From 41ab3f75358059f34a4f7df57dc0b2509082ad3a Mon Sep 17 00:00:00 2001 From: sheltonyu Date: Fri, 17 Nov 2023 17:02:18 +0800 Subject: [PATCH] fixed usb/usart drivers --- .../rt_drivers/config/f402_405/dma_config.h | 4 ++-- .../rt_drivers/config/f402_405/uart_config.h | 12 ++++++------ bsp/at32/libraries/rt_drivers/drv_usart_v2.c | 4 +++- bsp/at32/libraries/rt_drivers/drv_usbotgh.c | 2 +- bsp/at32/libraries/usbotg_library/inc/usb_core.h | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bsp/at32/libraries/rt_drivers/config/f402_405/dma_config.h b/bsp/at32/libraries/rt_drivers/config/f402_405/dma_config.h index be8118cf93..1dcb38d41f 100644 --- a/bsp/at32/libraries/rt_drivers/config/f402_405/dma_config.h +++ b/bsp/at32/libraries/rt_drivers/config/f402_405/dma_config.h @@ -186,7 +186,7 @@ extern "C" { #define UART7_RX_DMA_CHANNEL DMA2_CHANNEL6 #define UART7_RX_DMA_IRQ DMA2_Channel6_IRQn #define UART7_RX_DMA_MUX_CHANNEL DMA2MUX_CHANNEL6 -#define UART7_RX_DMA_REQ_ID DMAMUX_DMAREQ_ID_USART7_RX +#define UART7_RX_DMA_REQ_ID DMAMUX_DMAREQ_ID_UART7_RX #endif /* DMA2 channel7 */ @@ -196,7 +196,7 @@ extern "C" { #define UART7_TX_DMA_CHANNEL DMA2_CHANNEL7 #define UART7_TX_DMA_IRQ DMA2_Channel7_IRQn #define UART7_TX_DMA_MUX_CHANNEL DMA2MUX_CHANNEL7 -#define UART7_TX_DMA_REQ_ID DMAMUX_DMAREQ_ID_USART7_TX +#define UART7_TX_DMA_REQ_ID DMAMUX_DMAREQ_ID_UART7_TX #endif #ifdef __cplusplus diff --git a/bsp/at32/libraries/rt_drivers/config/f402_405/uart_config.h b/bsp/at32/libraries/rt_drivers/config/f402_405/uart_config.h index 9cee3d0572..8eda9a3ab8 100644 --- a/bsp/at32/libraries/rt_drivers/config/f402_405/uart_config.h +++ b/bsp/at32/libraries/rt_drivers/config/f402_405/uart_config.h @@ -24,8 +24,8 @@ extern "C" { #define UART4_IRQHandler USART4_IRQHandler #define UART5_IRQHandler USART5_IRQHandler #define UART6_IRQHandler USART6_IRQHandler -#define UART7_IRQHandler USART7_IRQHandler -#define UART8_IRQHandler USART8_IRQHandler +#define UART7_IRQHandler UART7_IRQHandler +#define UART8_IRQHandler UART8_IRQHandler #if defined(BSP_USING_UART1) #define UART1_CONFIG \ @@ -217,8 +217,8 @@ extern "C" { #define UART7_CONFIG \ { \ .name = "uart7", \ - .uart_x = USART7, \ - .irqn = USART7_IRQn, \ + .uart_x = UART7, \ + .irqn = UART7_IRQn, \ } #if defined(BSP_UART7_RX_USING_DMA) @@ -248,8 +248,8 @@ extern "C" { #define UART8_CONFIG \ { \ .name = "uart8", \ - .uart_x = USART8, \ - .irqn = USART8_IRQn, \ + .uart_x = UART8, \ + .irqn = UART8_IRQn, \ } #endif /* BSP_USING_UART8 */ diff --git a/bsp/at32/libraries/rt_drivers/drv_usart_v2.c b/bsp/at32/libraries/rt_drivers/drv_usart_v2.c index 98ec19f502..ed6523e489 100644 --- a/bsp/at32/libraries/rt_drivers/drv_usart_v2.c +++ b/bsp/at32/libraries/rt_drivers/drv_usart_v2.c @@ -7,6 +7,7 @@ * Date Author Notes * 2023-02-23 Jonas first version * 2023-04-16 shelton update for perfection of drv_usart_v2 + * 2023-11-16 shelton add support at32f402/405 series */ #include "drv_common.h" @@ -365,7 +366,8 @@ static void at32_dma_config(struct rt_serial_device *serial, rt_ubase_t flag) (dma_flexible_request_type)dma_config->request_id); #endif #if defined (SOC_SERIES_AT32F435) || defined (SOC_SERIES_AT32F437) || \ - defined (SOC_SERIES_AT32F423) + defined (SOC_SERIES_AT32F423) || defined (SOC_SERIES_AT32F402) || \ + defined (SOC_SERIES_AT32F405) dmamux_enable(dma_config->dma_x, TRUE); dmamux_init(dma_config->dmamux_channel, (dmamux_requst_id_sel_type)dma_config->request_id); #endif diff --git a/bsp/at32/libraries/rt_drivers/drv_usbotgh.c b/bsp/at32/libraries/rt_drivers/drv_usbotgh.c index 6fb3cbad25..5460fa3fbc 100644 --- a/bsp/at32/libraries/rt_drivers/drv_usbotgh.c +++ b/bsp/at32/libraries/rt_drivers/drv_usbotgh.c @@ -350,7 +350,7 @@ static rt_err_t at32_hcd_init(rt_device_t device) /* init usb */ usbh_init(p_usbotg_instance->p_otg_core, - USB_FULL_SPEED_CORE_ID, + p_usbotg_instance->dev_spd, p_usbotg_instance->id); return RT_EOK; } diff --git a/bsp/at32/libraries/usbotg_library/inc/usb_core.h b/bsp/at32/libraries/usbotg_library/inc/usb_core.h index de67131fde..ae62408cae 100644 --- a/bsp/at32/libraries/usbotg_library/inc/usb_core.h +++ b/bsp/at32/libraries/usbotg_library/inc/usb_core.h @@ -52,9 +52,9 @@ extern "C" { */ typedef enum { - USB_LOW_SPEED_CORE_ID, /*!< usb low speed core id */ + USB_HIGH_SPEED_CORE_ID, /*!< usb low speed core id */ USB_FULL_SPEED_CORE_ID, /*!< usb full speed core id */ - USB_HIGH_SPEED_CORE_ID, /*!< usb high speed core id */ + USB_LOW_SPEED_CORE_ID /*!< usb high speed core id */ } usb_speed_type; /**