@@ -24272,9 +24272,10 @@ struct mg_tcpip_driver mg_tcpip_driver_stm32f = {
24272
24272
#endif
24273
24273
24274
24274
24275
- #if MG_ENABLE_TCPIP && (MG_ENABLE_DRIVER_STM32H || MG_ENABLE_DRIVER_MCXN)
24275
+ #if MG_ENABLE_TCPIP && (MG_ENABLE_DRIVER_STM32H || MG_ENABLE_DRIVER_MCXN || \
24276
+ MG_ENABLE_DRIVER_STM32N)
24276
24277
// STM32H: vendor modded single-queue Synopsys v4.2
24277
- // MCXNx4x: dual-queue Synopsys v5.2 with no hash table option
24278
+ // STM32N, MCXNx4x: dual-queue Synopsys v5.2 with no hash table option
24278
24279
// RT1170 ENET_QOS: quad-queue Synopsys v5.1
24279
24280
struct synopsys_enet_qos {
24280
24281
volatile uint32_t MACCR, MACECR, MACPFR, MACWTR, MACHT0R, MACHT1R,
@@ -24313,17 +24314,20 @@ struct synopsys_enet_qos {
24313
24314
0x8000UL))
24314
24315
#elif MG_ENABLE_DRIVER_MCXN
24315
24316
#define ETH ((struct synopsys_enet_qos *) (uintptr_t) 0x40100000UL)
24317
+ #elif MG_ENABLE_DRIVER_STM32N
24318
+ #define ETH ((struct synopsys_enet_qos *) (uintptr_t) 0x48036000UL)
24316
24319
#endif
24317
24320
24318
24321
#define ETH_PKT_SIZE 1540 // Max frame size
24319
24322
#define ETH_DESC_CNT 4 // Descriptors count
24320
24323
#define ETH_DS 4 // Descriptor size (words)
24321
24324
24322
- static volatile uint32_t s_rxdesc[ETH_DESC_CNT][ETH_DS]; // RX descriptors
24323
- static volatile uint32_t s_txdesc[ETH_DESC_CNT][ETH_DS]; // TX descriptors
24324
- static uint8_t s_rxbuf[ETH_DESC_CNT][ETH_PKT_SIZE]; // RX ethernet buffers
24325
- static uint8_t s_txbuf[ETH_DESC_CNT][ETH_PKT_SIZE]; // TX ethernet buffers
24326
- static struct mg_tcpip_if *s_ifp; // MIP interface
24325
+ #define MG_8BYTE_ALIGNED __attribute__((aligned(8)))
24326
+ static volatile uint32_t s_rxdesc[ETH_DESC_CNT][ETH_DS] MG_8BYTE_ALIGNED;
24327
+ static volatile uint32_t s_txdesc[ETH_DESC_CNT][ETH_DS] MG_8BYTE_ALIGNED;
24328
+ static uint8_t s_rxbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_8BYTE_ALIGNED;
24329
+ static uint8_t s_txbuf[ETH_DESC_CNT][ETH_PKT_SIZE] MG_8BYTE_ALIGNED;
24330
+ static struct mg_tcpip_if *s_ifp; // MIP interface
24327
24331
24328
24332
static uint16_t eth_read_phy(uint8_t addr, uint8_t reg) {
24329
24333
ETH->MACMDIOAR &= (0xF << 8);
@@ -24374,7 +24378,7 @@ static bool mg_tcpip_driver_stm32h_init(struct mg_tcpip_if *ifp) {
24374
24378
ETH->DMASBMR |= MG_BIT(12); // AAL NOTE(scaprile): is this actually needed
24375
24379
ETH->MACIER = 0; // Do not enable additional irq sources (reset value)
24376
24380
ETH->MACTFCR = MG_BIT(7); // Disable zero-quanta pause
24377
- #if !MG_ENABLE_DRIVER_MCXN
24381
+ #if MG_ENABLE_DRIVER_STM32H
24378
24382
ETH->MACPFR = MG_BIT(10); // Perfect filtering
24379
24383
#endif
24380
24384
struct mg_phy phy = {eth_read_phy, eth_write_phy};
@@ -24443,7 +24447,7 @@ static size_t mg_tcpip_driver_stm32h_tx(const void *buf, size_t len,
24443
24447
}
24444
24448
24445
24449
static void mg_tcpip_driver_stm32h_update_hash_table(struct mg_tcpip_if *ifp) {
24446
- #if MG_ENABLE_DRIVER_MCXN
24450
+ #if MG_ENABLE_DRIVER_MCXN || MG_ENABLE_DRIVER_STM32N
24447
24451
ETH->MACPFR = MG_BIT(4); // Pass Multicast (pass all multicast frames)
24448
24452
#else
24449
24453
// TODO(): read database, rebuild hash table
@@ -24454,7 +24458,7 @@ static void mg_tcpip_driver_stm32h_update_hash_table(struct mg_tcpip_if *ifp) {
24454
24458
ETH->MACA1HR = (uint32_t) mcast_addr[5] << 8 | (uint32_t) mcast_addr[4];
24455
24459
ETH->MACA1HR |= MG_BIT(31); // AE
24456
24460
#endif
24457
- (void) ifp;
24461
+ (void) ifp;
24458
24462
}
24459
24463
24460
24464
static bool mg_tcpip_driver_stm32h_poll(struct mg_tcpip_if *ifp, bool s1) {
@@ -24488,9 +24492,12 @@ static uint32_t s_rxno;
24488
24492
#if MG_ENABLE_DRIVER_MCXN
24489
24493
void ETHERNET_IRQHandler(void);
24490
24494
void ETHERNET_IRQHandler(void) {
24491
- #else
24495
+ #elif MG_ENABLE_DRIVER_STM32H
24492
24496
void ETH_IRQHandler(void);
24493
24497
void ETH_IRQHandler(void) {
24498
+ #else
24499
+ void ETH1_IRQHandler(void);
24500
+ void ETH1_IRQHandler(void) {
24494
24501
#endif
24495
24502
if (ETH->DMACSR & MG_BIT(6)) { // Frame received, loop
24496
24503
ETH->DMACSR = MG_BIT(15) | MG_BIT(6); // Clear flag
0 commit comments