@@ -3009,7 +3009,9 @@ struct mg_profitem {
3009
3009
#endif
3010
3010
3011
3011
3012
- #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_CYW) && MG_ENABLE_DRIVER_CYW
3012
+ #if MG_ENABLE_TCPIP && \
3013
+ ((defined(MG_ENABLE_DRIVER_CYW) && MG_ENABLE_DRIVER_CYW) || \
3014
+ (defined(MG_ENABLE_DRIVER_CYW_SDIO) && MG_ENABLE_DRIVER_CYW_SDIO))
3013
3015
3014
3016
struct mg_tcpip_spi_ {
3015
3017
void *spi; // Opaque SPI bus descriptor
@@ -3029,7 +3031,7 @@ struct mg_tcpip_driver_cyw_firmware {
3029
3031
};
3030
3032
3031
3033
struct mg_tcpip_driver_cyw_data {
3032
- struct mg_tcpip_spi_ *spi ;
3034
+ void *bus ;
3033
3035
struct mg_tcpip_driver_cyw_firmware *fw;
3034
3036
char *ssid;
3035
3037
char *pass;
@@ -3279,6 +3281,45 @@ struct mg_tcpip_driver_same54_data {
3279
3281
#endif
3280
3282
3281
3283
3284
+ #if MG_ENABLE_TCPIP && \
3285
+ (defined(MG_ENABLE_DRIVER_CYW_SDIO) && MG_ENABLE_DRIVER_CYW_SDIO)
3286
+
3287
+ // Specific chip/card driver --> SDIO driver --> HAL --> SDIO hw controller
3288
+
3289
+ // API with HAL for hardware controller
3290
+ // - Provide a function to init the controller (external)
3291
+ // - Provide these functions:
3292
+ struct mg_tcpip_sdio {
3293
+ void *sdio; // Opaque SDIO bus descriptor
3294
+ void (*cfg)(void *, uint8_t ); // select operating parameters
3295
+ // SDIO transaction: send cmd with a possible 1-byte read or write
3296
+ bool (*txn)(void *, uint8_t cmd, uint32_t arg, uint32_t *r);
3297
+ // SDIO extended transaction: write or read len bytes, using blksz blocks
3298
+ bool (*xfr)(void *, bool write, uint32_t arg, uint16_t blksz, uint32_t *,
3299
+ uint32_t len, uint32_t *r);
3300
+ };
3301
+
3302
+ // API with driver (e.g.: cyw.c)
3303
+ // Once the hardware controller has been initialized:
3304
+ // - Init card: selects the card, sets F0 block size, sets bus width and speed
3305
+ bool mg_sdio_init (struct mg_tcpip_sdio *sdio);
3306
+ // - Enable other possible functions (F1 to F7)
3307
+ bool mg_sdio_enable_f (struct mg_tcpip_sdio *sdio, unsigned int f);
3308
+ // - Wait for them to be ready
3309
+ bool mg_sdio_waitready_f (struct mg_tcpip_sdio *sdio, unsigned int f);
3310
+ // - Set their transfer block length
3311
+ bool mg_sdio_set_blksz (struct mg_tcpip_sdio *sdio, unsigned int f,
3312
+ uint16_t blksz);
3313
+ // - Transfer data to/from a function (abstracts from transaction type)
3314
+ // - Requesting a read transfer > blocksize means block transfer will be used.
3315
+ // - Drivers must have room to accomodate a whole block transfer, see sdio.c
3316
+ // - Transfers of > 1 byte --> (uint32_t *) data. 1-byte --> (uint8_t *) data
3317
+ bool mg_sdio_transfer (struct mg_tcpip_sdio *sdio, bool write, unsigned int f,
3318
+ uint32_t addr, void *data, uint32_t len);
3319
+
3320
+ #endif
3321
+
3322
+
3282
3323
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_STM32F) && \
3283
3324
MG_ENABLE_DRIVER_STM32F
3284
3325
0 commit comments