|
|
@ -1,8 +1,36 @@ |
|
|
|
#include "zstm32uart_irq_rx_service.h" |
|
|
|
__weak void HOOK_ZUART_RxCpltCallback(UART_HandleTypeDef* huart, uint8_t rxdata) {} |
|
|
|
|
|
|
|
static zstm32uart_t* s_table; |
|
|
|
static int s_table_size; |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief 串口相关衔接点处理 |
|
|
|
*/ |
|
|
|
static inline void start_receive(UART_HandleTypeDef* huart) { |
|
|
|
for (size_t i = 0; i < s_table_size; i++) { |
|
|
|
if (huart == s_table[i].huart) { |
|
|
|
HAL_UART_Receive_IT(s_table[i].huart, &s_table->rxbuf, 1); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static inline uint8_t getrxdata(UART_HandleTypeDef* huart) { |
|
|
|
for (size_t i = 0; i < s_table_size; i++) { |
|
|
|
if (huart == s_table[i].huart) { |
|
|
|
return s_table[i].rxbuf; |
|
|
|
} |
|
|
|
} |
|
|
|
//代码如果走到这里,说明某个串口中断被触发了,但却没有登记该串口 |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart) { |
|
|
|
HOOK_ZUART_RxCpltCallback(huart, getrxdata(huart)); |
|
|
|
start_receive(huart); |
|
|
|
} |
|
|
|
|
|
|
|
void uart_service_start_all_uart_rx(zstm32uart_t* table, int size) { |
|
|
|
s_table = table; |
|
|
|
s_table_size = size; |
|
|
|