main.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Config.h
  3. *
  4. * Created on: 2020/01/15
  5. * Author: Eason Yang
  6. */
  7. #ifndef CONFIG_MAIN_H_
  8. #define CONFIG_MAIN_H_
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <sys/time.h>
  12. #include <sys/timeb.h>
  13. #include <sys/types.h>
  14. #include <sys/ioctl.h>
  15. #include <sys/socket.h>
  16. #include <sys/ipc.h>
  17. #include <sys/shm.h>
  18. #include <sys/mman.h>
  19. #include <linux/wireless.h>
  20. #include <arpa/inet.h>
  21. #include <netinet/in.h>
  22. #include <dirent.h>
  23. #include <unistd.h>
  24. #include <stdarg.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <unistd.h>
  28. #include <fcntl.h>
  29. #include <termios.h>
  30. #include <errno.h>
  31. #include <errno.h>
  32. #include <string.h>
  33. #include <time.h>
  34. #include <ctype.h>
  35. #include <ifaddrs.h>
  36. #include <stdbool.h>
  37. #include <stddef.h>
  38. #include <stdint.h>
  39. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
  40. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
  41. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
  42. #define ADC_AIN0 0
  43. #define ADC_AIN1 1
  44. #define ADC_AIN2 2
  45. #define ADC_AIN3 3
  46. typedef enum
  47. {
  48. GPIO_DIR_INPUT = 0,
  49. GPIO_DIR_OUTPUT
  50. }_GPIO_DIR;
  51. typedef enum
  52. {
  53. GPIO_IO_BD1_1 =0, // output
  54. GPIO_IO_BD1_2, // output
  55. GPIO_IO_BD2_1, // output
  56. GPIO_IO_BD2_2, // output
  57. GPIO_ID_BD1_1, // input
  58. GPIO_ID_BD1_2, // input
  59. GPIO_ID_BD2_1, // input
  60. GPIO_ID_BD2_2, // input
  61. GPIO_AM_RFID_RST, // output
  62. GPIO_AM_RFID_ICC, // output
  63. GPIO_BOARD1_PROXIMITY, // input
  64. GPIO_BOARD2_PROXIMITY, // input
  65. }_SYS_GPIO;
  66. #define SYS_GPIO_NUM 16
  67. #define PIN_IO_BD1_1 26
  68. #define PIN_IO_BD1_2 27
  69. #define PIN_IO_BD2_1 46
  70. #define PIN_IO_BD2_2 47
  71. #define PIN_ID_BD1_1 22
  72. #define PIN_ID_BD1_2 23
  73. #define PIN_ID_BD2_1 44
  74. #define PIN_ID_BD2_2 45
  75. #define PIN_AM_RFID_RST 19
  76. #define PIN_AM_RFID_ICC 20
  77. #define PIN_BOARD1_PROXIMITY 88
  78. #define PIN_BOARD2_PROXIMITY 86
  79. #define PIN_AM_DE_1 89
  80. #define PIN_AM_RE_1 87
  81. #define PIN_ENG_BNT 111
  82. extern int StoreLogMsg(const char *fmt, ...);
  83. enum
  84. {
  85. POLLING_STEP_0=0,
  86. POLLING_STEP_1,
  87. POLLING_STEP_2,
  88. POLLING_STEP_3,
  89. POLLING_STEP_4,
  90. POLLING_STEP_END
  91. };
  92. enum
  93. {
  94. ChargerSystemStatus_Booting=0,
  95. ChargerSystemStatus_Idle,
  96. ChargerSystemStatus_Authorizing,
  97. ChargerSystemStatus_Preparing,
  98. ChargerSystemStatus_Charging,
  99. ChargerSystemStatus_Terminating,
  100. ChargerSystemStatus_Alarm,
  101. ChargerSystemStatus_Fault
  102. };
  103. enum
  104. {
  105. RUN_STEP_0=0,
  106. RUN_STEP_1,
  107. RUN_STEP_2,
  108. RUN_STEP_3,
  109. RUN_STEP_4,
  110. RUN_STEP_END
  111. };
  112. void gpio_set_direction(int pin, unsigned char dir);
  113. void gpio_write(int pin, unsigned char value);
  114. int gpio_read(int pin);
  115. void InitIO(void);
  116. #define Relay1_on gpio_write(PIN_ID_BD1_1, 1);
  117. #define Relay1_off gpio_write(PIN_ID_BD1_1, 0);
  118. #define Relay2_on gpio_write(PIN_IO_BD1_1, 1);
  119. #define Relay2_off gpio_write(PIN_IO_BD1_1, 0);
  120. #define Relay3_on gpio_write(PIN_ID_BD2_1, 1);
  121. #define Relay3_off gpio_write(PIN_ID_BD2_1, 0);
  122. #define Relay4_on gpio_write(PIN_ID_BD1_2, 1);
  123. #define Relay4_off gpio_write(PIN_ID_BD1_2, 0);
  124. #define FAN1_on gpio_write(PIN_AM_RFID_RST, 1);
  125. #define FAN1_off gpio_write(PIN_AM_RFID_RST, 0);
  126. #define FAN2_on gpio_write(PIN_AM_RFID_ICC, 1);
  127. #define FAN2_off gpio_write(PIN_AM_RFID_ICC, 0);
  128. #define FAN3_on gpio_write(PIN_IO_BD2_2, 1);
  129. #define FAN3_off gpio_write(PIN_IO_BD2_2, 0);
  130. #define AIR_on gpio_write(PIN_IO_BD2_1, 1);
  131. #define AIR_off gpio_write(PIN_IO_BD2_1, 0);
  132. #define Battery_Start_charging system("/root/WebService startCharging 820 30"); //for TEST 10A
  133. #define Battery_Stop_charging system("/root/WebService stopCharging");
  134. #define ACTODC_Start_charging system("/root/WebService startCharging 750 200"); //for TEST 10A
  135. #define ACTODC_Stop_charging system("/root/WebService stopCharging");
  136. #define Read_EMSS_INFO system("/root/WebService readCharging");
  137. #define Default_Speed 1000
  138. #define Charging_Speed 6600
  139. #define MAX_Speed 12000
  140. #define TemperatureMax 1200
  141. #define TemperatureRecovery 900
  142. #define Temperature_20 1400
  143. #define Temperature_30 1447
  144. #define Temperature_40 1493
  145. #define Temperature_50 1541
  146. #define Temperature_60 1586
  147. typedef unsigned char UBYTE;
  148. typedef unsigned short UWORD;
  149. typedef unsigned int ULONG;
  150. typedef signed char SBYTE;
  151. typedef signed short SWORD;
  152. typedef signed int SLONG;
  153. typedef unsigned char byte;
  154. #endif /* CONFIG_MAIN_H_ */