Skip to content

Commit 03e9e55

Browse files
committed
Add CYW driver
1 parent 96754a8 commit 03e9e55

File tree

8 files changed

+2496
-2
lines changed

8 files changed

+2496
-2
lines changed

mongoose.c

Lines changed: 1197 additions & 1 deletion
Large diffs are not rendered by default.

mongoose.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,7 @@ char *mg_random_str(char *buf, size_t len);
11071107
uint32_t mg_crc32(uint32_t crc, const char *buf, size_t len);
11081108
uint64_t mg_millis(void); // Return milliseconds since boot
11091109
bool mg_path_is_sane(const struct mg_str path);
1110+
void mg_delayms(unsigned int ms);
11101111

11111112
#define MG_U32(a, b, c, d) \
11121113
(((uint32_t) ((a) &255) << 24) | ((uint32_t) ((b) &255) << 16) | \
@@ -2869,6 +2870,7 @@ extern struct mg_tcpip_driver mg_tcpip_driver_xmc7;
28692870
extern struct mg_tcpip_driver mg_tcpip_driver_ppp;
28702871
extern struct mg_tcpip_driver mg_tcpip_driver_pico_w;
28712872
extern struct mg_tcpip_driver mg_tcpip_driver_rw612;
2873+
extern struct mg_tcpip_driver mg_tcpip_driver_cyw;
28722874

28732875
// Drivers that require SPI, can use this SPI abstraction
28742876
struct mg_tcpip_spi {
@@ -2961,6 +2963,57 @@ struct mg_profitem {
29612963
#endif
29622964

29632965

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+
29643017
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_IMXRT) && MG_ENABLE_DRIVER_IMXRT
29653018

29663019
struct mg_tcpip_driver_imxrt_data {

0 commit comments

Comments
 (0)