usart.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file usart.h
  5. * @brief This file contains all the function prototypes for
  6. * the usart.c file
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * Copyright (c) 2025 STMicroelectronics.
  11. * All rights reserved.
  12. *
  13. * This software is licensed under terms that can be found in the LICENSE file
  14. * in the root directory of this software component.
  15. * If no LICENSE file comes with this software, it is provided AS-IS.
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef __USART_H__
  22. #define __USART_H__
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "main.h"
  28. /* USER CODE BEGIN Includes */
  29. #define BUFFER_SIZE 512 //大环形队列长度
  30. #define RXBUFFLEN 0x1FF //大环形队列校验
  31. /* USER CODE END Includes */
  32. extern UART_HandleTypeDef huart1;
  33. extern UART_HandleTypeDef huart3;
  34. /* USER CODE BEGIN Private defines */
  35. typedef struct{
  36. volatile uint16_t rx_len; //接收到的数据长度
  37. volatile uint8_t recv_end_flag;//接收完成标志
  38. uint8_t RX_BUFFER[BUFFER_SIZE];//大缓存数组
  39. }Rxbuff_t;
  40. enum
  41. {
  42. Usart_1, //0 福斯遥控器 SBUS
  43. Usart_2, //1
  44. Usart_3, //2
  45. // Usart_4, //3
  46. // Usart_5, //4
  47. // Usart_6, //5 RTK
  48. // Usart_7, //6
  49. // TTL_1, //7
  50. // TTL_2, //8
  51. Usart_Num
  52. };
  53. typedef struct
  54. {
  55. uint16_t Write ;
  56. uint16_t Read ;
  57. uint8_t RX_BUFFER[BUFFER_SIZE];
  58. uint8_t aRxBuff;
  59. uint16_t Flag;
  60. uint16_t Time_out;
  61. uint16_t SendFlag;
  62. uint16_t CrcCheck;
  63. uint8_t CRC_L;
  64. uint8_t CRC_H;
  65. uint8_t XorCheck;
  66. uint8_t heart[2];
  67. }LOOPRXTYPE;
  68. extern Rxbuff_t Rxbuffer[Usart_Num];
  69. /* USER CODE END Private defines */
  70. void MX_USART1_UART_Init(void);
  71. void MX_USART3_UART_Init(void);
  72. /* USER CODE BEGIN Prototypes */
  73. void Uart_Send(UART_HandleTypeDef *huart,uint8_t *data,uint8_t len);
  74. /* USER CODE END Prototypes */
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif /* __USART_H__ */