tool.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * @Description:
  3. * @Version: 2.0
  4. * @Author: Seven
  5. * @Date: 2023-08-09 16:54:10
  6. * @LastEditors: Seven
  7. * @LastEditTime: 2023-09-20 16:36:49
  8. */
  9. #ifndef TOOL_H__
  10. #define TOOL_H__
  11. #include "stm32f10x.h"
  12. typedef struct timeout_
  13. {
  14. uint8_t flag;
  15. uint64_t count;
  16. uint64_t timeout;
  17. }__attribute__((packed)) timeout_t;
  18. uint16_t CRC16_get(uint8_t *_buff,uint32_t _len);
  19. uint8_t _crc_get_gw(uint8_t *data, uint8_t size);
  20. uint8_t get_xor(uint8_t *buf, uint16_t len);
  21. void _ytsf_data_code(uint8_t *buff, uint8_t *len);
  22. void _ytsf_data_decode(uint8_t *buff, uint8_t *len);
  23. long HextoDec(char *s);
  24. unsigned char HexToChar(unsigned char bChar);
  25. int asciitohex(char *data, uint8_t *out_data, int len);
  26. uint32_t strtohex(char *data, uint8_t len);
  27. uint8_t ascii_to_bcd(uint8_t *data, uint8_t *res, uint16_t len);
  28. void timeout_setValue(timeout_t *tt,uint32_t val,uint8_t flg);
  29. void timeout_start(timeout_t *tt,uint8_t flg);
  30. void timeout_stop(timeout_t *tt);
  31. uint8_t timeout_isOut(timeout_t *tt);
  32. void timeout_setValue_us(timeout_t *tt,uint32_t val,uint8_t flg);
  33. void timeout_start_us(timeout_t *tt,uint8_t flg);
  34. void timeout_stop_us(timeout_t *tt);
  35. uint8_t timeout_isOut_us(timeout_t *tt);
  36. uint8_t buff_compare(uint8_t *buf1, uint8_t *buf2, uint16_t len);
  37. uint32_t crc_block_data_calculate(uint32_t *buf, uint32_t len);
  38. uint16_t set_flag_not(uint16_t data);
  39. uint8_t flag_not_cmp(uint16_t data);
  40. #endif