diff --git a/ports/mimxrt/eth.c b/ports/mimxrt/eth.c index 08e4dcc09d..288aafb6b3 100644 --- a/ports/mimxrt/eth.c +++ b/ports/mimxrt/eth.c @@ -291,6 +291,7 @@ void eth_init(eth_t *self, int mac_idx, const phy_operations_t *phy_ops, int phy ENET_Init(ENET, &g_handle, &enet_config, &buffConfig[0], hw_addr, CLOCK_GetFreq(kCLOCK_IpgClk)); ENET_SetCallback(&g_handle, eth_irq_handler, (void *)self); + NVIC_SetPriority(ENET_IRQn, IRQ_PRI_PENDSV); ENET_EnableInterrupts(ENET, ENET_RX_INTERRUPT); ENET_ClearInterruptStatus(ENET, ENET_TX_INTERRUPT | ENET_RX_INTERRUPT | ENET_ERR_INTERRUPT); ENET_ActiveRead(ENET); @@ -348,7 +349,7 @@ STATIC err_t eth_netif_output(struct netif *netif, struct pbuf *p) { p = p->next; } status = eth_send_frame_blocking(ENET, &g_handle, tx_frame, length); - } + } return status == kStatus_Success ? ERR_OK : ERR_BUF; } diff --git a/ports/mimxrt/mpconfigport.h b/ports/mimxrt/mpconfigport.h index 4462a18a61..7958874447 100644 --- a/ports/mimxrt/mpconfigport.h +++ b/ports/mimxrt/mpconfigport.h @@ -169,9 +169,11 @@ uint32_t trng_random_u32(void); // For regular code that wants to prevent "background tasks" from running. // These background tasks (LWIP, Bluetooth) run in PENDSV context. // TODO: Check for the settings of the STM32 port in irq.h -#define MICROPY_PY_PENDSV_ENTER uint32_t atomic_state = disable_irq(); -#define MICROPY_PY_PENDSV_REENTER atomic_state = disable_irq(); -#define MICROPY_PY_PENDSV_EXIT enable_irq(atomic_state); +#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) +#define IRQ_PRI_PENDSV NVIC_EncodePriority(NVIC_PRIORITYGROUP_4, 15, 0) +#define MICROPY_PY_PENDSV_ENTER uint32_t atomic_state = raise_irq_pri(IRQ_PRI_PENDSV); +#define MICROPY_PY_PENDSV_REENTER atomic_state = raise_irq_pri(IRQ_PRI_PENDSV); +#define MICROPY_PY_PENDSV_EXIT restore_irq_pri(atomic_state); // Use VfsLfs2's types for fileio/textio #define mp_type_fileio mp_type_vfs_lfs2_fileio