Browse Source

删除赵老师文件内容

master
zwsd 3 years ago
parent
commit
b98b4311d2
  1. 37
      README.md
  2. 12
      zstm32uart_irq_rx_service.c
  3. 8
      zstm32uart_irq_rx_service.h

37
README.md

@ -1,2 +1,37 @@
# copyZ_zstm32uart_irq_rx_service
# zstm32uart_irq_rx_service
## USAGE
```
功能描述:
初始化串口,让串口以中断的形式,持续不断的接收消息,接收到消息通过HOOK_ZUART_RxCpltCallback回调上来,同时如果串口发生异常,自动重启串口接收。
```
```c
static zstm32uart_t s_uarts[] = {
{
.huart = &huart2,
} //
};
...
void HOOK_ZUART_RxCpltCallback(UART_HandleTypeDef* huart, uint8_t rxdata) {
if (huart == &huart2) {
/**
* 处理接收到串口消息
*/
}
}
...
void main() {
....
//启动串口接收
uart_service_start_all_uart_rx(s_uarts, ARRARY_SIZE(s_uarts));
...
}
```

12
zstm32uart_irq_rx_service.c

@ -0,0 +1,12 @@
#include "zstm32uart_irq_rx_service.h"
static zstm32uart_t* s_table;
static int s_table_size;
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);
}
}

8
zstm32uart_irq_rx_service.h

@ -0,0 +1,8 @@
#include "main.h"
typedef struct {
UART_HandleTypeDef* huart;
uint8_t rxbuf;
} zstm32uart_t;
void uart_service_start_all_uart_rx(zstm32uart_t* table, int size);
Loading…
Cancel
Save