common.h 1.2 KB

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