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.

36 lines
661 B

3 years ago
  1. # zstm32uart_irq_rx_service
  2. ## USAGE
  3. ```
  4. 功能描述:
  5. 初始化串口,让串口以中断的形式,持续不断的接收消息,接收到消息通过HOOK_ZUART_RxCpltCallback回调上来,同时如果串口发生异常,自动重启串口接收。
  6. ```
  7. ```c
  8. static zstm32uart_t s_uarts[] = {
  9. {
  10. .huart = &huart2,
  11. } //
  12. };
  13. ...
  14. void HOOK_ZUART_RxCpltCallback(UART_HandleTypeDef* huart, uint8_t rxdata) {
  15. if (huart == &huart2) {
  16. /**
  17. * 处理接收到串口消息
  18. */
  19. }
  20. }
  21. ...
  22. void main() {
  23. ....
  24. //启动串口接收
  25. uart_service_start_all_uart_rx(s_uarts, ARRARY_SIZE(s_uarts));
  26. ...
  27. }
  28. ```