summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-11-23 15:21:34 +1100
committerDamien George <damien@micropython.org>2023-11-30 15:58:56 +1100
commit911662cc10971b1b0054fe0b19686e4a1683b9bd (patch)
treeb94adc3639afac73cc5b635a9fba9987e3cf1a21
parentc554df57f618fb8c42fcd120ce227a425e44c4bc (diff)
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 <damien@micropython.org>
-rw-r--r--ports/esp8266/Makefile2
-rw-r--r--ports/esp8266/boards/esp8266_common.ld1
-rw-r--r--ports/esp8266/machine_spi.c (renamed from ports/esp8266/machine_hspi.c)34
-rw-r--r--ports/esp8266/modmachine.c2
-rw-r--r--ports/esp8266/modmachine.h1
5 files changed, 19 insertions, 21 deletions
diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile
index cea0e789c..88c129952 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 ed8c6a7fe..cf4883acc 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
index 1a7de7f49..b7f8ecf24 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 78d5bde26..3daf5ad87 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 5a90a6c6f..ff8670687 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);