common.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #ifndef _COMMON_H_
  2. #define _COMMON_H_
  3. #include <stdio.h>
  4. #include <stdint.h>
  5. #include <string.h>
  6. #include <stdlib.h>
  7. #include <math.h>
  8. #include <ctype.h>
  9. #include "gd32f10x.h"
  10. #include "gd32f10x_libopt.h"
  11. #include "delay.h"
  12. #define DEBUG_MODE (1)
  13. #define CONFIG_CAN_IAP
  14. #define USART_BAUND (38400)
  15. #define NVIC_OFFSET (0x00)
  16. #define THER_NUM_CON 2u
  17. #define SN_FLASH_ADDRESS (2048)
  18. #define SYLC_FLASH_ADDRESS (SN_FLASH_ADDRESS + 1024)
  19. #define HARD_TEST_FLASH_ADDRESS (SYLC_FLASH_ADDRESS + 1024)
  20. #define TEST_INFO_FLASH_ADDRESS (HARD_TEST_FLASH_ADDRESS + 1024)
  21. #define PS100_SERIAL_NUM_SIZE 18
  22. #define PS100_SOFTWARE_SIZE 20
  23. extern const uint8_t soft_version[];
  24. extern uint8_t sn[PS100_SERIAL_NUM_SIZE];
  25. typedef struct
  26. {
  27. uint8_t set;
  28. uint16_t count;
  29. }DELAY_COMMON;
  30. typedef struct
  31. {
  32. uint8_t enable;
  33. uint8_t set;
  34. uint16_t count;
  35. }CTR_DELAY_COMMON;
  36. enum
  37. {
  38. WS_BATTER_BING_LIAN,
  39. WS_BATTER_CHUAN_LIAN,
  40. WS_BATTER_MAX
  41. };
  42. #define NO_EVENT 0x00000000UL
  43. #define RS485_RECEIVE_END_EVENT 0x00000001UL
  44. #define EVENT_CAN_RECEIVE_FINISH 0x00000002UL
  45. #define RS485_2_RECEIVE_END_EVENT 0x00000004UL
  46. #define SUB_BMS_1_RS485_DISC_EVENT 0x00000008UL
  47. #define SUB_BMS_2_RS485_DISC_EVENT 0x00000010UL
  48. #define MEASURE_TEMPERATURE_EVENT 0x00000020UL
  49. #define SUB_BMS_1_SEND_CMD_EVENT 0x00000040UL
  50. #define SUB_BMS_2_SEND_CMD_EVENT 0x00000080UL
  51. #define BMS_1_RESEND_CMD_EVENT 0x00000100UL
  52. #define BMS_2_RESEND_CMD_EVENT 0x00000200UL
  53. #define END_CTR_RESEND_CMD_EVENT 0x00000400UL
  54. #define ADAS_RESEND_CMD_EVENT 0x00000800UL
  55. #define BMS_1_SELF_TIMEOUT_EVENT 0x00001000UL
  56. #define BMS_2_SELF_TIMEOUT_EVENT 0x00002000UL
  57. #define END_CTR_SELF_TIMEOUT_EVENT 0x00004000UL
  58. #define ADAS_SELF_TIMEOUT_EVENT 0x00008000UL
  59. #define ADAS_PWM_1_TIMEOUT_EVENT 0x00010000UL
  60. #define ADAS_PWM_2_TIMEOUT_EVENT 0x00020000UL
  61. #define ADAS_MEAS_1_FINISH_EVENT 0x00040000UL
  62. #define ADAS_MEAS_2_FINISH_EVENT 0x00080000UL
  63. #define RE_INITIAL_CAN_EVENT 0x00100000UL
  64. #define ENTER_SLEEP_EVENT 0x00200000UL
  65. #define DEVICE_REBOOT_EVENT 0x00400000UL
  66. #define SAVE_PARAM_EVENT 0x00800000UL
  67. extern uint32_t g_event;
  68. #define ST_NORMAL (0x0000u)
  69. #define ST_OVRCHRG_VOL (0x0001u)
  70. #define ST_OVRDISCHRG_VOL (0x0002u)
  71. #define ST_SMALL_CURRENT_OVER (0x0004u)
  72. #define ST_SHORT_CUR (0x0008u)
  73. #define ST_CHRG_CUR (0x0010u)
  74. #define ST_DISCHRG_CUR (0x0020u)
  75. #define ST_OVRCHRG_CUR (0x0040u)
  76. #define ST_OVRDISCHRG_CUR (0x0080u)
  77. #define ST_TOTAL_CHRG (0x0100u)
  78. #define ST_CELLDIFF_CHRG (0x0200u)
  79. #define ST_PSAVE (0x0400u)
  80. #define ST_PDOWN (0x0800u)
  81. #define ST_UDR_TEMPE_CHRG (0x1000u)//Detect the charge inhibit temperature (high)
  82. #define ST_UDR_TEMPE_DISCHRG (0x2000u)
  83. #define ST_OVR_TEMPE_CHRG (0x4000u)
  84. #define ST_OVR_TEMPE_DISCHRG (0x8000u)
  85. //#define HAN_GUO_VERSION
  86. uint8_t Get_RS485_CRC(uint8_t *data,uint16_t size);
  87. void Writer_SN(uint8_t *data);
  88. #endif