Skip to content

Commit

Permalink
Support AT32F403A remap
Browse files Browse the repository at this point in the history
  • Loading branch information
rhgndf committed Oct 24, 2024
1 parent c176b33 commit 27c31ad
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
9 changes: 8 additions & 1 deletion hw/bsp/at32f403a_407/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ void USBFS_L_CAN1_RX0_IRQHandler(void) {
tud_int_handler(0);
}

void USBFSWakeUp_IRQHandler(void) {
void USBFS_MAPH_IRQHandler(void) {
tud_int_handler(0);
}

void USBFS_MAPL_IRQHandler(void) {
tud_int_handler(0);
}

void USBFSWakeUp_IRQHandler(void) {
tud_int_handler(0);
}

/**
* @brief usb 48M clock select
Expand Down
32 changes: 28 additions & 4 deletions src/portable/st/stm32_fsdev/fsdev_at32.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,39 @@ enum { FSDEV_IRQ_NUM = TU_ARRAY_SIZE(fsdev_irq) };

void dcd_int_enable(uint8_t rhport) {
(void)rhport;
for(uint8_t i=0; i < FSDEV_IRQ_NUM; i++) {
NVIC_EnableIRQ(fsdev_irq[i]);
#if CFG_TUSB_MCU == OPT_MCU_AT32F403A_407
// AT32F403A/407 devices allow to remap the USB interrupt vectors from
// shared USB/CAN IRQs to separate CAN and USB IRQs.
// This dynamically checks if this remap is active to enable the right IRQs.
if (CRM->intmap_bit.usbintmap) {
NVIC_DisableIRQ(USBFS_MAPH_IRQn);
NVIC_DisableIRQ(USBFS_MAPL_IRQn);
NVIC_DisableIRQ(USBFSWakeUp_IRQn);
} else
#endif
{
for(uint8_t i=0; i < FSDEV_IRQ_NUM; i++) {
NVIC_EnableIRQ(fsdev_irq[i]);
}
}
}

void dcd_int_disable(uint8_t rhport) {
(void)rhport;
for(uint8_t i=0; i < FSDEV_IRQ_NUM; i++) {
NVIC_DisableIRQ(fsdev_irq[i]);
#if CFG_TUSB_MCU == OPT_MCU_AT32F403A_407
// AT32F403A/407 devices allow to remap the USB interrupt vectors from
// shared USB/CAN IRQs to separate CAN and USB IRQs.
// This dynamically checks if this remap is active to enable the right IRQs.
if (CRM->intmap_bit.usbintmap) {
NVIC_DisableIRQ(USBFS_MAPH_IRQn);
NVIC_DisableIRQ(USBFS_MAPL_IRQn);
NVIC_DisableIRQ(USBFSWakeUp_IRQn);
} else
#endif
{
for(uint8_t i=0; i < FSDEV_IRQ_NUM; i++) {
NVIC_DisableIRQ(fsdev_irq[i]);
}
}
}

Expand Down

0 comments on commit 27c31ad

Please sign in to comment.