common.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef __COMMON_H
  2. #define __COMMON_H
  3. #include "stm32f4xx_hal.h"
  4. #include "rtthread.h"
  5. #include "stm32f4xx_it.h"
  6. #include "stm32f4xx_hal_uart.h"
  7. #include "stdbool.h"
  8. #define _1_HZ_ 1000
  9. #define _2_HZ_ 500
  10. #define _3_HZ_ 300
  11. #define _4_HZ_ 250
  12. #define _5_HZ_ 200
  13. #define _6_HZ_ 166
  14. #define _7_HZ_ 143
  15. #define _8_HZ_ 125
  16. #define _9_HZ_ 115
  17. #define _10_HZ_ 100
  18. #define _11_HZ_ 91
  19. #define _12_HZ_ 83
  20. #define _13_HZ_ 75
  21. #define _14_HZ_ 67
  22. #define _15_HZ_ 60
  23. #define _16_HZ_ 53
  24. #define _17_HZ_ 47
  25. #define _18_HZ_ 41
  26. #define _19_HZ_ 37
  27. #define _20_HZ_ 50
  28. #define _40_HZ_ 25
  29. #define _31_HZ_ 33
  30. #define _32_HZ_ 32
  31. #define _33_HZ_ 31
  32. #define _50_HZ_ 20
  33. #define _100_HZ_ 10
  34. #define _200_HZ_ 5
  35. #define _300_HZ_ 3
  36. #define _500_HZ_ 2
  37. #define _1000_HZ_ 12
  38. typedef enum
  39. {
  40. COMP_NOEXIST = 0,
  41. COMP_NORMAL = 1,
  42. COMP_LOST = 2,
  43. COMP_CLOSED = 3,
  44. COMP_RECON = 4
  45. } comp_status;
  46. typedef struct
  47. {
  48. uint32_t recv_time;
  49. int error_time;
  50. comp_status connect_status;
  51. bool boot_flag;
  52. } Connect_check;
  53. void Check_dev_link(Connect_check *dev, uint16_t ms, char *p, uint16_t size);
  54. bool Check_Timer_Ready(uint32_t *time, uint16_t HZ);
  55. int findStrInArray(uint8_t *array, int aLen, const char *str);
  56. void buf2int(int *tint, unsigned char *buf);
  57. void short2buf(unsigned char *buf, short *tshort);
  58. void u16t_buf_sort(uint16_t *arr, uint16_t length);
  59. void char_to_hex_string(unsigned char *cdata, short lenc, char *sbuf, short lens, char *ES);
  60. char *itoa(int num, char *str, int radix);
  61. char *Int2String(int num, char *str, uint8_t size);
  62. int16_t math_cons_i16( int16_t value, int16_t min, int16_t max );
  63. bool StrArrayNull( uint8_t *array, int aLen );
  64. void buf_sort(float *arr, uint32_t length);
  65. uint32_t cycle_check_ms(uint32_t *time);
  66. #endif