modified the bsp files of at32 to make them work better

This commit is contained in:
zhiqiang
2025-09-04 14:38:27 +08:00
parent 93487deab7
commit f6ca80ab13
27 changed files with 384 additions and 293 deletions

View File

@@ -60,124 +60,11 @@
#define PRINT_UART_TX_PIN_SOURCE GPIO_PINS_SOURCE9
#define PRINT_UART_TX_PIN_MUX_NUM GPIO_MUX_7
// USB
#ifdef BOARD_TUD_RHPORT
#if BOARD_TUD_RHPORT == 0
#define USB_ID 0
#define OTG_CLOCK CRM_OTGFS1_PERIPH_CLOCK
#define OTG_IRQ OTGFS1_IRQn
#define OTG_IRQ_HANDLER OTGFS1_IRQHandler
#define OTG_WKUP_IRQ OTGFS1_WKUP_IRQn
#define OTG_WKUP_HANDLER OTGFS1_WKUP_IRQHandler
#define OTG_WKUP_EXINT_LINE EXINT_LINE_18
#define OTG_PIN_GPIO GPIOA
#define OTG_PIN_GPIO_CLOCK CRM_GPIOA_PERIPH_CLOCK
#define OTG_PIN_DP GPIO_PINS_12
#define OTG_PIN_DP_SOURCE GPIO_PINS_SOURCE12
#define OTG_PIN_DM GPIO_PINS_11
#define OTG_PIN_DM_SOURCE GPIO_PINS_SOURCE11
#define OTG_PIN_VBUS GPIO_PINS_9
#define OTG_PIN_VBUS_SOURCE GPIO_PINS_SOURCE9
#define OTG_PIN_ID GPIO_PINS_10
#define OTG_PIN_ID_SOURCE GPIO_PINS_SOURCE12
#define OTG_PIN_SOF_GPIO GPIOA
#define OTG_PIN_SOF_GPIO_CLOCK CRM_GPIOA_PERIPH_CLOCK
#define OTG_PIN_SOF GPIO_PINS_8
#define OTG_PIN_SOF_SOURCE GPIO_PINS_SOURCE8
#define OTG_PIN_MUX GPIO_MUX_10
#elif BOARD_TUD_RHPORT == 1
#define USB_ID 1
#define OTG_CLOCK CRM_OTGFS2_PERIPH_CLOCK
#define OTG_IRQ OTGFS2_IRQn
#define OTG_IRQ_HANDLER OTGFS2_IRQHandler
#define OTG_WKUP_IRQ OTGFS2_WKUP_IRQn
#define OTG_WKUP_HANDLER OTGFS2_WKUP_IRQHandler
#define OTG_WKUP_EXINT_LINE EXINT_LINE_20
#define OTG_PIN_GPIO GPIOB
#define OTG_PIN_GPIO_CLOCK CRM_GPIOB_PERIPH_CLOCK
#define OTG_PIN_DP GPIO_PINS_15
#define OTG_PIN_DP_SOURCE GPIO_PINS_SOURCE15
#define OTG_PIN_DM GPIO_PINS_14
#define OTG_PIN_DM_SOURCE GPIO_PINS_SOURCE14
#define OTG_PIN_VBUS GPIO_PINS_13
#define OTG_PIN_VBUS_SOURCE GPIO_PINS_SOURCE13
#define OTG_PIN_ID GPIO_PINS_12
#define OTG_PIN_ID_SOURCE GPIO_PINS_SOURCE10
#define OTG_PIN_SOF_GPIO GPIOA
#define OTG_PIN_SOF_GPIO_CLOCK CRM_GPIOA_PERIPH_CLOCK
#define OTG_PIN_SOF GPIO_PINS_4
#define OTG_PIN_SOF_SOURCE GPIO_PINS_SOURCE4
#define OTG_PIN_MUX GPIO_MUX_12
#endif
#endif
#ifdef BOARD_TUH_RHPORT
#if BOARD_TUH_RHPORT == 0
#define USB_ID 0
#define OTG_CLOCK CRM_OTGFS1_PERIPH_CLOCK
#define OTG_IRQ OTGFS1_IRQn
#define OTG_IRQ_HANDLER OTGFS1_IRQHandler
#define OTG_WKUP_IRQ OTGFS1_WKUP_IRQn
#define OTG_WKUP_HANDLER OTGFS1_WKUP_IRQHandler
#define OTG_WKUP_EXINT_LINE EXINT_LINE_18
#define OTG_PIN_GPIO GPIOA
#define OTG_PIN_GPIO_CLOCK CRM_GPIOA_PERIPH_CLOCK
#define OTG_PIN_DP GPIO_PINS_12
#define OTG_PIN_DP_SOURCE GPIO_PINS_SOURCE12
#define OTG_PIN_DM GPIO_PINS_11
#define OTG_PIN_DM_SOURCE GPIO_PINS_SOURCE11
#define OTG_PIN_VBUS GPIO_PINS_9
#define OTG_PIN_VBUS_SOURCE GPIO_PINS_SOURCE9
#define OTG_PIN_ID GPIO_PINS_10
#define OTG_PIN_ID_SOURCE GPIO_PINS_SOURCE12
#define OTG_PIN_SOF_GPIO GPIOA
#define OTG_PIN_SOF_GPIO_CLOCK CRM_GPIOA_PERIPH_CLOCK
#define OTG_PIN_SOF GPIO_PINS_8
#define OTG_PIN_SOF_SOURCE GPIO_PINS_SOURCE8
#define OTG_PIN_MUX GPIO_MUX_10
#elif BOARD_TUH_RHPORT == 1
#define USB_ID 1
#define OTG_CLOCK CRM_OTGFS2_PERIPH_CLOCK
#define OTG_IRQ OTGFS2_IRQn
#define OTG_IRQ_HANDLER OTGFS2_IRQHandler
#define OTG_WKUP_IRQ OTGFS2_WKUP_IRQn
#define OTG_WKUP_HANDLER OTGFS2_WKUP_IRQHandler
#define OTG_WKUP_EXINT_LINE EXINT_LINE_20
#define OTG_PIN_GPIO GPIOB
#define OTG_PIN_GPIO_CLOCK CRM_GPIOB_PERIPH_CLOCK
#define OTG_PIN_DP GPIO_PINS_15
#define OTG_PIN_DP_SOURCE GPIO_PINS_SOURCE15
#define OTG_PIN_DM GPIO_PINS_14
#define OTG_PIN_DM_SOURCE GPIO_PINS_SOURCE14
#define OTG_PIN_VBUS GPIO_PINS_13
#define OTG_PIN_VBUS_SOURCE GPIO_PINS_SOURCE13
#define OTG_PIN_ID GPIO_PINS_12
#define OTG_PIN_ID_SOURCE GPIO_PINS_SOURCE10
#define OTG_PIN_SOF_GPIO GPIOA
#define OTG_PIN_SOF_GPIO_CLOCK CRM_GPIOA_PERIPH_CLOCK
#define OTG_PIN_SOF GPIO_PINS_4
#define OTG_PIN_SOF_SOURCE GPIO_PINS_SOURCE4
#define OTG_PIN_MUX GPIO_MUX_12
#endif
#endif
// VBUS
static inline void board_vbus_sense_init(void)
{
#ifdef BOARD_TUD_RHPORT
#if BOARD_TUD_RHPORT == 0
*(int*)(0x50000038) |= (1<<21);
#elif BOARD_TUD_RHPORT == 1
*(int*)(0x40040038) |= (1<<21);
#endif
#endif
#ifdef BOARD_TUH_RHPORT
#if BOARD_TUH_RHPORT == 0
*(int*)(0x50000038) |= (1<<21);
#elif BOARD_TUH_RHPORT == 1
*(int*)(0x40040038) |= (1<<21);
#endif
#endif
*(int*)(0x50000038) |= (1<<21);
*(int*)(0x40040038) |= (1<<21);
}
#ifdef __cplusplus