UartTask.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. //全局变量输出区
  17. extern UartReadMsgType UartReadMsg;
  18. extern osMutexId_t UartMutex;
  19. //
  20. #define PROC_UART_TASK_STACK_SIZE (1024)
  21. #define BMS_ADDRESS_CODE 0x01
  22. #define UART_READ_CODE 0x03
  23. #define UART_WRITE_CODE 0x10
  24. typedef struct Uart_Read_Msg_Type
  25. {
  26. uint8_t Bms_Address;
  27. uint8_t Bms_Funcode;
  28. uint8_t Reg_Begin_H;
  29. uint8_t Reg_Begin_L;
  30. uint8_t Reg_Num_H;
  31. uint8_t Reg_Num_L;
  32. uint8_t CRC_H;
  33. uint8_t CRC_L;
  34. }Uart_Read_Msg_Type;
  35. typedef struct Uart_Write_Msg_Type
  36. {
  37. uint8_t Bms_Address;
  38. uint8_t Bms_Funcode;
  39. uint8_t Reg_Begin_H;
  40. uint8_t Reg_Begin_L;
  41. uint8_t Reg_Num_H;
  42. uint8_t Reg_Num_L;
  43. uint8_t Data_Count;
  44. uint8_t Data[2];
  45. uint8_t CRC_H;
  46. uint8_t CRC_L;
  47. }Uart_Write_Msg_Type;
  48. typedef struct Uart_Write_Answer_Msg_Type
  49. {
  50. uint8_t Bms_Address;
  51. uint8_t Bms_Funcode;
  52. }Uart_Write_Answer_Msg_Type;
  53. typedef enum
  54. {
  55. PROCESS_UART_STATE_IDLE = 0,
  56. PROCESS_UART_STATE_READ,
  57. PROCESS_UART_STATE_WRITE,
  58. PROCESS_UART_STATE_SLEEP
  59. }process_Uart;
  60. void UartTaskInit(void* arg);
  61. void UartTaskDeInit(void* arg);