common.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef __COMMON_H
  2. #define __COMMON_H
  3. #include "tim.h"
  4. #include "stdlib.h"
  5. #include "stdbool.h"
  6. #define _1_HZ_ 1000
  7. #define _2_HZ_ 500
  8. #define _5_HZ_ 200
  9. #define _10_HZ_ 100
  10. #define _20_HZ_ 50
  11. #define _50_HZ_ 20
  12. #define _100_HZ_ 10
  13. #define _200_HZ_ 5
  14. #define _500_HZ_ 2
  15. #define _1000_HZ_ 1
  16. typedef enum
  17. {
  18. COMP_NOEXIST = 0,
  19. COMP_NORMAL = 1,
  20. COMP_LOST = 2,
  21. COMP_CLOSED = 3,
  22. COMP_RECON = 4
  23. } comp_status;
  24. typedef struct
  25. {
  26. uint32_t recv_time;
  27. int error_time;
  28. comp_status connect_status;
  29. bool boot_flag;
  30. } Connect_check;
  31. void Check_dev_link(Connect_check *dev, uint16_t ms, char *p, uint16_t size);
  32. bool Check_Timer_Ready(uint32_t *time, uint16_t HZ);
  33. int findStrInArray(uint8_t *array, int aLen, const char *str);
  34. void buf2int(int *tint, unsigned char *buf);
  35. void short2buf(unsigned char *buf, short *tshort);
  36. void u16t_buf_sort(uint16_t *arr, uint16_t length);
  37. void char_to_hex_string(unsigned char *cdata, short lenc, char *sbuf, short lens, char *ES);
  38. char *itoa(int num, char *str, int radix);
  39. char *Int2String(int num, char *str, uint8_t size);
  40. int16_t math_cons_i16( int16_t value, int16_t min, int16_t max );
  41. bool StrArrayNull( uint8_t *array, int aLen );
  42. #endif