修复stm32g系列不同芯片串口中断不匹配

This commit is contained in:
mazhiyuan 2021-10-13 15:44:32 +08:00
parent 634e5341a6
commit 3c5ed4b108
1 changed files with 80 additions and 9 deletions

View File

@ -13,6 +13,10 @@
#include <rtthread.h> #include <rtthread.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(BSP_USING_LPUART1) #if defined(BSP_USING_LPUART1)
#ifndef LPUART1_CONFIG #ifndef LPUART1_CONFIG
#define LPUART1_CONFIG \ #define LPUART1_CONFIG \
@ -61,12 +65,21 @@
#if defined(BSP_USING_UART2) #if defined(BSP_USING_UART2)
#ifndef UART2_CONFIG #ifndef UART2_CONFIG
#if defined(STM32G0B1xx) || defined(STM32G0C1xx)
#define UART2_CONFIG \
{ \
.name = "uart2", \
.Instance = USART2, \
.irq_type = USART2_LPUART2_IRQn , \
}
#else
#define UART2_CONFIG \ #define UART2_CONFIG \
{ \ { \
.name = "uart2", \ .name = "uart2", \
.Instance = USART2, \ .Instance = USART2, \
.irq_type = USART2_IRQn, \ .irq_type = USART2_IRQn, \
} }
#endif /* defined(STM32G0B1xx) || defined(STM32G0C1xx) */
#endif /* UART2_CONFIG */ #endif /* UART2_CONFIG */
#endif /* BSP_USING_UART2 */ #endif /* BSP_USING_UART2 */
@ -84,21 +97,42 @@
#if defined(BSP_USING_UART3) #if defined(BSP_USING_UART3)
#ifndef UART3_CONFIG #ifndef UART3_CONFIG
#ifndef SOC_SERIES_STM32G0 #if defined(STM32G0B1xx) || defined(STM32G0C1xx)
#define UART3_CONFIG \ #define UART3_CONFIG \
{ \ { \
.name = "uart3", \ .name = "uart3", \
.Instance = USART3, \ .Instance = USART3, \
.irq_type = USART3_IRQn, \ .irq_type = USART3_4_5_6_LPUART1_IRQn, \
} }
#else #elif defined(STM32G070xx)
#define UART3_CONFIG \
{ \
.name = "uart3", \
.Instance = USART3, \
.irq_type = USART3_4_IRQn, \
}
#elif defined(STM32G071xx) || defined(STM32G081xx)
#define UART3_CONFIG \ #define UART3_CONFIG \
{ \ { \
.name = "uart3", \ .name = "uart3", \
.Instance = USART3, \ .Instance = USART3, \
.irq_type = USART3_4_LPUART1_IRQn, \ .irq_type = USART3_4_LPUART1_IRQn, \
} }
#endif /* SOC_SERIES_STM32G0 */ #elif defined(STM32G0B0xx)
#define UART3_CONFIG \
{ \
.name = "uart3", \
.Instance = USART3, \
.irq_type = USART3_4_5_6_IRQn, \
}
#else
#define UART3_CONFIG \
{ \
.name = "uart3", \
.Instance = USART3, \
.irq_type = USART3_IRQn, \
}
#endif /* defined(STM32G0B1xx) || defined(STM32G0C1xx) */
#endif /* UART3_CONFIG */ #endif /* UART3_CONFIG */
#endif /* BSP_USING_UART3 */ #endif /* BSP_USING_UART3 */
@ -116,22 +150,43 @@
#if defined(BSP_USING_UART4) #if defined(BSP_USING_UART4)
#ifndef UART4_CONFIG #ifndef UART4_CONFIG
#ifndef SOC_SERIES_STM32G0 #if defined(STM32G0B1xx) || defined(STM32G0C1xx)
#define UART4_CONFIG \ #define UART4_CONFIG \
{ \ { \
.name = "uart4", \ .name = "uart4", \
.Instance = UART4, \ .Instance = USART4, \
.irq_type = UART4_IRQn, \ .irq_type = USART3_4_5_6_LPUART1_IRQn, \
} }
#else #elif defined(STM32G070xx)
#define UART4_CONFIG \
{ \
.name = "uart4", \
.Instance = USART4, \
.irq_type = USART3_4_IRQn, \
}
#elif defined(STM32G071xx) || defined(STM32G081xx)
#define UART4_CONFIG \ #define UART4_CONFIG \
{ \ { \
.name = "uart4", \ .name = "uart4", \
.Instance = USART4, \ .Instance = USART4, \
.irq_type = USART3_4_LPUART1_IRQn, \ .irq_type = USART3_4_LPUART1_IRQn, \
} }
#elif defined(STM32G0B0xx)
#define UART4_CONFIG \
{ \
.name = "uart4", \
.Instance = USART4, \
.irq_type = USART3_4_5_6_IRQn, \
}
#else
#define UART4_CONFIG \
{ \
.name = "uart4", \
.Instance = USART4, \
.irq_type = USART4_IRQn, \
}
#endif /* defined(STM32G0B1xx) || defined(STM32G0C1xx) */
#endif /* UART4_CONFIG */ #endif /* UART4_CONFIG */
#endif /* SOC_SERIES_STM32G0 */
#endif /* BSP_USING_UART4 */ #endif /* BSP_USING_UART4 */
#if defined(BSP_UART4_RX_USING_DMA) #if defined(BSP_UART4_RX_USING_DMA)
@ -148,12 +203,28 @@
#if defined(BSP_USING_UART5) #if defined(BSP_USING_UART5)
#ifndef UART5_CONFIG #ifndef UART5_CONFIG
#if defined(STM32G0B1xx) || defined(STM32G0C1xx)
#define UART5_CONFIG \
{ \
.name = "uart5", \
.Instance = UART5, \
.irq_type = USART3_4_5_6_LPUART1_IRQn, \
}
#elif defined(STM32G0B0xx)
#define UART5_CONFIG \
{ \
.name = "uart5", \
.Instance = UART5, \
.irq_type = USART3_4_5_6_IRQn, \
}
#else
#define UART5_CONFIG \ #define UART5_CONFIG \
{ \ { \
.name = "uart5", \ .name = "uart5", \
.Instance = UART5, \ .Instance = UART5, \
.irq_type = UART5_IRQn, \ .irq_type = UART5_IRQn, \
} }
#endif /* defined(STM32G0B1xx) || defined(STM32G0C1xx) */
#endif /* UART5_CONFIG */ #endif /* UART5_CONFIG */
#endif /* BSP_USING_UART5 */ #endif /* BSP_USING_UART5 */