You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
#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;
|
|
for (size_t i = 0; i < s_table_size; i++) {
|
|
HAL_UART_Receive_IT(s_table[i].huart, &s_table->rxbuf, 1);
|
|
}
|
|
}
|