694 lines
16 KiB
C
694 lines
16 KiB
C
/**
|
|
* Change Logs:
|
|
* 憓𧼮� __HAL_UART_FLUSH_DRREGISTER
|
|
*/
|
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "bsp_uart.h"
|
|
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
#if (BSP_USING_UART2_RE || BSP_USING_UART3_RE)
|
|
static volatile uint8_t _uart2_alter;
|
|
static volatile uint8_t _uart3_alter;
|
|
#endif
|
|
|
|
static UART_Callback_t _UART_RxCallback;
|
|
static UART_Callback_t _UART_RxIdleCallback;
|
|
static UART_Callback_t _UART_DMA_RxCallback;
|
|
static UART_Callback_t _UART_DMA_TxCallback;
|
|
|
|
#if (BSP_USING_UART1)
|
|
UART_CREATE(1);
|
|
#endif
|
|
|
|
#if (BSP_USING_UART2)
|
|
UART_CREATE(2);
|
|
#endif
|
|
|
|
#if (BSP_USING_UART2_RE)
|
|
UART_CREATE(2_RE);
|
|
#endif
|
|
|
|
#if (BSP_USING_UART3)
|
|
UART_CREATE(3);
|
|
#endif
|
|
|
|
#if (BSP_USING_UART3_RE)
|
|
UART_CREATE(3_RE);
|
|
#endif
|
|
|
|
#if (BSP_USING_UART4)
|
|
UART_CREATE(4);
|
|
#endif
|
|
|
|
#if (BSP_USING_UART5)
|
|
UART_CREATE(5);
|
|
#endif
|
|
|
|
#if (BSP_USING_UART6)
|
|
UART_CREATE(6);
|
|
#endif
|
|
|
|
struct UART_STRUCT *_uart_group[] =
|
|
{
|
|
#if (BSP_USING_UART1)
|
|
&UART(1),
|
|
#endif
|
|
#if (BSP_USING_UART2)
|
|
&UART(2),
|
|
#endif
|
|
#if (BSP_USING_UART2_RE)
|
|
&UART(2_RE),
|
|
#endif
|
|
#if (BSP_USING_UART3)
|
|
&UART(3),
|
|
#endif
|
|
#if (BSP_USING_UART3_RE)
|
|
&UART(3_RE),
|
|
#endif
|
|
#if (BSP_USING_UART4)
|
|
&UART(4),
|
|
#endif
|
|
#if (BSP_USING_UART5)
|
|
&UART(5),
|
|
#endif
|
|
#if (BSP_USING_UART6)
|
|
&UART(6),
|
|
#endif
|
|
};
|
|
|
|
static const uint8_t _uart_qty = sizeof(_uart_group) / sizeof(struct UART_STRUCT *);
|
|
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
static inline void _UART_IntHandler (struct UART_STRUCT *uart);
|
|
static inline void _UART_Alternate (struct UART_STRUCT *uart);
|
|
|
|
|
|
/* Exported functions ---------------------------------------------------------*/
|
|
/**
|
|
* @brief UART �亙藁�嘥��? * @note ���?UART 憭𤥁挽�嘥��硋��𡝗𧋦�賣㺭憭��銵?UART 憭𤥁挽�嘥��硋��滚虾靚�鍂
|
|
* @param[in] uart: UART 撖寡情
|
|
* @param[in] rx_callback: �交𤣰�訫���㺭�桐葉�剔��噼��賣㺭
|
|
* @param[in] rx_idle_callback: 蝛粹𤦭銝剜鱏���靚�遆�? * @param[in] dma_rx_callback: DMA �交𤣰銝剜鱏���靚�遆�? * @param[in] dma_tx_callback: DMA �煾����鞟��噼��賣㺭
|
|
* @retval None
|
|
*/
|
|
void BSP_UART_Port_Init( struct UART_STRUCT *uart,
|
|
UART_Callback_t rx_callback,
|
|
UART_Callback_t rx_idle_callback,
|
|
UART_Callback_t dma_rx_callback,
|
|
UART_Callback_t dma_tx_callback)
|
|
{
|
|
BSP_UART_Port_LockInit(uart);
|
|
|
|
_UART_RxCallback = rx_callback;
|
|
_UART_RxIdleCallback = rx_idle_callback;
|
|
_UART_DMA_RxCallback = dma_rx_callback;
|
|
_UART_DMA_TxCallback = dma_tx_callback;
|
|
|
|
/**
|
|
* 敶?uart->handle ���霈曄眏蝟餌��嘥��𡝗𧒄嚗䔶�憒?CubeMX ������憪见�隞��嚗䔶誑銝贝��潭�雿𨀣糓敹�◆���? * �血�嚗屸�閬�䌊撌勗� uart->handle �嘥��硔�? * �望迨�航�嚗?BSP_UART_Port_Init ���?UART 憭𤥁挽�嘥��硋��𡝗𧋦�賣㺭憭��銵?UART 憭𤥁挽�嘥��硋��滚虾靚�鍂�? */
|
|
switch (uart->id)
|
|
{
|
|
#if (BSP_USING_UART1)
|
|
case BSP_UART1: uart->handle = UART1_HANDLE; break;
|
|
#endif
|
|
#if (BSP_USING_UART2)
|
|
case BSP_UART2: uart->handle = UART2_HANDLE; break;
|
|
#endif
|
|
#if (BSP_USING_UART2_RE)
|
|
case BSP_UART2_RE: uart->handle = UART2_HANDLE; break;
|
|
#endif
|
|
#if (BSP_USING_UART3)
|
|
case BSP_UART3: uart->handle = UART3_HANDLE; break;
|
|
#endif
|
|
#if (BSP_USING_UART3_RE)
|
|
case BSP_UART3_RE: uart->handle = UART3_HANDLE; break;
|
|
#endif
|
|
#if (BSP_USING_UART4)
|
|
case BSP_UART4: uart->handle = UART4_HANDLE; break;
|
|
#endif
|
|
#if (BSP_USING_UART5)
|
|
case BSP_UART5: uart->handle = UART5_HANDLE; break;
|
|
#endif
|
|
#if (BSP_USING_UART6)
|
|
case BSP_UART6: uart->handle = UART6_HANDLE; break;
|
|
#endif
|
|
default: break;
|
|
}
|
|
|
|
if (uart->handle.hdmatx)
|
|
uart->handle.hdmatx->Parent = &uart->handle;
|
|
|
|
/* Clean the input path */
|
|
__HAL_UART_FLUSH_DRREGISTER(&uart->handle);
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief UART �亙藁�帋縑�批�����嘥��? * @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval BSP_UART_ERR
|
|
*/
|
|
BSP_UART_ERR BSP_UART_Port_LockInit(struct UART_STRUCT *uart)
|
|
{
|
|
return BSP_UART_ERR_OK;
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief UART 蝑匧��交𤣰�唳旿��縑�琿�
|
|
* @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval BSP_UART_ERR
|
|
*/
|
|
inline BSP_UART_ERR BSP_UART_Port_RxLock(struct UART_STRUCT *uart)
|
|
{
|
|
return BSP_UART_ERR_OK;
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief UART �交𤣰�唳㺭�桀��箇�靽∪噡�? * @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval BSP_UART_ERR
|
|
*/
|
|
inline BSP_UART_ERR BSP_UART_Port_RxUnlock(struct UART_STRUCT *uart)
|
|
{
|
|
return BSP_UART_ERR_OK;
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief UART �煾���
|
|
* @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval BSP_UART_ERR
|
|
*/
|
|
inline BSP_UART_ERR BSP_UART_Port_TxLock(struct UART_STRUCT *uart)
|
|
{
|
|
return BSP_UART_ERR_OK;
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief UART �煾���瘥閗圾�? * @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval BSP_UART_ERR
|
|
*/
|
|
inline BSP_UART_ERR BSP_UART_Port_TxUnlock(struct UART_STRUCT *uart)
|
|
{
|
|
return BSP_UART_ERR_OK;
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief 雿輯� UART �交𤣰�唳旿
|
|
* @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval BSP_UART_ERR
|
|
*/
|
|
BSP_UART_ERR BSP_UART_Port_EnableReceive(struct UART_STRUCT *uart)
|
|
{
|
|
BSP_UART_ERR ret = BSP_UART_ERR_OK;
|
|
|
|
if (uart->handle.hdmarx)
|
|
uart->handle.hdmarx->Parent = &uart->handle;
|
|
|
|
_UART_Alternate(uart);
|
|
|
|
if (uart->handle.hdmarx)
|
|
ret = (BSP_UART_ERR)HAL_UART_Receive_DMA(&uart->handle, (uint8_t *)uart->rx_buff, uart->rx_buff_max_len);
|
|
else
|
|
__HAL_UART_ENABLE_IT(&uart->handle, UART_IT_RXNE);
|
|
|
|
/* 撘��舐征�脖葉�?*/
|
|
__HAL_UART_ENABLE_IT(&uart->handle, UART_IT_IDLE);
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief 蝳�迫 UART �交𤣰�唳旿
|
|
* @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval BSP_UART_ERR
|
|
*/
|
|
BSP_UART_ERR BSP_UART_Port_DisableReceive(struct UART_STRUCT *uart)
|
|
{
|
|
BSP_UART_ERR ret = BSP_UART_ERR_OK;
|
|
|
|
if (uart->handle.hdmarx)
|
|
ret = (BSP_UART_ERR)HAL_UART_DMAPause(&uart->handle);
|
|
else
|
|
__HAL_UART_DISABLE_IT(&uart->handle, UART_IT_RXNE);
|
|
|
|
__HAL_UART_DISABLE_IT(&uart->handle, UART_IT_IDLE);
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief �批� UART �煾���撣扳㺭�? * @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @param[in] data: 閬������唳旿
|
|
* @param[in] len: 閬������唳旿�踹漲嚗��雿?byte���憭折鵭摨? 65535 byte
|
|
* @param[in] timeout: ��憭批�����嗆𧒄�湛��蓥� ms���憭扳�摰𡁏𧒄�? 65535 ms
|
|
* @retval BSP_UART_ERR
|
|
*/
|
|
BSP_UART_ERR BSP_UART_Port_Send(struct UART_STRUCT *uart, const uint8_t *data, uint16_t len, uint16_t timeout)
|
|
{
|
|
_UART_Alternate(uart);
|
|
|
|
if (timeout == 0)
|
|
{
|
|
if (uart->handle.hdmatx)
|
|
return (BSP_UART_ERR)HAL_UART_Transmit_DMA(&uart->handle, (uint8_t *)data, len);
|
|
else
|
|
return (BSP_UART_ERR)HAL_UART_Transmit_IT(&uart->handle, (uint8_t *)data, len);
|
|
}
|
|
else
|
|
return (BSP_UART_ERR)HAL_UART_Transmit(&uart->handle, (uint8_t *)data, len, timeout);
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* @brief 隞?UART �瑕�銝�銝芸�����唳旿
|
|
* @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval UART �唳旿
|
|
*/
|
|
inline uint32_t BSP_UART_Port_GetOneByte(struct UART_STRUCT *uart)
|
|
{
|
|
return uart->handle.Instance->DR;
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief �瑕� DMA 敶枏���恣�? * @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval 霈⊥㺭�? */
|
|
inline uint32_t BSP_UART_Port_GetDmaCounter(struct UART_STRUCT *uart)
|
|
{
|
|
return __HAL_DMA_GET_COUNTER(uart->handle.hdmarx);
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief �朞� UART ID �瑕� UART 撖寡情
|
|
* @note
|
|
* @param[in] id: 銝脣藁 ID
|
|
* @retval NULL: �䭾��?ID��� NULL: UART 撖寡情
|
|
*/
|
|
struct UART_STRUCT *BSP_UART_Port_GetHandle(BSP_UART_ID id)
|
|
{
|
|
for (uint8_t i = 0; i < _uart_qty; i++)
|
|
{
|
|
if (_uart_group[i]->id == id)
|
|
{
|
|
return _uart_group[i];
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
/* Private functions ---------------------------------------------------------*/
|
|
/**
|
|
* @brief UART 銝剜鱏���銝剖��? * @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval None
|
|
*/
|
|
static inline void _UART_IntHandler(struct UART_STRUCT *uart)
|
|
{
|
|
if (uart->handle.Instance == NULL)
|
|
return;
|
|
|
|
if (__HAL_UART_GET_FLAG(&uart->handle, UART_FLAG_RXNE) != RESET)
|
|
{
|
|
/* RXNE 銝剜鱏���雿滢��刻粉�?DR 撖���函��嗅�蹱��塚�雿��瘜閧&摰?_UART_RxCallback �臬炏隡朞粉�靝R撖���剁�
|
|
��隞亙銁甇文�餈𥡝�銝�甈⊥��?*/
|
|
__HAL_UART_CLEAR_FLAG(&uart->handle, UART_FLAG_RXNE);
|
|
|
|
if (_UART_RxCallback)
|
|
_UART_RxCallback(uart);
|
|
}
|
|
else if ((__HAL_UART_GET_FLAG(&uart->handle, UART_FLAG_IDLE) != RESET)
|
|
&& (__HAL_UART_GET_IT_SOURCE(&uart->handle, UART_IT_IDLE) != RESET))
|
|
{
|
|
/* IDLE 銝剜鱏���雿滚蘨�質蔓隞嗆��?*/
|
|
__HAL_UART_CLEAR_IDLEFLAG(&uart->handle);
|
|
|
|
if (_UART_RxIdleCallback)
|
|
_UART_RxIdleCallback(uart);
|
|
}
|
|
else
|
|
{
|
|
HAL_UART_IRQHandler(&(uart->handle));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief 銝脣藁憭滨鍂��揢�賣㺭
|
|
* @note
|
|
* @param[in] uart: UART 撖寡情
|
|
* @retval None
|
|
*/
|
|
static inline void _UART_Alternate(struct UART_STRUCT *uart)
|
|
{
|
|
#if (BSP_USING_UART2_RE || BSP_USING_UART3_RE)
|
|
switch (uart->id)
|
|
{
|
|
case BSP_UART2:
|
|
case BSP_UART2_RE:
|
|
{
|
|
if (_uart2_alter != uart->id) /* 憭滨鍂��揢 */
|
|
{
|
|
if (uart->id == BSP_UART2)
|
|
{
|
|
BSP_GPIO_SetMode(GET_PIN(A, 2), GPIO_MODE_AF_PP, GPIO_PULLUP); /* TX */
|
|
BSP_GPIO_SetMode(GET_PIN(A, 3), GPIO_MODE_INPUT, GPIO_PULLUP); /* RX */
|
|
__HAL_AFIO_REMAP_USART2_DISABLE();
|
|
}
|
|
else
|
|
{
|
|
BSP_GPIO_SetMode(GET_PIN(D, 5), GPIO_MODE_AF_PP, GPIO_PULLUP); /* TX */
|
|
BSP_GPIO_SetMode(GET_PIN(D, 6), GPIO_MODE_INPUT, GPIO_PULLUP); /* RX */
|
|
__HAL_AFIO_REMAP_USART2_ENABLE();
|
|
}
|
|
_uart2_alter = uart->id;
|
|
}
|
|
break;
|
|
}
|
|
case BSP_UART3:
|
|
case BSP_UART3_RE:
|
|
{
|
|
if (_uart3_alter != uart->id) /* 憭滨鍂��揢 */
|
|
{
|
|
if (uart->id == BSP_UART3)
|
|
{
|
|
BSP_GPIO_SetMode(GET_PIN(B, 10), GPIO_MODE_AF_PP, GPIO_PULLUP); /* TX */
|
|
BSP_GPIO_SetMode(GET_PIN(B, 11), GPIO_MODE_INPUT, GPIO_PULLUP); /* RX */
|
|
__HAL_AFIO_REMAP_USART3_DISABLE();
|
|
}
|
|
else
|
|
{
|
|
BSP_GPIO_SetMode(GET_PIN(D, 8), GPIO_MODE_AF_PP, GPIO_PULLUP); /* TX */
|
|
BSP_GPIO_SetMode(GET_PIN(D, 9), GPIO_MODE_INPUT, GPIO_PULLUP); /* RX */
|
|
__HAL_AFIO_REMAP_USART3_ENABLE();
|
|
}
|
|
_uart3_alter = uart->id;
|
|
}
|
|
break;
|
|
}
|
|
default: break;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
|
|
/* Callback functions ---------------------------------------------------------*/
|
|
/* 隞乩� 4 銝芸遆�啣��?HAL 摨?UART �詨���葉�剖遆�啁��噼��賣㺭 */
|
|
/* UART DMA �交𤣰�𦠜說銝剜鱏 */
|
|
void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
|
|
{
|
|
struct UART_STRUCT *uart = (struct UART_STRUCT *)huart;
|
|
|
|
if (_UART_DMA_RxCallback)
|
|
_UART_DMA_RxCallback(uart);
|
|
}
|
|
|
|
/* UART DMA �交𤣰�冽說銝剜鱏 */
|
|
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
|
{
|
|
struct UART_STRUCT *uart = (struct UART_STRUCT *)huart;
|
|
|
|
if (_UART_DMA_RxCallback)
|
|
_UART_DMA_RxCallback(uart);
|
|
}
|
|
|
|
/* UART DMA �煾����𣂷葉�?*/
|
|
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
|
{
|
|
struct UART_STRUCT *uart = (struct UART_STRUCT *)huart;
|
|
|
|
if (_UART_DMA_TxCallback)
|
|
_UART_DMA_TxCallback(uart);
|
|
}
|
|
|
|
/* UART 銝剜鱏璉�瘚见��躰秤���靚�遆�?*/
|
|
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
|
|
{
|
|
struct UART_STRUCT *uart = (struct UART_STRUCT *)huart;
|
|
|
|
//printf("%s: %d %d\r\n", __FUNCTION__, uart->id, huart->ErrorCode);
|
|
}
|
|
|
|
|
|
/* Interrupt request functions ---------------------------------------------------------*/
|
|
#if (BSP_USING_UART1)
|
|
void USART1_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
_UART_IntHandler(&UART(1));
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART1_DMA_RX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
if (UART(1).rx_init)
|
|
{
|
|
HAL_DMA_IRQHandler(UART(1).handle.hdmarx);
|
|
}
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART1_DMA_TX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
HAL_DMA_IRQHandler(UART(1).handle.hdmatx);
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
#endif
|
|
|
|
#if (BSP_USING_UART2)
|
|
void USART2_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
#if (BSP_USING_UART2_RE)
|
|
if (_uart2_alter == BSP_UART2)
|
|
_UART_IntHandler(&UART(2));
|
|
else
|
|
_UART_IntHandler(&UART(2_RE));
|
|
#else
|
|
_UART_IntHandler(&UART(2));
|
|
#endif
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART2_DMA_RX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
if (UART(2).rx_init)
|
|
{
|
|
#if (BSP_USING_UART2_RE)
|
|
if (_uart2_alter == BSP_UART2)
|
|
HAL_DMA_IRQHandler(UART(2).handle.hdmarx);
|
|
else
|
|
HAL_DMA_IRQHandler(UART(2_RE).handle.hdmarx);
|
|
#else
|
|
HAL_DMA_IRQHandler(UART(2).handle.hdmarx);
|
|
#endif
|
|
}
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART2_DMA_TX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
#if (BSP_USING_UART2_RE)
|
|
if (_uart2_alter == BSP_UART2)
|
|
HAL_DMA_IRQHandler(UART(2).handle.hdmatx);
|
|
else
|
|
HAL_DMA_IRQHandler(UART(2_RE).handle.hdmarx);
|
|
#else
|
|
HAL_DMA_IRQHandler(UART(2).handle.hdmarx);
|
|
#endif
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
#endif
|
|
|
|
#if (BSP_USING_UART3)
|
|
void USART3_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
#if (BSP_USING_UART3_RE)
|
|
if (_uart3_alter == BSP_UART3)
|
|
_UART_IntHandler(&UART(3));
|
|
else
|
|
_UART_IntHandler(&UART(3_RE));
|
|
#else
|
|
_UART_IntHandler(&UART(3));
|
|
#endif
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART3_DMA_RX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
if (UART(3).rx_init)
|
|
{
|
|
#if (BSP_USING_UART3_RE)
|
|
if (_uart3_alter == BSP_UART3)
|
|
HAL_DMA_IRQHandler(UART(3).handle.hdmarx);
|
|
else
|
|
HAL_DMA_IRQHandler(UART(3_RE).handle.hdmarx);
|
|
#else
|
|
HAL_DMA_IRQHandler(UART(3).handle.hdmarx);
|
|
#endif
|
|
}
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART3_DMA_TX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
#if (BSP_USING_UART3_RE)
|
|
if (_uart3_alter == BSP_UART3)
|
|
HAL_DMA_IRQHandler(UART(3).handle.hdmarx);
|
|
else
|
|
HAL_DMA_IRQHandler(UART(3_RE).handle.hdmarx);
|
|
#else
|
|
HAL_DMA_IRQHandler(UART(3).handle.hdmarx);
|
|
#endif
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
#endif
|
|
|
|
#if (BSP_USING_UART4)
|
|
void UART4_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
_UART_IntHandler(&UART(4));
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART4_DMA_RX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
if (UART(4).rx_init)
|
|
{
|
|
HAL_DMA_IRQHandler(UART(4).handle.hdmarx);
|
|
}
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART4_DMA_TX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
HAL_DMA_IRQHandler(UART(4).handle.hdmatx);
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
#endif
|
|
|
|
#if (BSP_USING_UART5)
|
|
void UART5_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
_UART_IntHandler(&UART(5));
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART5_DMA_RX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
if (UART(5).rx_init)
|
|
{
|
|
HAL_DMA_IRQHandler(UART(5).handle.hdmarx);
|
|
}
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART5_DMA_TX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
HAL_DMA_IRQHandler(UART(5).handle.hdmatx);
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
#endif
|
|
|
|
#if (BSP_USING_UART6)
|
|
void USART6_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
_UART_IntHandler(&UART(6));
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART6_DMA_RX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
if (UART(6).rx_init)
|
|
{
|
|
HAL_DMA_IRQHandler(UART(6).handle.hdmarx);
|
|
}
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
|
|
void UART6_DMA_TX_IRQHandler(void)
|
|
{
|
|
BSP_INT_ENTER();
|
|
|
|
HAL_DMA_IRQHandler(UART(6).handle.hdmatx);
|
|
|
|
BSP_INT_EXIT();
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
|