@@ -24230,9 +24230,10 @@ struct mg_tcpip_driver mg_tcpip_driver_stm32f = {
24230
24230
#endif
24231
24231
24232
24232
24233
- #if MG_ENABLE_TCPIP && (MG_ENABLE_DRIVER_STM32H || MG_ENABLE_DRIVER_MCXN)
24233
+ #if MG_ENABLE_TCPIP && (MG_ENABLE_DRIVER_STM32H || MG_ENABLE_DRIVER_MCXN || \
24234
+ MG_ENABLE_DRIVER_STM32N)
24234
24235
// STM32H: vendor modded single-queue Synopsys v4.2
24235
- // MCXNx4x: dual-queue Synopsys v5.2 with no hash table option
24236
+ // STM32N, MCXNx4x: dual-queue Synopsys v5.2 with no hash table option
24236
24237
// RT1170 ENET_QOS: quad-queue Synopsys v5.1
24237
24238
struct synopsys_enet_qos {
24238
24239
volatile uint32_t MACCR, MACECR, MACPFR, MACWTR, MACHT0R, MACHT1R,
@@ -24271,17 +24272,20 @@ struct synopsys_enet_qos {
24271
24272
0x8000UL))
24272
24273
#elif MG_ENABLE_DRIVER_MCXN
24273
24274
#define ETH ((struct synopsys_enet_qos *) (uintptr_t) 0x40100000UL)
24275
+ #elif MG_ENABLE_DRIVER_STM32N
24276
+ #define ETH ((struct synopsys_enet_qos *) (uintptr_t) 0x48036000UL)
24274
24277
#endif
24275
24278
24276
24279
#define ETH_PKT_SIZE 1540 // Max frame size
24277
24280
#define ETH_DESC_CNT 4 // Descriptors count
24278
24281
#define ETH_DS 4 // Descriptor size (words)
24279
24282
24280
- static volatile uint32_t s_rxdesc[ETH_DESC_CNT][ETH_DS]; // RX descriptors
24281
- static volatile uint32_t s_txdesc[ETH_DESC_CNT][ETH_DS]; // TX descriptors
24282
- static uint8_t s_rxbuf[ETH_DESC_CNT][ETH_PKT_SIZE]; // RX ethernet buffers
24283
- static uint8_t s_txbuf[ETH_DESC_CNT][ETH_PKT_SIZE]; // TX ethernet buffers
24284
- static struct mg_tcpip_if *s_ifp; // MIP interface
24283
+ #define MG_8BYTE_ALIGNED __attribute__((aligned(8)))
24284
+ static volatile uint32_t s_rxdesc[ETH_DESC_CNT][ETH_DS] MG_8BYTE_ALIGNED;
24285
+ static volatile uint32_t s_txdesc[ETH_DESC_CNT][ETH_DS] MG_8BYTE_ALIGNED;
24286
+ static uint8_t s_rxbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_8BYTE_ALIGNED;
24287
+ static uint8_t s_txbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_8BYTE_ALIGNED;
24288
+ static struct mg_tcpip_if *s_ifp; // MIP interface
24285
24289
24286
24290
static uint16_t eth_read_phy(uint8_t addr, uint8_t reg) {
24287
24291
ETH->MACMDIOAR &= (0xF << 8);
@@ -24332,7 +24336,7 @@ static bool mg_tcpip_driver_stm32h_init(struct mg_tcpip_if *ifp) {
24332
24336
ETH->DMASBMR |= MG_BIT(12); // AAL NOTE(scaprile): is this actually needed
24333
24337
ETH->MACIER = 0; // Do not enable additional irq sources (reset value)
24334
24338
ETH->MACTFCR = MG_BIT(7); // Disable zero-quanta pause
24335
- #if !MG_ENABLE_DRIVER_MCXN
24339
+ #if MG_ENABLE_DRIVER_STM32H
24336
24340
ETH->MACPFR = MG_BIT(10); // Perfect filtering
24337
24341
#endif
24338
24342
struct mg_phy phy = {eth_read_phy, eth_write_phy};
@@ -24401,7 +24405,7 @@ static size_t mg_tcpip_driver_stm32h_tx(const void *buf, size_t len,
24401
24405
}
24402
24406
24403
24407
static void mg_tcpip_driver_stm32h_update_hash_table(struct mg_tcpip_if *ifp) {
24404
- #if MG_ENABLE_DRIVER_MCXN
24408
+ #if MG_ENABLE_DRIVER_MCXN || MG_ENABLE_DRIVER_STM32N
24405
24409
ETH->MACPFR = MG_BIT(4); // Pass Multicast (pass all multicast frames)
24406
24410
#else
24407
24411
// TODO(): read database, rebuild hash table
@@ -24412,7 +24416,7 @@ static void mg_tcpip_driver_stm32h_update_hash_table(struct mg_tcpip_if *ifp) {
24412
24416
ETH->MACA1HR = (uint32_t) mcast_addr[5] << 8 | (uint32_t) mcast_addr[4];
24413
24417
ETH->MACA1HR |= MG_BIT(31); // AE
24414
24418
#endif
24415
- (void) ifp;
24419
+ (void) ifp;
24416
24420
}
24417
24421
24418
24422
static bool mg_tcpip_driver_stm32h_poll(struct mg_tcpip_if *ifp, bool s1) {
@@ -24446,9 +24450,12 @@ static uint32_t s_rxno;
24446
24450
#if MG_ENABLE_DRIVER_MCXN
24447
24451
void ETHERNET_IRQHandler(void);
24448
24452
void ETHERNET_IRQHandler(void) {
24449
- #else
24453
+ #elif MG_ENABLE_DRIVER_STM32H
24450
24454
void ETH_IRQHandler(void);
24451
24455
void ETH_IRQHandler(void) {
24456
+ #else
24457
+ void ETH1_IRQHandler(void);
24458
+ void ETH1_IRQHandler(void) {
24452
24459
#endif
24453
24460
if (ETH->DMACSR & MG_BIT(6)) { // Frame received, loop
24454
24461
ETH->DMACSR = MG_BIT(15) | MG_BIT(6); // Clear flag
0 commit comments