hal_module_adapter.h 4.2 KB

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