39 #include "STC3115_Driver.h" 76 static DrvContextTypeDef GG_SensorHandle[ GG_MAX_NUM ];
77 static GG_Data_t GG_Data[ GG_MAX_NUM ];
78 static STC3115_Data_t STC3115_0_Data;
104 GG_Drv_t *driver = NULL;
106 if(GG_SensorHandle[ STC3115_0 ].isInitialized == 1)
109 return COMPONENT_ERROR;
114 return COMPONENT_ERROR;
118 GG_SensorHandle[ STC3115_0 ].who_am_i = STC3115_ID;
119 GG_SensorHandle[ STC3115_0 ].ifType = 0;
120 GG_SensorHandle[ STC3115_0 ].address = STC3115_SLAVE_ADDRESS;
121 GG_SensorHandle[ STC3115_0 ].spiDevice = 0;
122 GG_SensorHandle[ STC3115_0 ].instance = STC3115_0;
123 GG_SensorHandle[ STC3115_0 ].isInitialized = 0;
124 GG_SensorHandle[ STC3115_0 ].isEnabled = 0;
125 GG_SensorHandle[ STC3115_0 ].isCombo = 1;
126 GG_SensorHandle[ STC3115_0 ].pData = (
void * )&GG_Data[ STC3115_0 ];
127 GG_SensorHandle[ STC3115_0 ].pVTable = (
void * )&STC3115_Drv;
128 GG_SensorHandle[ STC3115_0 ].pExtVTable = 0;
130 GG_Data[ STC3115_0 ].pComponentData = (
void * )&STC3115_0_Data;
131 GG_Data[ STC3115_0 ].pExtData = 0;
133 *handle = (
void *)&GG_SensorHandle[ STC3115_0 ];
136 driver = ( GG_Drv_t * )((DrvContextTypeDef *)(*handle))->pVTable;
138 if ( driver->Init == NULL )
140 memset((*handle), 0,
sizeof(DrvContextTypeDef));
142 return COMPONENT_ERROR;
145 if ( driver->Init( (DrvContextTypeDef *)(*handle) ) == COMPONENT_ERROR )
147 memset((*handle), 0,
sizeof(DrvContextTypeDef));
149 return COMPONENT_ERROR;
164 DrvContextTypeDef *ctx = (DrvContextTypeDef *)(*handle);
165 GG_Drv_t *driver = NULL;
169 return COMPONENT_ERROR;
172 driver = ( GG_Drv_t * )ctx->pVTable;
174 if ( driver->DeInit == NULL )
176 return COMPONENT_ERROR;
179 if ( driver->DeInit( ctx ) == COMPONENT_ERROR )
181 return COMPONENT_ERROR;
184 memset(ctx, 0,
sizeof(DrvContextTypeDef));
205 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
209 return COMPONENT_ERROR;
212 if ( status == NULL )
214 return COMPONENT_ERROR;
217 *status = ctx->isInitialized;
233 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
237 return COMPONENT_ERROR;
240 if ( status == NULL )
242 return COMPONENT_ERROR;
245 *status = ctx->isCombo;
261 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
262 GG_Drv_t *driver = NULL;
266 return COMPONENT_ERROR;
269 driver = ( GG_Drv_t * )ctx->pVTable;
271 if ( who_am_i == NULL )
273 return COMPONENT_ERROR;
275 if ( driver->Get_WhoAmI == NULL )
277 return COMPONENT_ERROR;
279 if ( driver->Get_WhoAmI( ctx, who_am_i ) == COMPONENT_ERROR )
281 return COMPONENT_ERROR;
297 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
298 GG_Drv_t *driver = NULL;
302 return COMPONENT_ERROR;
305 driver = ( GG_Drv_t * )ctx->pVTable;
307 if(driver->Task == NULL)
309 return COMPONENT_ERROR;
312 return driver->Task( ctx, vm_mode );
325 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
326 GG_Drv_t *driver = NULL;
330 return COMPONENT_ERROR;
333 driver = ( GG_Drv_t * )ctx->pVTable;
335 if(driver->Reset == NULL)
337 return COMPONENT_ERROR;
340 return driver->Reset( ctx );
352 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
353 GG_Drv_t *driver = NULL;
357 return COMPONENT_ERROR;
360 driver = ( GG_Drv_t * )ctx->pVTable;
362 if(driver->Stop == NULL)
364 return COMPONENT_ERROR;
367 return driver->Stop( ctx );
380 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
381 GG_Drv_t *driver = NULL;
385 return COMPONENT_ERROR;
388 driver = ( GG_Drv_t * )ctx->pVTable;
390 if(driver->GetOCV == NULL)
392 return COMPONENT_ERROR;
395 return driver->GetOCV( ctx, ocv);
408 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
409 GG_Drv_t *driver = NULL;
413 return COMPONENT_ERROR;
416 driver = ( GG_Drv_t * )ctx->pVTable;
418 if(driver->GetSOC == NULL)
420 return COMPONENT_ERROR;
423 return driver->GetSOC( ctx, soc);
436 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
437 GG_Drv_t *driver = NULL;
441 return COMPONENT_ERROR;
444 driver = ( GG_Drv_t * )ctx->pVTable;
446 if(driver->GetChargeValue == NULL)
448 return COMPONENT_ERROR;
451 return driver->GetChargeValue( ctx, chrgValue);
464 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
465 GG_Drv_t *driver = NULL;
469 return COMPONENT_ERROR;
472 driver = ( GG_Drv_t * )ctx->pVTable;
474 if(driver->GetPresence == NULL)
476 return COMPONENT_ERROR;
479 return driver->GetPresence( ctx, presence);
492 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
493 GG_Drv_t *driver = NULL;
497 return COMPONENT_ERROR;
500 driver = ( GG_Drv_t * )ctx->pVTable;
502 if(driver->GetCurrent == NULL)
504 return COMPONENT_ERROR;
507 return driver->GetCurrent( ctx, current);
520 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
521 GG_Drv_t *driver = NULL;
525 return COMPONENT_ERROR;
528 driver = ( GG_Drv_t * )ctx->pVTable;
530 if(driver->GetVoltage == NULL)
532 return COMPONENT_ERROR;
535 return driver->GetVoltage( ctx, voltage);
548 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
549 GG_Drv_t *driver = NULL;
553 return COMPONENT_ERROR;
556 driver = ( GG_Drv_t * )ctx->pVTable;
558 if(driver->GetTemperature == NULL)
560 return COMPONENT_ERROR;
563 return driver->GetTemperature( ctx, temp);
575 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
576 GG_Drv_t *driver = NULL;
580 return COMPONENT_ERROR;
583 driver = ( GG_Drv_t * )ctx->pVTable;
585 if(driver->GetRemTime == NULL)
587 return COMPONENT_ERROR;
590 return driver->GetRemTime( ctx, remTime);
DrvStatusTypeDef BSP_GG_GetSOC(void *handle, uint32_t *soc)
Get the SOC.
DrvStatusTypeDef BSP_GG_Stop(void *handle)
Stop the gas gauge system.
DrvStatusTypeDef BSP_GG_GetPresence(void *handle, uint32_t *presence)
Get the presence.
DrvStatusTypeDef BSP_GG_IsInitialized(void *handle, uint8_t *status)
Check if the gas gauge sensor is initialized.
DrvStatusTypeDef BSP_GG_Get_WhoAmI(void *handle, uint8_t *who_am_i)
Get the WHO_AM_I ID of the gas gauge sensor.
DrvStatusTypeDef BSP_GG_GetRemTime(void *handle, int32_t *remTime)
Get the estimated remaining time.
This file contains definitions for SensorTile_gg.c firmware driver.
DrvStatusTypeDef BSP_GG_IsCombo(void *handle, uint8_t *status)
Check if the gas gauge sensor is combo.
DrvStatusTypeDef BSP_GG_GetChargeValue(void *handle, uint32_t *chrgValue)
Get the charge value.
DrvStatusTypeDef BSP_GG_GetCurrent(void *handle, int32_t *current)
Get the current.
DrvStatusTypeDef BSP_GG_Task(void *handle, uint8_t *vm_mode)
Task to read periodically data of STC3115.
DrvStatusTypeDef BSP_GG_GetVoltage(void *handle, uint32_t *voltage)
Get the voltage.
DrvStatusTypeDef BSP_GG_Init(void **handle)
Set GG Initialization.
DrvStatusTypeDef BSP_GG_GetOCV(void *handle, uint32_t *ocv)
Get the OCV.
DrvStatusTypeDef Sensor_IO_I2C_Init(void)
Configures sensor SPI interface.
DrvStatusTypeDef BSP_GG_GetTemperature(void *handle, int32_t *temp)
Get the temperature.
DrvStatusTypeDef BSP_GG_DeInit(void **handle)
Deinitialize a gas gauge sensor.
DrvStatusTypeDef BSP_GG_Reset(void *handle)
Reboot memory content of GG.