UartTask.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /****************************************************************************
  2. *
  3. * Copy right: Qx.
  4. * File name: UartTask.h
  5. * Description: 串口任务
  6. * History: 2021-03-05
  7. *
  8. ****************************************************************************/
  9. typedef struct _UartRedMsg
  10. {
  11. bool UartFlag;
  12. UINT8 Header[3];
  13. UINT8 data[120];
  14. UINT16 len;
  15. }UartReadMsgType;
  16. typedef struct Uart_Write_Data_Type
  17. {
  18. volatile uint8_t WriteCmd;
  19. uint8_t Data[2];
  20. }Uart_Write_Data_Type;
  21. //全局变量输出区
  22. extern UartReadMsgType UartReadMsg;
  23. extern osMutexId_t UartMutex;
  24. extern Uart_Write_Data_Type UartWriteData;
  25. //
  26. #define UART_WRITE_FLAG 0x01
  27. #define UART_READ_FLAG 0x00
  28. #define PROC_UART_TASK_STACK_SIZE (1024)
  29. #define BMS_ADDRESS_CODE 0x01
  30. #define UART_READ_CODE 0x03
  31. #define UART_WRITE_CODE 0x10
  32. typedef struct Uart_Read_Msg_Type
  33. {
  34. uint8_t Bms_Address;
  35. uint8_t Bms_Funcode;
  36. uint8_t Reg_Begin_H;
  37. uint8_t Reg_Begin_L;
  38. uint8_t Reg_Num_H;
  39. uint8_t Reg_Num_L;
  40. uint8_t CRC_L;
  41. uint8_t CRC_H;
  42. }Uart_Read_Msg_Type;
  43. typedef struct Uart_Write_Msg_Type
  44. {
  45. uint8_t Bms_Address;
  46. uint8_t Bms_Funcode;
  47. uint8_t Reg_Begin_H;
  48. uint8_t Reg_Begin_L;
  49. uint8_t Reg_Num_H;
  50. uint8_t Reg_Num_L;
  51. uint8_t Data_Count;
  52. uint8_t Data[2];
  53. uint8_t CRC_L;
  54. uint8_t CRC_H;
  55. }Uart_Write_Msg_Type;
  56. typedef struct Uart_Write_Answer_Msg_Type
  57. {
  58. uint8_t Bms_Address;
  59. uint8_t Bms_Funcode;
  60. }Uart_Write_Answer_Msg_Type;
  61. typedef enum
  62. {
  63. PROCESS_UART_STATE_IDLE = 0,
  64. PROCESS_UART_STATE_READ,
  65. PROCESS_UART_STATE_WRITE,
  66. PROCESS_UART_STATE_SLEEP
  67. }process_Uart;
  68. void UartTaskInit(void* arg);
  69. void UartTaskDeInit(void* arg);