From 911662cc10971b1b0054fe0b19686e4a1683b9bd Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 23 Nov 2023 15:21:34 +1100 Subject: [PATCH] esp8266/machine_spi: Rename machine_hspi to machine_spi. This renames the type, functions and file to match other ports. Signed-off-by: Damien George --- ports/esp8266/Makefile | 2 +- ports/esp8266/boards/esp8266_common.ld | 1 - .../esp8266/{machine_hspi.c => machine_spi.c} | 34 +++++++++---------- ports/esp8266/modmachine.c | 2 +- ports/esp8266/modmachine.h | 1 - 5 files changed, 19 insertions(+), 21 deletions(-) rename ports/esp8266/{machine_hspi.c => machine_spi.c} (85%) diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index cea0e789c6..88c129952e 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -114,7 +114,7 @@ SRC_C = \ machine_bitstream.c \ machine_pin.c \ machine_rtc.c \ - machine_hspi.c \ + machine_spi.c \ modesp.c \ network_wlan.c \ ets_alt_task.c \ diff --git a/ports/esp8266/boards/esp8266_common.ld b/ports/esp8266/boards/esp8266_common.ld index ed8c6a7fe8..cf4883acc9 100644 --- a/ports/esp8266/boards/esp8266_common.ld +++ b/ports/esp8266/boards/esp8266_common.ld @@ -161,7 +161,6 @@ SECTIONS *modmachine.o(.literal*, .text*) *machine_wdt.o(.literal*, .text*) *machine_spi.o(.literal*, .text*) - *machine_hspi.o(.literal*, .text*) *hspi.o(.literal*, .text*) *modesp.o(.literal* .text*) *modespnow.o(.literal* .text*) diff --git a/ports/esp8266/machine_hspi.c b/ports/esp8266/machine_spi.c similarity index 85% rename from ports/esp8266/machine_hspi.c rename to ports/esp8266/machine_spi.c index 1a7de7f49b..b7f8ecf240 100644 --- a/ports/esp8266/machine_hspi.c +++ b/ports/esp8266/machine_spi.c @@ -41,14 +41,14 @@ #if MICROPY_PY_MACHINE_SPI -typedef struct _machine_hspi_obj_t { +typedef struct _machine_spi_obj_t { mp_obj_base_t base; uint32_t baudrate; uint8_t polarity; uint8_t phase; -} machine_hspi_obj_t; +} machine_spi_obj_t; -STATIC void machine_hspi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) { +STATIC void machine_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) { (void)self_in; if (dest == NULL) { @@ -94,14 +94,14 @@ STATIC void machine_hspi_transfer(mp_obj_base_t *self_in, size_t len, const uint /******************************************************************************/ // MicroPython bindings for HSPI -STATIC void machine_hspi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - machine_hspi_obj_t *self = MP_OBJ_TO_PTR(self_in); +STATIC void machine_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + machine_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "HSPI(id=1, baudrate=%u, polarity=%u, phase=%u)", self->baudrate, self->polarity, self->phase); } -STATIC void machine_hspi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - machine_hspi_obj_t *self = (machine_hspi_obj_t *)self_in; +STATIC void machine_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + machine_spi_obj_t *self = (machine_spi_obj_t *)self_in; enum { ARG_baudrate, ARG_polarity, ARG_phase }; static const mp_arg_t allowed_args[] = { @@ -150,7 +150,7 @@ STATIC void machine_hspi_init(mp_obj_base_t *self_in, size_t n_args, const mp_ob spi_mode(HSPI, self->phase, self->polarity); } -mp_obj_t machine_hspi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +mp_obj_t machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { MP_MACHINE_SPI_CHECK_FOR_LEGACY_SOFTSPI_CONSTRUCTION(n_args, n_kw, args); // args[0] holds the id of the peripheral @@ -159,29 +159,29 @@ mp_obj_t machine_hspi_make_new(const mp_obj_type_t *type, size_t n_args, size_t mp_raise_ValueError(NULL); } - machine_hspi_obj_t *self = mp_obj_malloc(machine_hspi_obj_t, &machine_hspi_type); + machine_spi_obj_t *self = mp_obj_malloc(machine_spi_obj_t, &machine_spi_type); // set defaults self->baudrate = 80000000L; self->polarity = 0; self->phase = 0; mp_map_t kw_args; mp_map_init_fixed_table(&kw_args, n_kw, args + n_args); - machine_hspi_init((mp_obj_base_t *)self, n_args - 1, args + 1, &kw_args); + machine_spi_init((mp_obj_base_t *)self, n_args - 1, args + 1, &kw_args); return MP_OBJ_FROM_PTR(self); } -STATIC const mp_machine_spi_p_t machine_hspi_p = { - .init = machine_hspi_init, - .transfer = machine_hspi_transfer, +STATIC const mp_machine_spi_p_t machine_spi_p = { + .init = machine_spi_init, + .transfer = machine_spi_transfer, }; MP_DEFINE_CONST_OBJ_TYPE( - machine_hspi_type, + machine_spi_type, MP_QSTR_HSPI, MP_TYPE_FLAG_NONE, - make_new, machine_hspi_make_new, - print, machine_hspi_print, - protocol, &machine_hspi_p, + make_new, machine_spi_make_new, + print, machine_spi_print, + protocol, &machine_spi_p, locals_dict, &mp_machine_spi_locals_dict ); diff --git a/ports/esp8266/modmachine.c b/ports/esp8266/modmachine.c index 78d5bde26d..3daf5ad876 100644 --- a/ports/esp8266/modmachine.c +++ b/ports/esp8266/modmachine.c @@ -432,7 +432,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SoftI2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) }, #endif #if MICROPY_PY_MACHINE_SPI - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_hspi_type) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_spi_type) }, { MP_ROM_QSTR(MP_QSTR_SoftSPI), MP_ROM_PTR(&mp_machine_soft_spi_type) }, #endif diff --git a/ports/esp8266/modmachine.h b/ports/esp8266/modmachine.h index 5a90a6c6fe..ff8670687b 100644 --- a/ports/esp8266/modmachine.h +++ b/ports/esp8266/modmachine.h @@ -5,7 +5,6 @@ extern const mp_obj_type_t pyb_pin_type; extern const mp_obj_type_t pyb_rtc_type; -extern const mp_obj_type_t machine_hspi_type; MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_info_obj);