From e7bfbf99fa734a24d21438ef1db5b2b62abe9522 Mon Sep 17 00:00:00 2001 From: cpq Date: Wed, 2 Dec 2026 23:55:57 +0000 Subject: [PATCH] Rename mg_tcpip_spi to mg_spi and move it to flash.h --- mongoose.c | 50 +++++++++---------- mongoose.h | 35 +++++++------ src/drivers/cyw.c | 4 +- src/drivers/st67w6.c | 2 +- src/drivers/w5100.c | 22 ++++---- src/drivers/w5100.h | 2 +- src/drivers/w5500.c | 22 ++++---- src/drivers/w5500.h | 2 +- src/flash.h | 8 +-- src/net_builtin.h | 13 ----- src/periph.h | 16 ++++++ test/Makefile | 2 +- .../arduino/nano-w5500-mqtt/w5500-mqtt.ino | 2 +- tutorials/arduino/w5500-http/w5500-http.ino | 2 +- tutorials/arduino/w5500-mqtt/w5500-mqtt.ino | 2 +- tutorials/rp/pico-rm2/wifi.c | 4 +- tutorials/rp/w5500-evb-pico/main.c | 2 +- tutorials/rp/w55rp20-evb-pico/main.c | 2 +- .../stm32/nucleo-f429zi/minimal-rm2/main.c | 4 +- .../stm32/nucleo-f746zg/minimal-rm2/main.c | 4 +- .../stm32/nucleo-g031k8/minimal-w5500/main.c | 2 +- tutorials/stm32/nucleo-u5a5zj-q/cubemx/wifi.c | 4 +- .../stm32/nucleo-u5a5zj-q/minimal/wifi.c | 4 +- 23 files changed, 104 insertions(+), 106 deletions(-) create mode 100644 src/periph.h diff --git a/mongoose.c b/mongoose.c index 363838d0..202f715d 100644 --- a/mongoose.c +++ b/mongoose.c @@ -31873,7 +31873,7 @@ static bool cyw_spi_write(unsigned int f, uint32_t addr, void *data, uint16_t len) { struct mg_tcpip_driver_cyw_data *d = (struct mg_tcpip_driver_cyw_data *) s_ifp->driver_data; - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) d->bus; + struct mg_spi *s = (struct mg_spi *) d->bus; uint32_t hdr = CYW_SPID_WR | CYW_SPID_INC | CYW_SPID_FUNC(f) | CYW_SPID_ADDR(addr) | CYW_SPID_LEN(len); // gSPI header // TODO(scaprile): check spin in between and timeout values, return false @@ -31903,7 +31903,7 @@ static void cyw_spi_read(unsigned int f, uint32_t addr, void *data, uint16_t len) { struct mg_tcpip_driver_cyw_data *d = (struct mg_tcpip_driver_cyw_data *) s_ifp->driver_data; - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) d->bus; + struct mg_spi *s = (struct mg_spi *) d->bus; uint32_t padding = f == CYW_SPID_FUNC_CHIP ? 4 @@ -36690,7 +36690,7 @@ static size_t st67w6_spi_poll(uint8_t *write, uint8_t *read) { struct mg_tcpip_driver_st67w6_data *d = (struct mg_tcpip_driver_st67w6_data *) s_ifp->driver_data; struct spi_hdr *th, *rh = (struct spi_hdr *) read; - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) d->spi; + struct mg_spi *s = (struct mg_spi *) d->spi; size_t padded; unsigned int times; @@ -39324,7 +39324,7 @@ struct mg_tcpip_driver mg_tcpip_driver_usb_rp = {mgi_usb_rp_init, mg_usb_tx, #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_W5100) && MG_ENABLE_DRIVER_W5100 -static void w5100_txn(struct mg_tcpip_spi *s, uint16_t addr, bool wr, void *buf, +static void w5100_txn(struct mg_spi *s, uint16_t addr, bool wr, void *buf, size_t len) { uint8_t control = wr ? 0xF0 : 0x0F; uint8_t cmd[] = {control, (uint8_t) (addr >> 8), (uint8_t) (addr & 255)}; @@ -39336,16 +39336,16 @@ static void w5100_txn(struct mg_tcpip_spi *s, uint16_t addr, bool wr, void *buf, } // clang-format off -static void w5100_wn(struct mg_tcpip_spi *s, uint16_t addr, void *buf, size_t len) { w5100_txn(s, addr, true, buf, len); } -static void w5100_w1(struct mg_tcpip_spi *s, uint16_t addr, uint8_t val) { w5100_wn(s, addr, &val, 1); } -static void w5100_w2(struct mg_tcpip_spi *s, uint16_t addr, uint16_t val) { uint8_t buf[2] = {(uint8_t) (val >> 8), (uint8_t) (val & 255)}; w5100_wn(s, addr, buf, sizeof(buf)); } -static void w5100_rn(struct mg_tcpip_spi *s, uint16_t addr, void *buf, size_t len) { w5100_txn(s, addr, false, buf, len); } -static uint8_t w5100_r1(struct mg_tcpip_spi *s, uint16_t addr) { uint8_t r = 0; w5100_rn(s, addr, &r, 1); return r; } -static uint16_t w5100_r2(struct mg_tcpip_spi *s, uint16_t addr) { uint8_t buf[2] = {0, 0}; w5100_rn(s, addr, buf, sizeof(buf)); return (uint16_t) ((buf[0] << 8) | buf[1]); } +static void w5100_wn(struct mg_spi *s, uint16_t addr, void *buf, size_t len) { w5100_txn(s, addr, true, buf, len); } +static void w5100_w1(struct mg_spi *s, uint16_t addr, uint8_t val) { w5100_wn(s, addr, &val, 1); } +static void w5100_w2(struct mg_spi *s, uint16_t addr, uint16_t val) { uint8_t buf[2] = {(uint8_t) (val >> 8), (uint8_t) (val & 255)}; w5100_wn(s, addr, buf, sizeof(buf)); } +static void w5100_rn(struct mg_spi *s, uint16_t addr, void *buf, size_t len) { w5100_txn(s, addr, false, buf, len); } +static uint8_t w5100_r1(struct mg_spi *s, uint16_t addr) { uint8_t r = 0; w5100_rn(s, addr, &r, 1); return r; } +static uint16_t w5100_r2(struct mg_spi *s, uint16_t addr) { uint8_t buf[2] = {0, 0}; w5100_rn(s, addr, buf, sizeof(buf)); return (uint16_t) ((buf[0] << 8) | buf[1]); } // clang-format on static size_t w5100_rx(void *buf, size_t buflen, struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; uint16_t r = 0, n = 0, len = (uint16_t) buflen, n2; // Read recv len while ((n2 = w5100_r2(s, 0x426)) > n) n = n2; // Until it is stable if (n > 0) { @@ -39371,7 +39371,7 @@ static size_t w5100_rx(void *buf, size_t buflen, struct mg_tcpip_if *ifp) { static size_t w5100_tx(const void *buf, size_t buflen, struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; uint16_t i, n = 0, ptr = 0, len = (uint16_t) buflen; while (n < len) n = w5100_r2(s, 0x420); // Wait for space ptr = w5100_r2(s, 0x424); // Get write pointer @@ -39399,7 +39399,7 @@ static size_t w5100_tx(const void *buf, size_t buflen, } static bool w5100_init(struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; s->end(s->spi); w5100_w1(s, 0, 0x80); // Reset chip: CR -> 0x80 w5100_w1(s, 0x72, 0x53); // CR PHYLCKR -> unlock PHY @@ -39415,7 +39415,7 @@ static bool w5100_init(struct mg_tcpip_if *ifp) { } static bool w5100_poll(struct mg_tcpip_if *ifp, bool s1) { - struct mg_tcpip_spi *spi = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *spi = (struct mg_spi *) ifp->driver_data; return s1 ? w5100_r1(spi, 0x3c /* PHYSR */) & 1 : false; // Bit 0 of PHYSR is LNK (0 - down, 1 - up) } @@ -39433,7 +39433,7 @@ struct mg_tcpip_driver mg_tcpip_driver_w5100 = {w5100_init, w5100_tx, w5100_rx, enum { W5500_CR = 0, W5500_S0 = 1, W5500_TX0 = 2, W5500_RX0 = 3 }; -static void w5500_txn(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, +static void w5500_txn(struct mg_spi *s, uint8_t block, uint16_t addr, bool wr, void *buf, size_t len) { uint8_t cmd[] = {(uint8_t) (addr >> 8), (uint8_t) (addr & 255), (uint8_t) ((block << 3) | (wr ? 4 : 0))}; @@ -39445,16 +39445,16 @@ static void w5500_txn(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, } // clang-format off -static void w5500_wn(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, void *buf, size_t len) { w5500_txn(s, block, addr, true, buf, len); } -static void w5500_w1(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, uint8_t val) { w5500_wn(s, block, addr, &val, 1); } -static void w5500_w2(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, uint16_t val) { uint8_t buf[2] = {(uint8_t) (val >> 8), (uint8_t) (val & 255)}; w5500_wn(s, block, addr, buf, sizeof(buf)); } -static void w5500_rn(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, void *buf, size_t len) { w5500_txn(s, block, addr, false, buf, len); } -static uint8_t w5500_r1(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr) { uint8_t r = 0; w5500_rn(s, block, addr, &r, 1); return r; } -static uint16_t w5500_r2(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr) { uint8_t buf[2] = {0, 0}; w5500_rn(s, block, addr, buf, sizeof(buf)); return (uint16_t) ((buf[0] << 8) | buf[1]); } +static void w5500_wn(struct mg_spi *s, uint8_t block, uint16_t addr, void *buf, size_t len) { w5500_txn(s, block, addr, true, buf, len); } +static void w5500_w1(struct mg_spi *s, uint8_t block, uint16_t addr, uint8_t val) { w5500_wn(s, block, addr, &val, 1); } +static void w5500_w2(struct mg_spi *s, uint8_t block, uint16_t addr, uint16_t val) { uint8_t buf[2] = {(uint8_t) (val >> 8), (uint8_t) (val & 255)}; w5500_wn(s, block, addr, buf, sizeof(buf)); } +static void w5500_rn(struct mg_spi *s, uint8_t block, uint16_t addr, void *buf, size_t len) { w5500_txn(s, block, addr, false, buf, len); } +static uint8_t w5500_r1(struct mg_spi *s, uint8_t block, uint16_t addr) { uint8_t r = 0; w5500_rn(s, block, addr, &r, 1); return r; } +static uint16_t w5500_r2(struct mg_spi *s, uint8_t block, uint16_t addr) { uint8_t buf[2] = {0, 0}; w5500_rn(s, block, addr, buf, sizeof(buf)); return (uint16_t) ((buf[0] << 8) | buf[1]); } // clang-format on static size_t w5500_rx(void *buf, size_t buflen, struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; uint16_t r = 0, n = 0, len = (uint16_t) buflen, n2; // Read recv len while ((n2 = w5500_r2(s, W5500_S0, 0x26)) > n) n = n2; // Until it is stable // printf("RSR: %d\n", (int) n); @@ -39474,7 +39474,7 @@ static size_t w5500_rx(void *buf, size_t buflen, struct mg_tcpip_if *ifp) { static size_t w5500_tx(const void *buf, size_t buflen, struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; uint16_t i, ptr, n = 0, len = (uint16_t) buflen; while (n < len) n = w5500_r2(s, W5500_S0, 0x20); // Wait for space ptr = w5500_r2(s, W5500_S0, 0x24); // Get write pointer @@ -39493,7 +39493,7 @@ static size_t w5500_tx(const void *buf, size_t buflen, } static bool w5500_init(struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; s->end(s->spi); w5500_w1(s, W5500_CR, 0, 0x80); // Reset chip: CR -> 0x80 w5500_w1(s, W5500_CR, 0x2e, 0); // CR PHYCFGR -> reset @@ -39507,7 +39507,7 @@ static bool w5500_init(struct mg_tcpip_if *ifp) { } static bool w5500_poll(struct mg_tcpip_if *ifp, bool s1) { - struct mg_tcpip_spi *spi = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *spi = (struct mg_spi *) ifp->driver_data; return s1 ? w5500_r1(spi, W5500_CR, 0x2e /* PHYCFGR */) & 1 : false; // Bit 0 of PHYCFGR is LNK (0 - down, 1 - up) } diff --git a/mongoose.h b/mongoose.h index b6712ab6..906146d5 100644 --- a/mongoose.h +++ b/mongoose.h @@ -4637,7 +4637,21 @@ void mg_mdash_free(struct mg_mgr *); -#if (MG_OTA != MG_OTA_NONE && MG_OTA != MG_OTA_CUSTOM) || MG_ENABLE_LFS +// SPI bus abstraction for SPI-attached chips, e.g. W5500. +// Network drivers get it via the driver_data field +struct mg_spi { + void *spi; // Opaque SPI bus handle passed to all callbacks + void (*begin)(void *); // Assert chip-select, start of transaction + void (*end)(void *); // Deassert chip-select, end of transaction + void (*txn)(void *, uint8_t *write, uint8_t *read, size_t); // Full duplex +}; + +// SPI bus for SPI-attached network chips, defined by the application. +// Used by the drivers' INIT macros, e.g. MG_TCPIP_DRIVER_W5500_INIT +extern struct mg_spi mg_spi; + + + struct mg_flash { void *start; // Address at which flash starts @@ -4655,8 +4669,6 @@ bool mg_ota_flash_begin(size_t new_firmware_size, struct mg_flash *flash); bool mg_ota_flash_write(const void *buf, size_t len, struct mg_flash *flash); bool mg_ota_flash_end(struct mg_flash *flash); -#endif - @@ -4926,19 +4938,6 @@ extern const uint8_t mcast_addr[6]; // Multicast MAC address programmed by driv - -// SPI bus abstraction for SPI-attached network chips (e.g. W5500). -// Populate and assign to the driver's driver_data field. -struct mg_tcpip_spi { - void *spi; // Opaque SPI bus handle passed to all callbacks - void (*begin)(void *); // Assert chip-select (start of transaction) - void (*end)(void *); // Deassert chip-select (end of transaction) - void (*txn)(void *, uint8_t *write, uint8_t *read, size_t); // Full-duplex transfer: write and read len bytes simultaneously -}; - -// SPI bus for SPI-attached network chips, defined by the application. -// Used by the drivers' INIT macros, e.g. MG_TCPIP_DRIVER_W5500_INIT -extern struct mg_tcpip_spi mg_spi; // Alignment attributes for DMA-capable Ethernet descriptor buffers. // Use these on driver RX/TX descriptor arrays where the hardware requires @@ -6436,7 +6435,7 @@ extern struct mg_tcpip_driver mg_tcpip_driver_usb_rp; extern struct mg_tcpip_driver mg_tcpip_driver_w5100; // Initialises W5100 on mgr. The application defines -// struct mg_tcpip_spi mg_spi +// struct mg_spi mg_spi #define MG_TCPIP_DRIVER_W5100_INIT(mgr) \ do { \ static struct mg_tcpip_if mif_; \ @@ -6463,7 +6462,7 @@ extern struct mg_tcpip_driver mg_tcpip_driver_w5100; extern struct mg_tcpip_driver mg_tcpip_driver_w5500; // Initialises W5500 on mgr. The application defines -// struct mg_tcpip_spi mg_spi. Example: tutorials/rp/w5500-evb-pico +// struct mg_spi mg_spi. Example: tutorials/rp/w5500-evb-pico #define MG_TCPIP_DRIVER_W5500_INIT(mgr) \ do { \ static struct mg_tcpip_if mif_; \ diff --git a/src/drivers/cyw.c b/src/drivers/cyw.c index 7bcabcaa..95a9b12d 100644 --- a/src/drivers/cyw.c +++ b/src/drivers/cyw.c @@ -1183,7 +1183,7 @@ static bool cyw_spi_write(unsigned int f, uint32_t addr, void *data, uint16_t len) { struct mg_tcpip_driver_cyw_data *d = (struct mg_tcpip_driver_cyw_data *) s_ifp->driver_data; - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) d->bus; + struct mg_spi *s = (struct mg_spi *) d->bus; uint32_t hdr = CYW_SPID_WR | CYW_SPID_INC | CYW_SPID_FUNC(f) | CYW_SPID_ADDR(addr) | CYW_SPID_LEN(len); // gSPI header // TODO(scaprile): check spin in between and timeout values, return false @@ -1213,7 +1213,7 @@ static void cyw_spi_read(unsigned int f, uint32_t addr, void *data, uint16_t len) { struct mg_tcpip_driver_cyw_data *d = (struct mg_tcpip_driver_cyw_data *) s_ifp->driver_data; - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) d->bus; + struct mg_spi *s = (struct mg_spi *) d->bus; uint32_t padding = f == CYW_SPID_FUNC_CHIP ? 4 diff --git a/src/drivers/st67w6.c b/src/drivers/st67w6.c index 3b2fae87..f04dd4b7 100644 --- a/src/drivers/st67w6.c +++ b/src/drivers/st67w6.c @@ -442,7 +442,7 @@ static size_t st67w6_spi_poll(uint8_t *write, uint8_t *read) { struct mg_tcpip_driver_st67w6_data *d = (struct mg_tcpip_driver_st67w6_data *) s_ifp->driver_data; struct spi_hdr *th, *rh = (struct spi_hdr *) read; - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) d->spi; + struct mg_spi *s = (struct mg_spi *) d->spi; size_t padded; unsigned int times; diff --git a/src/drivers/w5100.c b/src/drivers/w5100.c index e6e51ad3..53f3e89e 100644 --- a/src/drivers/w5100.c +++ b/src/drivers/w5100.c @@ -2,7 +2,7 @@ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_W5100) && MG_ENABLE_DRIVER_W5100 -static void w5100_txn(struct mg_tcpip_spi *s, uint16_t addr, bool wr, void *buf, +static void w5100_txn(struct mg_spi *s, uint16_t addr, bool wr, void *buf, size_t len) { uint8_t control = wr ? 0xF0 : 0x0F; uint8_t cmd[] = {control, (uint8_t) (addr >> 8), (uint8_t) (addr & 255)}; @@ -14,16 +14,16 @@ static void w5100_txn(struct mg_tcpip_spi *s, uint16_t addr, bool wr, void *buf, } // clang-format off -static void w5100_wn(struct mg_tcpip_spi *s, uint16_t addr, void *buf, size_t len) { w5100_txn(s, addr, true, buf, len); } -static void w5100_w1(struct mg_tcpip_spi *s, uint16_t addr, uint8_t val) { w5100_wn(s, addr, &val, 1); } -static void w5100_w2(struct mg_tcpip_spi *s, uint16_t addr, uint16_t val) { uint8_t buf[2] = {(uint8_t) (val >> 8), (uint8_t) (val & 255)}; w5100_wn(s, addr, buf, sizeof(buf)); } -static void w5100_rn(struct mg_tcpip_spi *s, uint16_t addr, void *buf, size_t len) { w5100_txn(s, addr, false, buf, len); } -static uint8_t w5100_r1(struct mg_tcpip_spi *s, uint16_t addr) { uint8_t r = 0; w5100_rn(s, addr, &r, 1); return r; } -static uint16_t w5100_r2(struct mg_tcpip_spi *s, uint16_t addr) { uint8_t buf[2] = {0, 0}; w5100_rn(s, addr, buf, sizeof(buf)); return (uint16_t) ((buf[0] << 8) | buf[1]); } +static void w5100_wn(struct mg_spi *s, uint16_t addr, void *buf, size_t len) { w5100_txn(s, addr, true, buf, len); } +static void w5100_w1(struct mg_spi *s, uint16_t addr, uint8_t val) { w5100_wn(s, addr, &val, 1); } +static void w5100_w2(struct mg_spi *s, uint16_t addr, uint16_t val) { uint8_t buf[2] = {(uint8_t) (val >> 8), (uint8_t) (val & 255)}; w5100_wn(s, addr, buf, sizeof(buf)); } +static void w5100_rn(struct mg_spi *s, uint16_t addr, void *buf, size_t len) { w5100_txn(s, addr, false, buf, len); } +static uint8_t w5100_r1(struct mg_spi *s, uint16_t addr) { uint8_t r = 0; w5100_rn(s, addr, &r, 1); return r; } +static uint16_t w5100_r2(struct mg_spi *s, uint16_t addr) { uint8_t buf[2] = {0, 0}; w5100_rn(s, addr, buf, sizeof(buf)); return (uint16_t) ((buf[0] << 8) | buf[1]); } // clang-format on static size_t w5100_rx(void *buf, size_t buflen, struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; uint16_t r = 0, n = 0, len = (uint16_t) buflen, n2; // Read recv len while ((n2 = w5100_r2(s, 0x426)) > n) n = n2; // Until it is stable if (n > 0) { @@ -49,7 +49,7 @@ static size_t w5100_rx(void *buf, size_t buflen, struct mg_tcpip_if *ifp) { static size_t w5100_tx(const void *buf, size_t buflen, struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; uint16_t i, n = 0, ptr = 0, len = (uint16_t) buflen; while (n < len) n = w5100_r2(s, 0x420); // Wait for space ptr = w5100_r2(s, 0x424); // Get write pointer @@ -77,7 +77,7 @@ static size_t w5100_tx(const void *buf, size_t buflen, } static bool w5100_init(struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; s->end(s->spi); w5100_w1(s, 0, 0x80); // Reset chip: CR -> 0x80 w5100_w1(s, 0x72, 0x53); // CR PHYLCKR -> unlock PHY @@ -93,7 +93,7 @@ static bool w5100_init(struct mg_tcpip_if *ifp) { } static bool w5100_poll(struct mg_tcpip_if *ifp, bool s1) { - struct mg_tcpip_spi *spi = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *spi = (struct mg_spi *) ifp->driver_data; return s1 ? w5100_r1(spi, 0x3c /* PHYSR */) & 1 : false; // Bit 0 of PHYSR is LNK (0 - down, 1 - up) } diff --git a/src/drivers/w5100.h b/src/drivers/w5100.h index ead9b6ef..bab8c6ac 100644 --- a/src/drivers/w5100.h +++ b/src/drivers/w5100.h @@ -6,7 +6,7 @@ extern struct mg_tcpip_driver mg_tcpip_driver_w5100; // Initialises W5100 on mgr. The application defines -// struct mg_tcpip_spi mg_spi +// struct mg_spi mg_spi #define MG_TCPIP_DRIVER_W5100_INIT(mgr) \ do { \ static struct mg_tcpip_if mif_; \ diff --git a/src/drivers/w5500.c b/src/drivers/w5500.c index c731e256..5008aa2b 100644 --- a/src/drivers/w5500.c +++ b/src/drivers/w5500.c @@ -4,7 +4,7 @@ enum { W5500_CR = 0, W5500_S0 = 1, W5500_TX0 = 2, W5500_RX0 = 3 }; -static void w5500_txn(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, +static void w5500_txn(struct mg_spi *s, uint8_t block, uint16_t addr, bool wr, void *buf, size_t len) { uint8_t cmd[] = {(uint8_t) (addr >> 8), (uint8_t) (addr & 255), (uint8_t) ((block << 3) | (wr ? 4 : 0))}; @@ -16,16 +16,16 @@ static void w5500_txn(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, } // clang-format off -static void w5500_wn(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, void *buf, size_t len) { w5500_txn(s, block, addr, true, buf, len); } -static void w5500_w1(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, uint8_t val) { w5500_wn(s, block, addr, &val, 1); } -static void w5500_w2(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, uint16_t val) { uint8_t buf[2] = {(uint8_t) (val >> 8), (uint8_t) (val & 255)}; w5500_wn(s, block, addr, buf, sizeof(buf)); } -static void w5500_rn(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr, void *buf, size_t len) { w5500_txn(s, block, addr, false, buf, len); } -static uint8_t w5500_r1(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr) { uint8_t r = 0; w5500_rn(s, block, addr, &r, 1); return r; } -static uint16_t w5500_r2(struct mg_tcpip_spi *s, uint8_t block, uint16_t addr) { uint8_t buf[2] = {0, 0}; w5500_rn(s, block, addr, buf, sizeof(buf)); return (uint16_t) ((buf[0] << 8) | buf[1]); } +static void w5500_wn(struct mg_spi *s, uint8_t block, uint16_t addr, void *buf, size_t len) { w5500_txn(s, block, addr, true, buf, len); } +static void w5500_w1(struct mg_spi *s, uint8_t block, uint16_t addr, uint8_t val) { w5500_wn(s, block, addr, &val, 1); } +static void w5500_w2(struct mg_spi *s, uint8_t block, uint16_t addr, uint16_t val) { uint8_t buf[2] = {(uint8_t) (val >> 8), (uint8_t) (val & 255)}; w5500_wn(s, block, addr, buf, sizeof(buf)); } +static void w5500_rn(struct mg_spi *s, uint8_t block, uint16_t addr, void *buf, size_t len) { w5500_txn(s, block, addr, false, buf, len); } +static uint8_t w5500_r1(struct mg_spi *s, uint8_t block, uint16_t addr) { uint8_t r = 0; w5500_rn(s, block, addr, &r, 1); return r; } +static uint16_t w5500_r2(struct mg_spi *s, uint8_t block, uint16_t addr) { uint8_t buf[2] = {0, 0}; w5500_rn(s, block, addr, buf, sizeof(buf)); return (uint16_t) ((buf[0] << 8) | buf[1]); } // clang-format on static size_t w5500_rx(void *buf, size_t buflen, struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; uint16_t r = 0, n = 0, len = (uint16_t) buflen, n2; // Read recv len while ((n2 = w5500_r2(s, W5500_S0, 0x26)) > n) n = n2; // Until it is stable // printf("RSR: %d\n", (int) n); @@ -45,7 +45,7 @@ static size_t w5500_rx(void *buf, size_t buflen, struct mg_tcpip_if *ifp) { static size_t w5500_tx(const void *buf, size_t buflen, struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; uint16_t i, ptr, n = 0, len = (uint16_t) buflen; while (n < len) n = w5500_r2(s, W5500_S0, 0x20); // Wait for space ptr = w5500_r2(s, W5500_S0, 0x24); // Get write pointer @@ -64,7 +64,7 @@ static size_t w5500_tx(const void *buf, size_t buflen, } static bool w5500_init(struct mg_tcpip_if *ifp) { - struct mg_tcpip_spi *s = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *s = (struct mg_spi *) ifp->driver_data; s->end(s->spi); w5500_w1(s, W5500_CR, 0, 0x80); // Reset chip: CR -> 0x80 w5500_w1(s, W5500_CR, 0x2e, 0); // CR PHYCFGR -> reset @@ -78,7 +78,7 @@ static bool w5500_init(struct mg_tcpip_if *ifp) { } static bool w5500_poll(struct mg_tcpip_if *ifp, bool s1) { - struct mg_tcpip_spi *spi = (struct mg_tcpip_spi *) ifp->driver_data; + struct mg_spi *spi = (struct mg_spi *) ifp->driver_data; return s1 ? w5500_r1(spi, W5500_CR, 0x2e /* PHYCFGR */) & 1 : false; // Bit 0 of PHYCFGR is LNK (0 - down, 1 - up) } diff --git a/src/drivers/w5500.h b/src/drivers/w5500.h index 7b7ca37f..f4003e3b 100644 --- a/src/drivers/w5500.h +++ b/src/drivers/w5500.h @@ -6,7 +6,7 @@ extern struct mg_tcpip_driver mg_tcpip_driver_w5500; // Initialises W5500 on mgr. The application defines -// struct mg_tcpip_spi mg_spi. Example: tutorials/rp/w5500-evb-pico +// struct mg_spi mg_spi. Example: tutorials/rp/w5500-evb-pico #define MG_TCPIP_DRIVER_W5500_INIT(mgr) \ do { \ static struct mg_tcpip_if mif_; \ diff --git a/src/flash.h b/src/flash.h index 8b42bf73..26289b6c 100644 --- a/src/flash.h +++ b/src/flash.h @@ -1,8 +1,6 @@ -#include "arch.h" -#include "config.h" -#include "ota.h" +#pragma once -#if (MG_OTA != MG_OTA_NONE && MG_OTA != MG_OTA_CUSTOM) || MG_ENABLE_LFS +#include "arch.h" struct mg_flash { void *start; // Address at which flash starts @@ -19,5 +17,3 @@ bool mg_lfs_init(size_t size); bool mg_ota_flash_begin(size_t new_firmware_size, struct mg_flash *flash); bool mg_ota_flash_write(const void *buf, size_t len, struct mg_flash *flash); bool mg_ota_flash_end(struct mg_flash *flash); - -#endif diff --git a/src/net_builtin.h b/src/net_builtin.h index ecceafcb..d1f0714a 100644 --- a/src/net_builtin.h +++ b/src/net_builtin.h @@ -168,19 +168,6 @@ extern const uint8_t mcast_addr[6]; // Multicast MAC address programmed by driv #include "drivers/xmc.h" #include "drivers/xmc7.h" -// SPI bus abstraction for SPI-attached network chips (e.g. W5500). -// Populate and assign to the driver's driver_data field. -struct mg_tcpip_spi { - void *spi; // Opaque SPI bus handle passed to all callbacks - void (*begin)(void *); // Assert chip-select (start of transaction) - void (*end)(void *); // Deassert chip-select (end of transaction) - void (*txn)(void *, uint8_t *write, uint8_t *read, size_t); // Full-duplex transfer: write and read len bytes simultaneously -}; - -// SPI bus for SPI-attached network chips, defined by the application. -// Used by the drivers' INIT macros, e.g. MG_TCPIP_DRIVER_W5500_INIT -extern struct mg_tcpip_spi mg_spi; - // Alignment attributes for DMA-capable Ethernet descriptor buffers. // Use these on driver RX/TX descriptor arrays where the hardware requires // specific alignment. diff --git a/src/periph.h b/src/periph.h new file mode 100644 index 00000000..cdbff2e7 --- /dev/null +++ b/src/periph.h @@ -0,0 +1,16 @@ +#pragma once + +#include "arch.h" + +// SPI bus abstraction for SPI-attached chips, e.g. W5500. +// Network drivers get it via the driver_data field +struct mg_spi { + void *spi; // Opaque SPI bus handle passed to all callbacks + void (*begin)(void *); // Assert chip-select, start of transaction + void (*end)(void *); // Deassert chip-select, end of transaction + void (*txn)(void *, uint8_t *write, uint8_t *read, size_t); // Full duplex +}; + +// SPI bus for SPI-attached network chips, defined by the application. +// Used by the drivers' INIT macros, e.g. MG_TCPIP_DRIVER_W5500_INIT +extern struct mg_spi mg_spi; diff --git a/test/Makefile b/test/Makefile index 6f23d7e5..9b71a591 100644 --- a/test/Makefile +++ b/test/Makefile @@ -98,7 +98,7 @@ mongoose.c: Makefile $(wildcard ../src/*.c) $(wildcard ../src/drivers/*.c) cd .. && (export LC_ALL=C ; cat src/license.h; echo; echo '#include "mongoose.h"' ; (for F in src/*.c src/drivers/*.c ; do echo; echo '#ifdef MG_ENABLE_LINES'; echo "#line 1 \"$$F\""; echo '#endif'; cat $$F | sed -e 's,#include ".*,,'; done))> $@ mongoose.h: $(HDRS) Makefile - cd .. && (export LC_ALL=C ; cat src/license.h; echo; echo '#ifndef MONGOOSE_H'; echo '#define MONGOOSE_H'; echo; cat src/version.h ; echo; cat src/ai.h; echo; echo '#ifdef __cplusplus'; echo 'extern "C" {'; echo '#endif'; cat src/arch.h src/arch_*.h src/os_*.h src/net_ft.h src/net_lwip.h src/net_rl.h src/config.h src/profile.h src/str.h src/queue.h src/fmt.h src/printf.h src/log.h src/timer.h src/fs.h src/lfs.h src/util.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/sha256.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/tls_aes128.h src/tls_p256.h src/tls_p384.h src/tls_chacha20.h src/tls_rsa.h src/tls_mbed.h src/tls_openssl.h src/ws.h src/sntp.h src/mqtt.h src/dns.h src/modbus.h src/json.h src/jwt.h src/rpc.h src/dash.h src/ota.h src/health.h src/mdash.h src/flash.h src/wifi.h src/l2.h src/net_builtin.h src/bsd.h src/drivers/*.h | sed -e '/keep/! s,#include ".*,,' -e 's,^#pragma once,,'; echo; echo '#ifdef __cplusplus'; echo '}'; echo '#endif'; echo '#endif // MONGOOSE_H')> $@ + cd .. && (export LC_ALL=C ; cat src/license.h; echo; echo '#ifndef MONGOOSE_H'; echo '#define MONGOOSE_H'; echo; cat src/version.h ; echo; cat src/ai.h; echo; echo '#ifdef __cplusplus'; echo 'extern "C" {'; echo '#endif'; cat src/arch.h src/arch_*.h src/os_*.h src/net_ft.h src/net_lwip.h src/net_rl.h src/config.h src/profile.h src/str.h src/queue.h src/fmt.h src/printf.h src/log.h src/timer.h src/fs.h src/lfs.h src/util.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/sha256.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/tls_aes128.h src/tls_p256.h src/tls_p384.h src/tls_chacha20.h src/tls_rsa.h src/tls_mbed.h src/tls_openssl.h src/ws.h src/sntp.h src/mqtt.h src/dns.h src/modbus.h src/json.h src/jwt.h src/rpc.h src/dash.h src/ota.h src/health.h src/mdash.h src/periph.h src/flash.h src/wifi.h src/l2.h src/net_builtin.h src/bsd.h src/drivers/*.h | sed -e '/keep/! s,#include ".*,,' -e 's,^#pragma once,,'; echo; echo '#ifdef __cplusplus'; echo '}'; echo '#endif'; echo '#endif // MONGOOSE_H')> $@ # Check that all external (exported) symbols have "mg_" prefix mg_prefix: mongoose.c mongoose.h diff --git a/tutorials/arduino/nano-w5500-mqtt/w5500-mqtt.ino b/tutorials/arduino/nano-w5500-mqtt/w5500-mqtt.ino index 5fb1153f..ae2a8e35 100644 --- a/tutorials/arduino/nano-w5500-mqtt/w5500-mqtt.ino +++ b/tutorials/arduino/nano-w5500-mqtt/w5500-mqtt.ino @@ -9,7 +9,7 @@ struct mg_connection *mqtt_connection; // SPI bus used by the W5500 driver, see MG_TCPIP_DRIVER_W5500_INIT -struct mg_tcpip_spi mg_spi = { +struct mg_spi mg_spi = { NULL, // SPI metadata [](void *) { digitalWrite(SS_PIN, LOW); SPI.beginTransaction(SPISettings()); }, [](void *) { digitalWrite(SS_PIN, HIGH); SPI.endTransaction(); }, diff --git a/tutorials/arduino/w5500-http/w5500-http.ino b/tutorials/arduino/w5500-http/w5500-http.ino index 49484424..27e9b32b 100644 --- a/tutorials/arduino/w5500-http/w5500-http.ino +++ b/tutorials/arduino/w5500-http/w5500-http.ino @@ -5,7 +5,7 @@ #define SS_PIN 17 // Slave select pin for the W5500 module // SPI bus used by the W5500 driver, see MG_TCPIP_DRIVER_W5500_INIT -struct mg_tcpip_spi mg_spi = { +struct mg_spi mg_spi = { NULL, // SPI metadata [](void *) { digitalWrite(SS_PIN, LOW); SPI.beginTransaction(SPISettings()); }, [](void *) { digitalWrite(SS_PIN, HIGH); SPI.endTransaction(); }, diff --git a/tutorials/arduino/w5500-mqtt/w5500-mqtt.ino b/tutorials/arduino/w5500-mqtt/w5500-mqtt.ino index 1227584f..79d6cda6 100644 --- a/tutorials/arduino/w5500-mqtt/w5500-mqtt.ino +++ b/tutorials/arduino/w5500-mqtt/w5500-mqtt.ino @@ -9,7 +9,7 @@ struct mg_connection *mqtt_connection; // SPI bus used by the W5500 driver, see MG_TCPIP_DRIVER_W5500_INIT -struct mg_tcpip_spi mg_spi = { +struct mg_spi mg_spi = { NULL, // SPI metadata [](void *) { digitalWrite(SS_PIN, LOW); SPI.beginTransaction(SPISettings()); }, [](void *) { digitalWrite(SS_PIN, HIGH); SPI.endTransaction(); }, diff --git a/tutorials/rp/pico-rm2/wifi.c b/tutorials/rp/pico-rm2/wifi.c index 0948b49f..9cc09513 100644 --- a/tutorials/rp/pico-rm2/wifi.c +++ b/tutorials/rp/pico-rm2/wifi.c @@ -165,7 +165,7 @@ void hwspecific_spi_end(void *arg) { (void) arg; } -static const struct mg_tcpip_spi spi = {NULL, hwspecific_spi_begin, +static const struct mg_spi spi = {NULL, hwspecific_spi_begin, hwspecific_spi_end, hwspecific_spi_txn}; #ifndef CYW43_RESOURCE_ATTRIBUTE @@ -274,7 +274,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) { static struct mg_tcpip_driver_cyw_data d = { {WIFI_SSID, WIFI_PASS, "mongoose", "mongoose", 0, 0, 0, 0, 10, true}, - (struct mg_tcpip_spi *) &spi, + (struct mg_spi *) &spi, (struct mg_tcpip_driver_cyw_firmware *) &fw, false, }; diff --git a/tutorials/rp/w5500-evb-pico/main.c b/tutorials/rp/w5500-evb-pico/main.c index 9eaa04c2..75c101b5 100644 --- a/tutorials/rp/w5500-evb-pico/main.c +++ b/tutorials/rp/w5500-evb-pico/main.c @@ -31,7 +31,7 @@ static void spi_txn(void *spi, uint8_t *tx, uint8_t *rx, size_t len) { } // SPI bus used by the W5500 driver, see MG_TCPIP_DRIVER_W5500_INIT -struct mg_tcpip_spi mg_spi = {NULL, spi_begin, spi_end, spi_txn}; +struct mg_spi mg_spi = {NULL, spi_begin, spi_end, spi_txn}; static void ethernet_init(void) { // Init SPI pins diff --git a/tutorials/rp/w55rp20-evb-pico/main.c b/tutorials/rp/w55rp20-evb-pico/main.c index 8e6545f6..67051cf7 100644 --- a/tutorials/rp/w55rp20-evb-pico/main.c +++ b/tutorials/rp/w55rp20-evb-pico/main.c @@ -151,7 +151,7 @@ static void spi_txn(void *arg, uint8_t *txdata, uint8_t *rxdata, size_t len) { } // SPI bus used by the W5500 driver, see MG_TCPIP_DRIVER_W5500_INIT -struct mg_tcpip_spi mg_spi = {NULL, spi_begin, spi_end, spi_txn}; +struct mg_spi mg_spi = {NULL, spi_begin, spi_end, spi_txn}; static void blink_task(void) { diff --git a/tutorials/stm32/nucleo-f429zi/minimal-rm2/main.c b/tutorials/stm32/nucleo-f429zi/minimal-rm2/main.c index d8c0fe77..c135f4eb 100644 --- a/tutorials/stm32/nucleo-f429zi/minimal-rm2/main.c +++ b/tutorials/stm32/nucleo-f429zi/minimal-rm2/main.c @@ -66,7 +66,7 @@ static void hwspecific_spi_init(void) { mg_delayms(50); } -static const struct mg_tcpip_spi spi = {NULL, hwspecific_spi_begin, hwspecific_spi_end, hwspecific_spi_txn}; +static const struct mg_spi spi = {NULL, hwspecific_spi_begin, hwspecific_spi_end, hwspecific_spi_txn}; #ifndef CYW43_RESOURCE_ATTRIBUTE #define CYW43_RESOURCE_ATTRIBUTE @@ -162,7 +162,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) { static struct mg_tcpip_driver_cyw_data d = { - {WIFI_SSID, WIFI_PASS, "mongoose", "mongoose", 0, 0, 0, 0, 10, true}, (struct mg_tcpip_spi *)&spi, (struct mg_tcpip_driver_cyw_firmware *)&fw, false}; + {WIFI_SSID, WIFI_PASS, "mongoose", "mongoose", 0, 0, 0, 0, 10, true}, (struct mg_spi *)&spi, (struct mg_tcpip_driver_cyw_firmware *)&fw, false}; int main(void) { uart_init(UART_DEBUG, 115200); // Initialise debug printf diff --git a/tutorials/stm32/nucleo-f746zg/minimal-rm2/main.c b/tutorials/stm32/nucleo-f746zg/minimal-rm2/main.c index 72822dd0..ccd1e3b8 100644 --- a/tutorials/stm32/nucleo-f746zg/minimal-rm2/main.c +++ b/tutorials/stm32/nucleo-f746zg/minimal-rm2/main.c @@ -66,7 +66,7 @@ static void hwspecific_spi_init(void) { mg_delayms(50); } -static const struct mg_tcpip_spi spi = {NULL, hwspecific_spi_begin, hwspecific_spi_end, hwspecific_spi_txn}; +static const struct mg_spi spi = {NULL, hwspecific_spi_begin, hwspecific_spi_end, hwspecific_spi_txn}; #ifndef CYW43_RESOURCE_ATTRIBUTE #define CYW43_RESOURCE_ATTRIBUTE @@ -162,7 +162,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) { static struct mg_tcpip_driver_cyw_data d = { - {WIFI_SSID, WIFI_PASS, "mongoose", "mongoose", 0, 0, 0, 0, 10, true}, (struct mg_tcpip_spi *)&spi, (struct mg_tcpip_driver_cyw_firmware *)&fw, false}; + {WIFI_SSID, WIFI_PASS, "mongoose", "mongoose", 0, 0, 0, 0, 10, true}, (struct mg_spi *)&spi, (struct mg_tcpip_driver_cyw_firmware *)&fw, false}; int main(void) { uart_init(UART_DEBUG, 115200); // Initialise debug printf diff --git a/tutorials/stm32/nucleo-g031k8/minimal-w5500/main.c b/tutorials/stm32/nucleo-g031k8/minimal-w5500/main.c index 5d225935..53ed2d33 100644 --- a/tutorials/stm32/nucleo-g031k8/minimal-w5500/main.c +++ b/tutorials/stm32/nucleo-g031k8/minimal-w5500/main.c @@ -22,7 +22,7 @@ static struct spi spi_pins = { }; // SPI bus used by the W5500 driver, see MG_TCPIP_DRIVER_W5500_INIT -struct mg_tcpip_spi mg_spi = { +struct mg_spi mg_spi = { .begin = (void (*)(void *)) spi_begin, .end = (void (*)(void *)) spi_end, .txn = (void (*)(void *, uint8_t *, uint8_t *, size_t)) spi_txn, diff --git a/tutorials/stm32/nucleo-u5a5zj-q/cubemx/wifi.c b/tutorials/stm32/nucleo-u5a5zj-q/cubemx/wifi.c index 27636b88..0adfd6d7 100644 --- a/tutorials/stm32/nucleo-u5a5zj-q/cubemx/wifi.c +++ b/tutorials/stm32/nucleo-u5a5zj-q/cubemx/wifi.c @@ -114,7 +114,7 @@ void hwspecific_spi_init(void) { HAL_GPIO_WritePin(SPI_CHIP_EN_GPIO_Port, SPI_CHIP_EN_Pin, 1); } -static const struct mg_tcpip_spi spi = {NULL, hwspecific_spi_begin, hwspecific_spi_end, hwspecific_spi_txn}; +static const struct mg_spi spi = {NULL, hwspecific_spi_begin, hwspecific_spi_end, hwspecific_spi_txn}; void wifi_setconfig(void *data) { struct mg_tcpip_driver_st67w6_data *d = (struct mg_tcpip_driver_st67w6_data *) data; @@ -128,6 +128,6 @@ void wifi_setconfig(void *data) { d->wifi.apsecurity = 0; d->wifi.apchannel = 10; d->wifi.apmode = ENABLE_WIFI_AP; - d->spi = (struct mg_tcpip_spi *) &spi; + d->spi = (struct mg_spi *) &spi; d->is_ready = hwspecific_is_ready; } diff --git a/tutorials/stm32/nucleo-u5a5zj-q/minimal/wifi.c b/tutorials/stm32/nucleo-u5a5zj-q/minimal/wifi.c index 2605403b..185501da 100644 --- a/tutorials/stm32/nucleo-u5a5zj-q/minimal/wifi.c +++ b/tutorials/stm32/nucleo-u5a5zj-q/minimal/wifi.c @@ -57,7 +57,7 @@ void hwspecific_spi_init(void) { hal_gpio_write(SPI_CHIP_EN, 1); } -static const struct mg_tcpip_spi spi = {NULL, hwspecific_spi_begin, hwspecific_spi_end, hwspecific_spi_txn}; +static const struct mg_spi spi = {NULL, hwspecific_spi_begin, hwspecific_spi_end, hwspecific_spi_txn}; void wifi_setconfig(void *data) { struct mg_tcpip_driver_st67w6_data *d = (struct mg_tcpip_driver_st67w6_data *) data; @@ -71,6 +71,6 @@ void wifi_setconfig(void *data) { d->wifi.apsecurity = 0; d->wifi.apchannel = 10; d->wifi.apmode = ENABLE_WIFI_AP; - d->spi = (struct mg_tcpip_spi *) &spi; + d->spi = (struct mg_spi *) &spi; d->is_ready = hwspecific_is_ready; }