Skip to content

Commit e8fc817

Browse files
authored
Merge pull request #3295 from cesanta/mcxe247
Add NXP MCXE driver support
2 parents 3273c20 + e621ade commit e8fc817

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

mongoose.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22123,7 +22123,8 @@ bool mg_wifi_ap_stop(void) {
2212322123

2212422124
#if MG_ENABLE_TCPIP && \
2212522125
(defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10) || \
22126-
(defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11)
22126+
(defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11) || \
22127+
(defined(MG_ENABLE_DRIVER_MCXE) && MG_ENABLE_DRIVER_MCXE)
2212722128
struct imxrt_enet {
2212822129
volatile uint32_t RESERVED0, EIR, EIMR, RESERVED1, RDAR, TDAR, RESERVED2[3],
2212922130
ECR, RESERVED3[6], MMFR, MSCR, RESERVED4[7], MIBC, RESERVED5[7], RCR,
@@ -22152,9 +22153,12 @@ struct imxrt_enet {
2215222153
#if defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11
2215322154
#define ENET ((struct imxrt_enet *) (uintptr_t) 0x40424000U)
2215422155
#define ETH_DESC_CNT 5 // Descriptors count
22155-
#else
22156+
#elif defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10
2215622157
#define ENET ((struct imxrt_enet *) (uintptr_t) 0x402D8000U)
2215722158
#define ETH_DESC_CNT 4 // Descriptors count
22159+
#else // MG_ENABLE_DRIVER_MCXE
22160+
#define ENET ((struct imxrt_enet *) (uintptr_t) 0x40079000U)
22161+
#define ETH_DESC_CNT 4 // Descriptor count
2215822162
#endif
2215922163

2216022164
#define ETH_PKT_SIZE 1536 // Max frame size, 64-bit aligned
@@ -22310,9 +22314,14 @@ static bool mg_tcpip_driver_imxrt_poll(struct mg_tcpip_if *ifp, bool s1) {
2231022314
return up;
2231122315
}
2231222316

22313-
void ENET_IRQHandler(void);
2231422317
static uint32_t s_rxno;
22318+
#if !defined(MG_ENABLE_DRIVER_MCXE)
22319+
void ENET_IRQHandler(void);
2231522320
void ENET_IRQHandler(void) {
22321+
#else
22322+
void ENET_Receive_IRQHandler(void);
22323+
void ENET_Receive_IRQHandler(void) {
22324+
#endif
2231622325
ENET->EIR = MG_BIT(25); // Ack IRQ
2231722326
// Frame received, loop
2231822327
for (uint32_t i = 0; i < 10; i++) { // read as they arrive but not forever

mongoose.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3234,7 +3234,8 @@ struct mg_tcpip_driver_cyw_data {
32343234

32353235
#if MG_ENABLE_TCPIP && \
32363236
(defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10) || \
3237-
(defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11)
3237+
(defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11) || \
3238+
(defined(MG_ENABLE_DRIVER_MCXE) && MG_ENABLE_DRIVER_MCXE)
32383239

32393240
struct mg_tcpip_driver_imxrt_data {
32403241
// MDC clock divider. MDC clock is derived from IPS Bus clock (ipg_clk),

src/drivers/imxrt.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
#if MG_ENABLE_TCPIP && \
44
(defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10) || \
5-
(defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11)
5+
(defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11) || \
6+
(defined(MG_ENABLE_DRIVER_MCXE) && MG_ENABLE_DRIVER_MCXE)
67
struct imxrt_enet {
78
volatile uint32_t RESERVED0, EIR, EIMR, RESERVED1, RDAR, TDAR, RESERVED2[3],
89
ECR, RESERVED3[6], MMFR, MSCR, RESERVED4[7], MIBC, RESERVED5[7], RCR,
@@ -31,9 +32,12 @@ struct imxrt_enet {
3132
#if defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11
3233
#define ENET ((struct imxrt_enet *) (uintptr_t) 0x40424000U)
3334
#define ETH_DESC_CNT 5 // Descriptors count
34-
#else
35+
#elif defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10
3536
#define ENET ((struct imxrt_enet *) (uintptr_t) 0x402D8000U)
3637
#define ETH_DESC_CNT 4 // Descriptors count
38+
#else // MG_ENABLE_DRIVER_MCXE
39+
#define ENET ((struct imxrt_enet *) (uintptr_t) 0x40079000U)
40+
#define ETH_DESC_CNT 4 // Descriptor count
3741
#endif
3842

3943
#define ETH_PKT_SIZE 1536 // Max frame size, 64-bit aligned
@@ -189,9 +193,14 @@ static bool mg_tcpip_driver_imxrt_poll(struct mg_tcpip_if *ifp, bool s1) {
189193
return up;
190194
}
191195

192-
void ENET_IRQHandler(void);
193196
static uint32_t s_rxno;
197+
#if !defined(MG_ENABLE_DRIVER_MCXE)
198+
void ENET_IRQHandler(void);
194199
void ENET_IRQHandler(void) {
200+
#else
201+
void ENET_Receive_IRQHandler(void);
202+
void ENET_Receive_IRQHandler(void) {
203+
#endif
195204
ENET->EIR = MG_BIT(25); // Ack IRQ
196205
// Frame received, loop
197206
for (uint32_t i = 0; i < 10; i++) { // read as they arrive but not forever

src/drivers/imxrt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
#if MG_ENABLE_TCPIP && \
44
(defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10) || \
5-
(defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11)
5+
(defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11) || \
6+
(defined(MG_ENABLE_DRIVER_MCXE) && MG_ENABLE_DRIVER_MCXE)
67

78
struct mg_tcpip_driver_imxrt_data {
89
// MDC clock divider. MDC clock is derived from IPS Bus clock (ipg_clk),

0 commit comments

Comments
 (0)