|
41 | 41 | /******************************************************************************/ |
42 | 42 | // MicroPython bindings for generic machine.SPI |
43 | 43 |
|
44 | | -STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); |
45 | | - |
46 | | -mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { |
47 | | - // check the id argument, if given |
48 | | - if (n_args > 0) { |
49 | | - if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) { |
50 | | - #if defined(MICROPY_PY_MACHINE_SPI_MAKE_NEW) |
51 | | - // dispatch to port-specific constructor |
52 | | - extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); |
53 | | - return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, n_kw, args); |
54 | | - #else |
55 | | - mp_raise_ValueError(MP_ERROR_TEXT("invalid SPI peripheral")); |
56 | | - #endif |
57 | | - } |
58 | | - --n_args; |
59 | | - ++args; |
60 | | - } |
61 | | - |
62 | | - // software SPI |
63 | | - return mp_machine_soft_spi_make_new(type, n_args, n_kw, args); |
64 | | -} |
65 | | - |
66 | 44 | STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { |
67 | 45 | mp_obj_base_t *s = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); |
68 | 46 | mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t *)s->type->protocol; |
@@ -275,7 +253,7 @@ const mp_obj_type_t mp_machine_soft_spi_type = { |
275 | 253 | { &mp_type_type }, |
276 | 254 | .name = MP_QSTR_SoftSPI, |
277 | 255 | .print = mp_machine_soft_spi_print, |
278 | | - .make_new = mp_machine_spi_make_new, // delegate to master constructor |
| 256 | + .make_new = mp_machine_soft_spi_make_new, |
279 | 257 | .protocol = &mp_machine_soft_spi_p, |
280 | 258 | .locals_dict = (mp_obj_dict_t *)&mp_machine_spi_locals_dict, |
281 | 259 | }; |
|
0 commit comments