uart_update.h 1016 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef _UART_DEV_
  2. #define _UART_DEV_
  3. #include "typedef.h"
  4. #define MSG_UART_UPDATE_READY 0x1
  5. #define MSG_UART_UPDATE_START 0x2
  6. #define MSG_UART_UPDATE_START_RSP 0X3
  7. #define MSG_UART_UPDATE_READ_RSP 0x4
  8. #define MSG_UART_UPDATE_ALIVE_RSP 0x5
  9. #define PROTOCAL_SIZE 528
  10. #define SYNC_SIZE 6
  11. #define SYNC_MARK0 0xAA
  12. #define SYNC_MARK1 0x55
  13. typedef union {
  14. u8 raw_data[PROTOCAL_SIZE + SYNC_SIZE];
  15. struct {
  16. u8 mark0;
  17. u8 mark1;
  18. u16 length;
  19. u8 data[PROTOCAL_SIZE + 2]; //最后CRC16
  20. } data;
  21. } protocal_frame_t;
  22. struct file_info {
  23. u8 cmd;
  24. u32 addr;
  25. u32 len;
  26. } __attribute__((packed));
  27. typedef struct __update_io {
  28. u16 rx;
  29. u16 tx;
  30. u8 input_channel; //input channel选择,根据方案选择未被使用的channel
  31. u8 output_channel; //同input channel
  32. } uart_update_cfg;
  33. void uart_update_init(uart_update_cfg *cfg);
  34. void sava_uart_update_param(void);
  35. #endif