diff options
| author | Damien George <damien@micropython.org> | 2021-09-02 12:39:28 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-09-02 13:11:23 +1000 |
| commit | afe0634c989d81f0c887308a7bc152061cb5d319 (patch) | |
| tree | 24d93b633842560249f5ceb64f01ca799bf6c080 /extmod/machine_spi.c | |
| parent | 122d901ef1b624c26771532cb4725eaa8f85e0f4 (diff) | |
extmod/machine_spi: Make SoftSPI configurable via macro option.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/machine_spi.c')
| -rw-r--r-- | extmod/machine_spi.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/extmod/machine_spi.c b/extmod/machine_spi.c index c951a5137..ae5e6677d 100644 --- a/extmod/machine_spi.c +++ b/extmod/machine_spi.c @@ -30,8 +30,6 @@ #include "py/runtime.h" #include "extmod/machine_spi.h" -#if MICROPY_PY_MACHINE_SPI - // if a port didn't define MSB/LSB constants then provide them #ifndef MICROPY_PY_MACHINE_SPI_MSB #define MICROPY_PY_MACHINE_SPI_MSB (0) @@ -41,6 +39,8 @@ /******************************************************************************/ // MicroPython bindings for generic machine.SPI +#if MICROPY_PY_MACHINE_SPI || MICROPY_PY_MACHINE_SOFTSPI + STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_obj_base_t *s = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t *)s->type->protocol; @@ -115,12 +115,15 @@ STATIC const mp_rom_map_elem_t machine_spi_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_MSB), MP_ROM_INT(MICROPY_PY_MACHINE_SPI_MSB) }, { MP_ROM_QSTR(MP_QSTR_LSB), MP_ROM_INT(MICROPY_PY_MACHINE_SPI_LSB) }, }; - MP_DEFINE_CONST_DICT(mp_machine_spi_locals_dict, machine_spi_locals_dict_table); +#endif // MICROPY_PY_MACHINE_SPI || MICROPY_PY_MACHINE_SOFTSPI + /******************************************************************************/ // Implementation of soft SPI +#if MICROPY_PY_MACHINE_SOFTSPI + STATIC uint32_t baudrate_from_delay_half(uint32_t delay_half) { #ifdef MICROPY_HW_SOFTSPI_MIN_DELAY if (delay_half == MICROPY_HW_SOFTSPI_MIN_DELAY) { @@ -258,4 +261,4 @@ const mp_obj_type_t mp_machine_soft_spi_type = { .locals_dict = (mp_obj_dict_t *)&mp_machine_spi_locals_dict, }; -#endif // MICROPY_PY_MACHINE_SPI +#endif // MICROPY_PY_MACHINE_SOFTSPI |
