hal_module_adapter.h 4.3 KB

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