@@ -1107,6 +1107,7 @@ char *mg_random_str(char *buf, size_t len);
1107
1107
uint32_t mg_crc32 (uint32_t crc, const char *buf, size_t len);
1108
1108
uint64_t mg_millis (void ); // Return milliseconds since boot
1109
1109
bool mg_path_is_sane (const struct mg_str path);
1110
+ void mg_delayms (unsigned int ms);
1110
1111
1111
1112
#define MG_U32 (a, b, c, d ) \
1112
1113
(((uint32_t ) ((a) &255 ) << 24 ) | ((uint32_t ) ((b) &255 ) << 16 ) | \
@@ -2869,6 +2870,7 @@ extern struct mg_tcpip_driver mg_tcpip_driver_xmc7;
2869
2870
extern struct mg_tcpip_driver mg_tcpip_driver_ppp;
2870
2871
extern struct mg_tcpip_driver mg_tcpip_driver_pico_w;
2871
2872
extern struct mg_tcpip_driver mg_tcpip_driver_rw612;
2873
+ extern struct mg_tcpip_driver mg_tcpip_driver_cyw;
2872
2874
2873
2875
// Drivers that require SPI, can use this SPI abstraction
2874
2876
struct mg_tcpip_spi {
@@ -2961,6 +2963,57 @@ struct mg_profitem {
2961
2963
#endif
2962
2964
2963
2965
2966
+ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_CYW) && MG_ENABLE_DRIVER_CYW
2967
+
2968
+ struct mg_tcpip_spi_ {
2969
+ void *spi; // Opaque SPI bus descriptor
2970
+ void (*begin)(void *); // SPI begin: slave select low
2971
+ void (*end)(void *); // SPI end: slave select high
2972
+ void (*txn)(void *, uint8_t *, uint8_t *,
2973
+ size_t len); // SPI transaction: write-read len bytes
2974
+ };
2975
+
2976
+ struct mg_tcpip_driver_cyw_firmware {
2977
+ const uint8_t * code_addr;
2978
+ size_t code_len;
2979
+ const uint8_t * nvram_addr;
2980
+ size_t nvram_len;
2981
+ const uint8_t * clm_addr;
2982
+ size_t clm_len;
2983
+ };
2984
+
2985
+ struct mg_tcpip_driver_cyw_data {
2986
+ struct mg_tcpip_spi_ *spi;
2987
+ struct mg_tcpip_driver_cyw_firmware *fw;
2988
+ char *ssid;
2989
+ char *pass;
2990
+ char *apssid;
2991
+ char *appass;
2992
+ uint8_t security; // TBD
2993
+ uint8_t apsecurity; // TBD
2994
+ uint8_t apchannel;
2995
+ bool apmode; // start in AP mode; 'false' starts connection to 'ssid' if not NULL
2996
+ };
2997
+
2998
+ // #define MG_TCPIP_DRIVER_INIT(mgr) \
2999
+ // do { \
3000
+ // static struct mg_tcpip_driver_cyw_data driver_data_; \
3001
+ // static struct mg_tcpip_if mif_; \
3002
+ // MG_SET_WIFI_CONFIG(&driver_data_); \
3003
+ // mif_.ip = MG_TCPIP_IP; \
3004
+ // mif_.mask = MG_TCPIP_MASK; \
3005
+ // mif_.gw = MG_TCPIP_GW; \
3006
+ // mif_.driver = &mg_tcpip_driver_pico_w; \
3007
+ // mif_.driver_data = &driver_data_; \
3008
+ // mif_.recv_queue.size = 8192; \
3009
+ // mif_.mac[0] = 2; /* MAC read from OTP at driver init */ \
3010
+ // mg_tcpip_init(mgr, &mif_); \
3011
+ // MG_INFO(("Driver: cyw, MAC: %M", mg_print_mac, mif_.mac)); \
3012
+ // } while (0)
3013
+
3014
+ #endif
3015
+
3016
+
2964
3017
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_IMXRT) && MG_ENABLE_DRIVER_IMXRT
2965
3018
2966
3019
struct mg_tcpip_driver_imxrt_data {
0 commit comments