hal_module_adapter.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #ifndef HAL_MODULE_ADAPTER_H
  2. #define HAL_MODULE_ADAPTER_H
  3. #ifdef __cplusplus
  4. extern "C"
  5. {
  6. #endif
  7. #include "commontypedef.h"
  8. #include "sensor.h"
  9. #include "can.h"
  10. #include "bsp.h"
  11. #define USING_PRINTF
  12. #define DEBUGLOG
  13. #define GPS_DATA_RECV_BUFFER_SIZE (1024)
  14. #define I2C_INT1_REQ_BITMAP (0x1)
  15. #define I2C_INT2_REQ_BITMAP (0x2)
  16. #define ADC_REQ_BITMAP_VBAT (0x01)
  17. #define ADC_REQ_BITMAP_TEMP (0x02)
  18. #define ADC_REQ_BITMAP_CH1 (0x04)
  19. #define ADC_REQ_BITMAP_CH2 (0x08)
  20. #define ADC_REQ_BITMAP_CH30 (0x10)
  21. #define ADC_REQ_BITMAP_CH31 (0x20)
  22. #define ADC_REQ_BITMAP_CH4 (0x40)
  23. #define ADC_REQ_BITMAP_VBAT_CALI (0x80)
  24. #define ADC_REQ_BITMAP_INRES_CALI (0x100)
  25. #define ADC_GET_RESULT_TIMOUT (2000)
  26. typedef enum
  27. {
  28. FAST_CHARGE_TEMP = 1,
  29. NORMAL_CHARGE_TEMP,
  30. OTHER_TEMP_1,
  31. OTHER_TEMP_2,
  32. VBAT
  33. } ADC_CHANNEL_TYPE;
  34. typedef enum _ntc_channel
  35. {
  36. NTC_Channel1,
  37. NTC_Channel2,
  38. NTC_Channel30,
  39. NTC_Channel31,
  40. NTC_Channel4,
  41. NTC_Channel4_VbatCali,
  42. NTC_Channel4_InresCali,
  43. NTC_ChannelMax
  44. } ntc_channel_t;
  45. typedef enum
  46. {
  47. LED_SOC_0,
  48. LED_SOC_1,
  49. LED_SOC_2,
  50. LED_SOC_3,
  51. LED_MAX_INX
  52. } ledInx_t;
  53. typedef enum
  54. {
  55. AON_IO = 0,
  56. NORMAL_IO = 1,
  57. } IOType;
  58. typedef enum
  59. {
  60. LED_TURN_ON,
  61. LED_TURN_OFF
  62. } ledStaus_t;
  63. typedef struct
  64. {
  65. UINT32 request;
  66. UINT32 param[7];
  67. } adcReqMsg;
  68. typedef struct
  69. {
  70. void *dataPtr;
  71. UINT32 len;
  72. } gpsReqMsg;
  73. typedef struct
  74. {
  75. UINT32 event;
  76. UINT32 value;
  77. } i2c_recv_msgqueue_obj_t;
  78. typedef struct _led_pin_config
  79. {
  80. INT32 pinPort;
  81. INT32 pinInx;
  82. INT32 padInx;
  83. pad_mux_t padMutex;
  84. } led_pin_config_t;
  85. typedef enum
  86. {
  87. STD_PACK,
  88. EXT_PACK,
  89. PACK_MAX
  90. } PackType;
  91. typedef struct _can_initType
  92. {
  93. INT32 baudrate;
  94. INT16 mode;
  95. INT8 TxStdIDH;
  96. /*
  97. std : sid0 - sid2 ->bit5-bit7
  98. ext :eid17: bit1
  99. ext: eid16 :bit0
  100. */
  101. INT8 TxStdIDL;
  102. INT8 TxExtIDH;
  103. INT8 TxExtIDL;
  104. INT8 RxStdIDH[6];
  105. INT8 RxStdIDL[6];
  106. INT8 RxExtIDH[6];
  107. INT8 RxExtIDL[6];
  108. PackType packType; //0 STID; 1 EXTID;
  109. } Can_InitType;
  110. typedef struct _Can_TxMsgType
  111. {
  112. UINT16 stdIDH;
  113. UINT16 stdIDL;
  114. UINT8 DLC;
  115. UINT8 Data[8];
  116. } Can_TxMsgType;
  117. typedef struct UTC8Time_Type
  118. {
  119. UINT16 year;
  120. UINT8 month;
  121. UINT8 day;
  122. UINT8 hour;
  123. UINT8 minute;
  124. UINT8 second;
  125. } UTC8TimeType;
  126. #ifdef BL_FILE_LOG
  127. typedef enum
  128. {
  129. BL_LEVEL0,
  130. BL_LEVEL1,
  131. BL_LEVEL2,
  132. BL_LEVEL3,
  133. } BlLogLevel;
  134. #endif
  135. typedef struct CAN_Msg_Type
  136. {
  137. UINT32 Id;
  138. UINT8 DLC;
  139. UINT8 Data[8];
  140. } CAN_Msg_Type;
  141. typedef void (*posGGACallBack)(UINT8 res, UINT8 *params);
  142. void PowerPinConfig(IOType iotype);
  143. void relayConfigInit(void);
  144. void relayControl(BOOL onOrOff);
  145. void posGGAServiceStop(void);
  146. void posGGAReset(void);
  147. void NetSocDisplay(ledInx_t Inx, ledStaus_t status);
  148. void FaultDisplay(ledStaus_t status);
  149. INT32 AdcSendReq(UINT32 req, UINT32 *param, UINT8 len, UINT32 timeout);
  150. INT32 AdcTaskInit(void);
  151. void CanSPIHandler(ARM_SPI_SignalEvent_t cb_event, UINT8 mode, UINT8 dataBits, UINT32 spiRate);
  152. #if 1
  153. UINT8 CanTriggerEvtInit(void);
  154. void CanWaitEvt(UINT32 timeout);
  155. void CanTiggerEvt(UINT8 cmd);
  156. #endif
  157. INT32 CAN_WriteReg(UINT8 addr, UINT8 value);
  158. INT32 CAN_ReadReg(UINT8 reg, UINT8 len, UINT8 *buf);
  159. void HAL_Can_Init(Can_InitType param);
  160. void HAL_Can_Sleep(void);
  161. INT32 HAL_Can_Reset(void);
  162. INT8 HAL_Can_Transmit(CAN_Msg_Type Can_TxMsg);
  163. UINT8 HAL_Can_Receive(CAN_Msg_Type *CanRxMsgBuffer);
  164. void UTCToBeijing(UTC8TimeType *UTC8Time, unsigned int UTCyear, unsigned char UTCmonth, unsigned char UTCday, unsigned int UTChour, unsigned char UTCminute, unsigned char UTCsecond);
  165. BOOL NB_ADC_Get(UINT32 *adcValue, ADC_CHANNEL_TYPE adcChannel);
  166. #ifdef DEBUGLOG
  167. void Debug_Del_Logfile(void);
  168. void Debug_Read_Logfile(UINT8 *rbuf, UINT16 FileSize);
  169. void Debug_printf(const UINT8 *format, ...);
  170. UINT16 Debug_GetSize();
  171. #endif
  172. #ifdef BL_FILE_LOG
  173. void bluejoy_printf(BlLogLevel level, const UINT8 *format, ...);
  174. void bluejoy_read_logfile(void);
  175. void bluejoy_del_logfile(void);
  176. #endif
  177. extern void GsensorInit(void);
  178. extern void GsensorI2CHandler(ARM_I2C_SignalEvent_t cb_event);
  179. extern void GsensorI2CCallback(UINT32 event);
  180. #ifdef __cplusplus
  181. }
  182. #endif
  183. #endif /* HAL_MODULE_ADAPTER_H */