SRD Standelone programmation box: BQ27510DRZRG2.h File Reference

| SRD Standelone programmation box 2.0 (16/11/15 10:00:00) Documentation of the SRD standelone programmation box

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Enumerator Macros Pages
Data Structures | Macros | Functions | Variables
BQ27510DRZRG2.h File Reference

Headerfile for Battery Management BQ27510DRZR-G2 driver. More...

`#include "i2c0.h"`
Include dependency graph for BQ27510DRZRG2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | tBQBatteryStatus
| Struct used to store informations about the cell monitoring. More...

## Macros

#define | BQ_I2C_BAUDRATE (100000UL)
| Define the I2C baudrate use tocommunicate with the BQ device. More...
#define | BQ_DEVICE_ADDRESS (0x55)
| Define the I2C BQ address. More...
#define | BQ_AT_RATE_CMD (0x02)
| Define the command of the BQ device. More...
#define | BQ_AT_RATE_TIME_TO_EMPTY_CMD (0x04)
| Define the command of the BQ device. More...
#define | BQ_TEMPERATURE_CMD (0x06)
| Define the command of the BQ device. More...
#define | BQ_VOLTAGE_CMD (0x08)
| Define the command of the BQ device. More...
#define | BQ_FLAGS_CMD (0x0A)
| Define the command of the BQ device. More...
#define | BQ_NOMI_AVAILABLE_CAPACITY_CMD (0x0C)
| Define the command of the BQ device. More...
#define | BQ_FULL_AVAILABLE_CAPACITY_CMD (0x0E)
| Define the command of the BQ device. More...
#define | BQ_REMAINING_CAPACITY_CMD (0x10)
| Define the command of the BQ device. More...
#define | BQ_FULL_CHARGE_CAPACITY_CMD (0x12)
| Define the command of the BQ device. More...
#define | BQ_AVERAGE_CURRENT_CMD (0x14)
| Define the command of the BQ device. More...
#define | BQ_TIME_TO_EMPTY_CMD (0x16)
| Define the command of the BQ device. More...
#define | BQ_TIME_TO_FULL_CMD (0x18)
| Define the command of the BQ device. More...
#define | BQ_STANDBY_CURRENT_CMD (0x1A)
| Define the command of the BQ device. More...
#define | BQ_STANDBY_TIME_TO_EMPTY_CMD (0x1C)
| Define the command of the BQ device. More...
#define | BQ_MAX_LOAD_CURRENT_CMD (0x1E)
| Define the command of the BQ device. More...
#define | BQ_MAX_LOAD_TIME_TO_EMPTY_CMD (0x20)
| Define the command of the BQ device. More...
#define | BQ_AVAILABLE_ENERGY_CMD (0x22)
| Define the command of the BQ device. More...
#define | BQ_AVERAGE_POWER_CMD (0x24)
| Define the command of the BQ device. More...
#define | BQ_TTEAT_CONSTANT_POWER_CMD (0x26)
| Define the command of the BQ device. More...
#define | BQ_CYCLE_COUNTE_CMD (0x2A)
| Define the command of the BQ device. More...
#define | BQ_STATE_OF_CHARGE_CMD (0x2C)
| Define the command of the BQ device. More...

## Functions

void | BQ27510DRZRG2_Init (void)
| Function used to initialize the BQ device and it's DSP peripheral. More...
signed short | BQ_batteryIsConnected (void)
| Function used to know if a battery is connected or not. More...
signed short | BQ_getFullInfo (void)
| Function used to get all information about the cell monitoring. More...
signed short | BQ_getCellTemperature (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getCellVoltage (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getNominalAvailableCapacity (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getFullAvailableCapacity (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getRemainingCapacity (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getFullChargeCapacity (void)
| Function used to get some information about the cell monitoring. More...
signed short | BQ_getAverageCurrent (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getTimeToEmpty (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getTimeToFull (void)
| Function used to get some information about the cell monitoring. More...
signed short | BQ_getStandbyCurrent (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getStandbyTimeToEmpty (void)
| Function used to get some information about the cell monitoring. More...
signed short | BQ_getMaxLoadCurrent (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getMaxLoadTimeToEmpty (void)
| Function used to get some information about the cell monitoring. More...
unsigned long | BQ_getAvailableEnergy (void)
| Function used to get some information about the cell monitoring. More...
signed short | BQ_getAveragePower (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getTTEAtConstantPower (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getCycleCount (void)
| Function used to get some information about the cell monitoring. More...
unsigned short | BQ_getStateOfCharge (void)
| Function used to get some information about the cell monitoring. More...

## Variables

tBQBatteryStatus | BQBatteryStatus
| Variable used to store informations about the cell monitoring. More...

## Detailed Description

Headerfile for Battery Management BQ27510DRZR-G2 driver.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  12/11/2014

Version
  1.0

All Right Reserved.

Definition in file BQ27510DRZRG2.h.

## Macro Definition Documentation

#define BQ_AT_RATE_CMD (0x02)

Define the command of the BQ device.

Definition at line 50 of file BQ27510DRZRG2.h.

#define BQ_AT_RATE_TIME_TO_EMPTY_CMD (0x04)

Define the command of the BQ device.

Definition at line 51 of file BQ27510DRZRG2.h.

#define BQ_AVAILABLE_ENERGY_CMD (0x22)

Define the command of the BQ device.

Definition at line 66 of file BQ27510DRZRG2.h.

Referenced by BQ_getAvailableEnergy().

#define BQ_AVERAGE_CURRENT_CMD (0x14)

Define the command of the BQ device.

Definition at line 59 of file BQ27510DRZRG2.h.

Referenced by BQ_getAverageCurrent().

#define BQ_AVERAGE_POWER_CMD (0x24)

Define the command of the BQ device.

Definition at line 67 of file BQ27510DRZRG2.h.

Referenced by BQ_getAveragePower().

#define BQ_CYCLE_COUNTE_CMD (0x2A)

Define the command of the BQ device.

Definition at line 69 of file BQ27510DRZRG2.h.

Referenced by BQ_getCycleCount().

#define BQ_DEVICE_ADDRESS (0x55)

Define the I2C BQ address.

Definition at line 42 of file BQ27510DRZRG2.h.

Referenced by BQ_batteryIsConnected(), BQ_getAvailableEnergy(), BQ_getAverageCurrent(), BQ_getAveragePower(), BQ_getCellTemperature(), BQ_getCellVoltage(), BQ_getCycleCount(), BQ_getFullAvailableCapacity(), BQ_getFullChargeCapacity(), BQ_getMaxLoadCurrent(), BQ_getMaxLoadTimeToEmpty(), BQ_getNominalAvailableCapacity(), BQ_getRemainingCapacity(), BQ_getStandbyCurrent(), BQ_getStandbyTimeToEmpty(), BQ_getStateOfCharge(), BQ_getTimeToEmpty(), BQ_getTimeToFull(), and BQ_getTTEAtConstantPower().

#define BQ_FLAGS_CMD (0x0A)

Define the command of the BQ device.

Definition at line 54 of file BQ27510DRZRG2.h.

#define BQ_FULL_AVAILABLE_CAPACITY_CMD (0x0E)

Define the command of the BQ device.

Definition at line 56 of file BQ27510DRZRG2.h.

Referenced by BQ_getFullAvailableCapacity().

#define BQ_FULL_CHARGE_CAPACITY_CMD (0x12)

Define the command of the BQ device.

Definition at line 58 of file BQ27510DRZRG2.h.

Referenced by BQ_getFullChargeCapacity().

#define BQ_I2C_BAUDRATE (100000UL)

Define the I2C baudrate use tocommunicate with the BQ device.

Definition at line 34 of file BQ27510DRZRG2.h.

#define BQ_MAX_LOAD_CURRENT_CMD (0x1E)

Define the command of the BQ device.

Definition at line 64 of file BQ27510DRZRG2.h.

Referenced by BQ_getMaxLoadCurrent().

#define BQ_MAX_LOAD_TIME_TO_EMPTY_CMD (0x20)

Define the command of the BQ device.

Definition at line 65 of file BQ27510DRZRG2.h.

Referenced by BQ_getMaxLoadTimeToEmpty().

#define BQ_NOMI_AVAILABLE_CAPACITY_CMD (0x0C)

Define the command of the BQ device.

Definition at line 55 of file BQ27510DRZRG2.h.

Referenced by BQ_getNominalAvailableCapacity().

#define BQ_REMAINING_CAPACITY_CMD (0x10)

Define the command of the BQ device.

Definition at line 57 of file BQ27510DRZRG2.h.

Referenced by BQ_getRemainingCapacity().

#define BQ_STANDBY_CURRENT_CMD (0x1A)

Define the command of the BQ device.

Definition at line 62 of file BQ27510DRZRG2.h.

Referenced by BQ_getStandbyCurrent().

#define BQ_STANDBY_TIME_TO_EMPTY_CMD (0x1C)

Define the command of the BQ device.

Definition at line 63 of file BQ27510DRZRG2.h.

Referenced by BQ_getStandbyTimeToEmpty().

#define BQ_STATE_OF_CHARGE_CMD (0x2C)

Define the command of the BQ device.

Definition at line 70 of file BQ27510DRZRG2.h.

Referenced by BQ_getStateOfCharge().

#define BQ_TEMPERATURE_CMD (0x06)

Define the command of the BQ device.

Definition at line 52 of file BQ27510DRZRG2.h.

Referenced by BQ_getCellTemperature().

#define BQ_TIME_TO_EMPTY_CMD (0x16)

Define the command of the BQ device.

Definition at line 60 of file BQ27510DRZRG2.h.

Referenced by BQ_getTimeToEmpty().

#define BQ_TIME_TO_FULL_CMD (0x18)

Define the command of the BQ device.

Definition at line 61 of file BQ27510DRZRG2.h.

Referenced by BQ_getTimeToFull().

#define BQ_TTEAT_CONSTANT_POWER_CMD (0x26)

Define the command of the BQ device.

Definition at line 68 of file BQ27510DRZRG2.h.

Referenced by BQ_getTTEAtConstantPower().

#define BQ_VOLTAGE_CMD (0x08)

Define the command of the BQ device.

Definition at line 53 of file BQ27510DRZRG2.h.

Referenced by BQ_getCellVoltage().

## Function Documentation

void BQ27510DRZRG2_Init | ( | void |  | ) |

Function used to initialize the BQ device and it's DSP peripheral.

Definition at line 79 of file BQ27510DRZRG2.c.

References I2C0Enable, and I2C0Init().

Referenced by PowerManagerInit().

79 {
80
81 I2C0Init(); //Init I2C
82 I2C0Enable(); //Enable I2C
83 }
I2C0Init
void I2C0Init(void)
Initialized the I2C0 module with the defined parameters.
Definition: i2c0.c:95
I2C0Enable
#define I2C0Enable()
Set/Clear/Read the enable status of the I2C0 module.
Definition: i2c0.h:124

Here is the call graph for this function:

Here is the caller graph for this function:

signed short BQ_batteryIsConnected | ( | void |  | ) |

Function used to know if a battery is connected or not.

Definition at line 85 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, and I2C0Send().

Referenced by BQ_getFullInfo().

85 {
86 unsigned char data; //Dummy
87 signed char result = I2C0Send(BQ_DEVICE_ADDRESS,&data,0);
88 return result; //Return 0 if battery is connected else return -1
89 }
I2C0Send
signed char I2C0Send(unsigned char address, unsigned char *data, unsigned char dataLength)
Send a packet on the I2C interface.
Definition: i2c0.c:131
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long BQ_getAvailableEnergy | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 341 of file BQ27510DRZRG2.c.

References BQ_AVAILABLE_ENERGY_CMD, BQ_DEVICE_ADDRESS, and I2C0Read().

Referenced by BQ_getFullInfo().

341 {
342 signed char result = 0;
343 unsigned char data[2] = {0};
344 unsigned char command;
345
346 command = BQ_AVAILABLE_ENERGY_CMD;
347
348 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
349
350 if (result == -1) {
351 return 0; //Error
352 } else {
353
354 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
355
356 return value*10;
357 }
358 }
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_AVAILABLE_ENERGY_CMD
#define BQ_AVAILABLE_ENERGY_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:66
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

signed short BQ_getAverageCurrent | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 208 of file BQ27510DRZRG2.c.

References BQ_AVERAGE_CURRENT_CMD, BQ_DEVICE_ADDRESS, and I2C0Read().

Referenced by BQ_getFullInfo().

208 {
209 signed char result = 0;
210 unsigned char data[2] = {0};
211 unsigned char command;
212
213 command = BQ_AVERAGE_CURRENT_CMD;
214
215 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
216
217 if (result == -1) {
218 return 0; //Error
219 } else {
220
221 signed short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
222
223 return value;
224 }
225 }
BQ_AVERAGE_CURRENT_CMD
#define BQ_AVERAGE_CURRENT_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:59
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

signed short BQ_getAveragePower | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 360 of file BQ27510DRZRG2.c.

References BQ_AVERAGE_POWER_CMD, BQ_DEVICE_ADDRESS, and I2C0Read().

Referenced by BQ_getFullInfo().

360 {
361 signed char result = 0;
362 unsigned char data[2] = {0};
363 unsigned char command;
364
365 command = BQ_AVERAGE_POWER_CMD;
366
367 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
368
369 if (result == -1) {
370 return 0; //Error
371 } else {
372
373 signed short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
374
375 return value;
376 }
377 }
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_AVERAGE_POWER_CMD
#define BQ_AVERAGE_POWER_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:67
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

signed short BQ_getCellTemperature | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 92 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_TEMPERATURE_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

92 {
93 signed char result = 0;
94 unsigned char data[2] = {0};
95 unsigned char command;
96
97 command = BQ_TEMPERATURE_CMD;
98
99 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
100
101 if (result == -1) {
102 return -273; //Error
103 } else {
104 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
105 return (value/10) - 273; //Convert °K to °C
106 }
107 }
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_TEMPERATURE_CMD
#define BQ_TEMPERATURE_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:52
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getCellVoltage | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 110 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_VOLTAGE_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

110 {
111
112 signed char result = 0;
113 unsigned char data[2] = {0};
114 unsigned char command;
115
116 command = BQ_VOLTAGE_CMD;
117
118 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
119
120 if (result == -1) {
121 return 0; //Error
122 } else {
123
124 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
125
126 return value;
127 }
128 }
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_VOLTAGE_CMD
#define BQ_VOLTAGE_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:53
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getCycleCount | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 398 of file BQ27510DRZRG2.c.

References BQ_CYCLE_COUNTE_CMD, BQ_DEVICE_ADDRESS, and I2C0Read().

Referenced by BQ_getFullInfo().

398 {
399 signed char result = 0;
400 unsigned char data[2] = {0};
401 unsigned char command;
402
403 command = BQ_CYCLE_COUNTE_CMD;
404
405 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
406
407 if (result == -1) {
408 return 0; //Error
409 } else {
410
411 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
412
413 return value;
414 }
415 }
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_CYCLE_COUNTE_CMD
#define BQ_CYCLE_COUNTE_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:69
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getFullAvailableCapacity | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 150 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_FULL_AVAILABLE_CAPACITY_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

150 {
151 signed char result = 0;
152 unsigned char data[2] = {0};
153 unsigned char command;
154
155 command = BQ_FULL_AVAILABLE_CAPACITY_CMD;
156
157 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
158
159 if (result == -1) {
160 return 0; //Error
161 } else {
162
163 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
164
165 return value;
166 }
167 }
BQ_FULL_AVAILABLE_CAPACITY_CMD
#define BQ_FULL_AVAILABLE_CAPACITY_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:56
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getFullChargeCapacity | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 189 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_FULL_CHARGE_CAPACITY_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

189 {
190 signed char result = 0;
191 unsigned char data[2] = {0};
192 unsigned char command;
193
194 command = BQ_FULL_CHARGE_CAPACITY_CMD;
195
196 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
197
198 if (result == -1) {
199 return 0; //Error
200 } else {
201
202 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
203
204 return value;
205 }
206 }
BQ_FULL_CHARGE_CAPACITY_CMD
#define BQ_FULL_CHARGE_CAPACITY_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:58
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

signed short BQ_getFullInfo | ( | void |  | ) |

Function used to get all information about the cell monitoring.

Returns
  (signed short) : 0 if all data are correctly read, else return -1.

the result are stored in the BQBatteryStatus variable. an error can be returned if the battery is not connected.

Definition at line 434 of file BQ27510DRZRG2.c.

References tBQBatteryStatus::availableEnergy, tBQBatteryStatus::averageCurrent, tBQBatteryStatus::averagePower, BQ_batteryIsConnected(), BQ_getAvailableEnergy(), BQ_getAverageCurrent(), BQ_getAveragePower(), BQ_getCellTemperature(), BQ_getCellVoltage(), BQ_getCycleCount(), BQ_getFullAvailableCapacity(), BQ_getFullChargeCapacity(), BQ_getMaxLoadCurrent(), BQ_getMaxLoadTimeToEmpty(), BQ_getNominalAvailableCapacity(), BQ_getRemainingCapacity(), BQ_getStandbyTimeToEmpty(), BQ_getStateOfCharge(), BQ_getTimeToEmpty(), BQ_getTimeToFull(), BQ_getTTEAtConstantPower(), tBQBatteryStatus::cellTemperature, tBQBatteryStatus::cellVoltage, tBQBatteryStatus::cycleCount, tBQBatteryStatus::fullCapacity, tBQBatteryStatus::maxLoadCurrent, tBQBatteryStatus::maxLoadTimeToEmpty, tBQBatteryStatus::noLoadFullCapacity, tBQBatteryStatus::noLoadNominalCapacity, tBQBatteryStatus::remainingCapacity, tBQBatteryStatus::standbyCurrent, tBQBatteryStatus::standbyTimeToEmpty, tBQBatteryStatus::stateOfCharge, tBQBatteryStatus::timeToEmpty, tBQBatteryStatus::timeToEmptyAtConstantPower, and tBQBatteryStatus::timeToFull.

Referenced by PowerManager().

434 {
435
436 if(BQ_batteryIsConnected() == 0) {
437
438 BQBatteryStatus.cellTemperature = BQ_getCellTemperature();
439 BQBatteryStatus.cellVoltage = BQ_getCellVoltage();
440 BQBatteryStatus.noLoadNominalCapacity = BQ_getNominalAvailableCapacity();
441 BQBatteryStatus.noLoadFullCapacity = BQ_getFullAvailableCapacity();
442 BQBatteryStatus.remainingCapacity = BQ_getRemainingCapacity();
443 BQBatteryStatus.fullCapacity = BQ_getFullChargeCapacity();
444 BQBatteryStatus.averageCurrent = BQ_getAverageCurrent();
445 BQBatteryStatus.timeToEmpty = BQ_getTimeToEmpty();
446 BQBatteryStatus.timeToFull = BQ_getTimeToFull();
447 BQBatteryStatus.standbyCurrent = BQ_getTimeToFull();
448 BQBatteryStatus.standbyTimeToEmpty = BQ_getStandbyTimeToEmpty();
449 BQBatteryStatus.maxLoadCurrent = BQ_getMaxLoadCurrent();
450 BQBatteryStatus.maxLoadTimeToEmpty = BQ_getMaxLoadTimeToEmpty();
451 BQBatteryStatus.availableEnergy = BQ_getAvailableEnergy();
452 BQBatteryStatus.averagePower = BQ_getAveragePower();
453 BQBatteryStatus.timeToEmptyAtConstantPower = BQ_getTTEAtConstantPower();
454 BQBatteryStatus.cycleCount = BQ_getCycleCount();
455 BQBatteryStatus.stateOfCharge = BQ_getStateOfCharge();
456
457 return 0;
458
459 } else {
460
461 //No battery detected
462 BQBatteryStatus.cellTemperature = 0;
463 BQBatteryStatus.cellVoltage = 0;
464 BQBatteryStatus.noLoadNominalCapacity = 0;
465 BQBatteryStatus.noLoadFullCapacity = 0;
466 BQBatteryStatus.remainingCapacity = 0;
467 BQBatteryStatus.fullCapacity = 0;
468 BQBatteryStatus.averageCurrent = 0;
469 BQBatteryStatus.timeToEmpty = 0;
470 BQBatteryStatus.timeToFull = 0;
471 BQBatteryStatus.standbyCurrent = 0;
472 BQBatteryStatus.standbyTimeToEmpty = 0;
473 BQBatteryStatus.maxLoadCurrent = 0;
474 BQBatteryStatus.maxLoadTimeToEmpty = 0;
475 BQBatteryStatus.availableEnergy = 0;
476 BQBatteryStatus.averagePower = 0;
477 BQBatteryStatus.timeToEmptyAtConstantPower = 0;
478 BQBatteryStatus.cycleCount = 0;
479 BQBatteryStatus.stateOfCharge = 0;
480
481 return -1;
482 }
483 }
tBQBatteryStatus::remainingCapacity
unsigned short remainingCapacity
Definition: BQ27510DRZRG2.h:94
BQ_getTTEAtConstantPower
unsigned short BQ_getTTEAtConstantPower(void)
Definition: BQ27510DRZRG2.c:379
tBQBatteryStatus::cycleCount
unsigned short cycleCount
Definition: BQ27510DRZRG2.h:106
BQ_getMaxLoadCurrent
signed short BQ_getMaxLoadCurrent(void)
Definition: BQ27510DRZRG2.c:303
tBQBatteryStatus::maxLoadTimeToEmpty
unsigned short maxLoadTimeToEmpty
Definition: BQ27510DRZRG2.h:102
BQ_getCellTemperature
signed short BQ_getCellTemperature(void)
Function used to get some information about the cell monitoring.
Definition: BQ27510DRZRG2.c:92
tBQBatteryStatus::timeToEmptyAtConstantPower
unsigned short timeToEmptyAtConstantPower
Definition: BQ27510DRZRG2.h:105
tBQBatteryStatus::averagePower
signed short averagePower
Definition: BQ27510DRZRG2.h:104
tBQBatteryStatus::averageCurrent
signed short averageCurrent
Definition: BQ27510DRZRG2.h:96
tBQBatteryStatus::timeToFull
unsigned short timeToFull
Definition: BQ27510DRZRG2.h:98
tBQBatteryStatus::noLoadFullCapacity
unsigned short noLoadFullCapacity
Definition: BQ27510DRZRG2.h:93
tBQBatteryStatus::fullCapacity
unsigned short fullCapacity
Definition: BQ27510DRZRG2.h:95
BQ_batteryIsConnected
signed short BQ_batteryIsConnected(void)
Function used to know if a battery is connected or not.
Definition: BQ27510DRZRG2.c:85
BQ_getRemainingCapacity
unsigned short BQ_getRemainingCapacity(void)
Definition: BQ27510DRZRG2.c:170
tBQBatteryStatus::cellTemperature
signed short cellTemperature
Definition: BQ27510DRZRG2.h:90
BQ_getStateOfCharge
unsigned short BQ_getStateOfCharge(void)
Definition: BQ27510DRZRG2.c:417
BQ_getNominalAvailableCapacity
unsigned short BQ_getNominalAvailableCapacity(void)
Definition: BQ27510DRZRG2.c:130
tBQBatteryStatus::availableEnergy
unsigned long availableEnergy
Definition: BQ27510DRZRG2.h:103
BQ_getTimeToFull
unsigned short BQ_getTimeToFull(void)
Definition: BQ27510DRZRG2.c:246
BQ_getCycleCount
unsigned short BQ_getCycleCount(void)
Definition: BQ27510DRZRG2.c:398
BQ_getTimeToEmpty
unsigned short BQ_getTimeToEmpty(void)
Definition: BQ27510DRZRG2.c:227
BQ_getAvailableEnergy
unsigned long BQ_getAvailableEnergy(void)
Definition: BQ27510DRZRG2.c:341
BQBatteryStatus
tBQBatteryStatus BQBatteryStatus
Variable used to store informations about the cell monitoring.
Definition: BQ27510DRZRG2.c:61
tBQBatteryStatus::maxLoadCurrent
signed short maxLoadCurrent
Definition: BQ27510DRZRG2.h:101
BQ_getStandbyTimeToEmpty
unsigned short BQ_getStandbyTimeToEmpty(void)
Definition: BQ27510DRZRG2.c:284
tBQBatteryStatus::stateOfCharge
unsigned short stateOfCharge
Definition: BQ27510DRZRG2.h:107
BQ_getMaxLoadTimeToEmpty
unsigned short BQ_getMaxLoadTimeToEmpty(void)
Definition: BQ27510DRZRG2.c:322
tBQBatteryStatus::standbyTimeToEmpty
unsigned short standbyTimeToEmpty
Definition: BQ27510DRZRG2.h:100
BQ_getFullChargeCapacity
unsigned short BQ_getFullChargeCapacity(void)
Definition: BQ27510DRZRG2.c:189
BQ_getCellVoltage
unsigned short BQ_getCellVoltage(void)
Definition: BQ27510DRZRG2.c:110
BQ_getAveragePower
signed short BQ_getAveragePower(void)
Definition: BQ27510DRZRG2.c:360
BQ_getFullAvailableCapacity
unsigned short BQ_getFullAvailableCapacity(void)
Definition: BQ27510DRZRG2.c:150
tBQBatteryStatus::standbyCurrent
signed short standbyCurrent
Definition: BQ27510DRZRG2.h:99
tBQBatteryStatus::noLoadNominalCapacity
unsigned short noLoadNominalCapacity
Definition: BQ27510DRZRG2.h:92
tBQBatteryStatus::timeToEmpty
unsigned short timeToEmpty
Definition: BQ27510DRZRG2.h:97
tBQBatteryStatus::cellVoltage
unsigned short cellVoltage
Definition: BQ27510DRZRG2.h:91
BQ_getAverageCurrent
signed short BQ_getAverageCurrent(void)
Definition: BQ27510DRZRG2.c:208

Here is the call graph for this function:

Here is the caller graph for this function:

signed short BQ_getMaxLoadCurrent | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 303 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_MAX_LOAD_CURRENT_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

303 {
304 signed char result = 0;
305 unsigned char data[2] = {0};
306 unsigned char command;
307
308 command = BQ_MAX_LOAD_CURRENT_CMD;
309
310 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
311
312 if (result == -1) {
313 return 0; //Error
314 } else {
315
316 signed short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
317
318 return value;
319 }
320 }
BQ_MAX_LOAD_CURRENT_CMD
#define BQ_MAX_LOAD_CURRENT_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:64
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getMaxLoadTimeToEmpty | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 322 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_MAX_LOAD_TIME_TO_EMPTY_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

322 {
323 signed char result = 0;
324 unsigned char data[2] = {0};
325 unsigned char command;
326
327 command = BQ_MAX_LOAD_TIME_TO_EMPTY_CMD;
328
329 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
330
331 if (result == -1) {
332 return 0; //Error
333 } else {
334
335 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
336
337 return value;
338 }
339 }
BQ_MAX_LOAD_TIME_TO_EMPTY_CMD
#define BQ_MAX_LOAD_TIME_TO_EMPTY_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:65
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getNominalAvailableCapacity | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 130 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_NOMI_AVAILABLE_CAPACITY_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

130 {
131 signed char result = 0;
132 unsigned char data[2] = {0};
133 unsigned char command;
134
135 command = BQ_NOMI_AVAILABLE_CAPACITY_CMD;
136
137 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
138
139 if (result == -1) {
140 return 0; //Error
141 } else {
142
143 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
144
145 return value;
146 }
147 }
BQ_NOMI_AVAILABLE_CAPACITY_CMD
#define BQ_NOMI_AVAILABLE_CAPACITY_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:55
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getRemainingCapacity | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 170 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_REMAINING_CAPACITY_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

170 {
171 signed char result = 0;
172 unsigned char data[2] = {0};
173 unsigned char command;
174
175 command = BQ_REMAINING_CAPACITY_CMD;
176
177 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
178
179 if (result == -1) {
180 return 0; //Error
181 } else {
182
183 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
184
185 return value;
186 }
187 }
BQ_REMAINING_CAPACITY_CMD
#define BQ_REMAINING_CAPACITY_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:57
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

signed short BQ_getStandbyCurrent | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 265 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_STANDBY_CURRENT_CMD, and I2C0Read().

265 {
266 signed char result = 0;
267 unsigned char data[2] = {0};
268 unsigned char command;
269
270 command = BQ_STANDBY_CURRENT_CMD;
271
272 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
273
274 if (result == -1) {
275 return 0; //Error
276 } else {
277
278 signed short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
279
280 return value;
281 }
282 }
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_STANDBY_CURRENT_CMD
#define BQ_STANDBY_CURRENT_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:62
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

unsigned short BQ_getStandbyTimeToEmpty | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 284 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_STANDBY_TIME_TO_EMPTY_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

284 {
285 signed char result = 0;
286 unsigned char data[2] = {0};
287 unsigned char command;
288
289 command = BQ_STANDBY_TIME_TO_EMPTY_CMD;
290
291 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
292
293 if (result == -1) {
294 return 0; //Error
295 } else {
296
297 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
298
299 return value;
300 }
301 }
BQ_STANDBY_TIME_TO_EMPTY_CMD
#define BQ_STANDBY_TIME_TO_EMPTY_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:63
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getStateOfCharge | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 417 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_STATE_OF_CHARGE_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

417 {
418 signed char result = 0;
419 unsigned char data[2] = {0};
420 unsigned char command;
421
422 command = BQ_STATE_OF_CHARGE_CMD;
423
424 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
425
426 if (result == -1) {
427 return 0; //Error
428 } else {
429 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
430 return value; //Convert °K to °C
431 }
432 }
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_STATE_OF_CHARGE_CMD
#define BQ_STATE_OF_CHARGE_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:70
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getTimeToEmpty | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 227 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_TIME_TO_EMPTY_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

227 {
228 signed char result = 0;
229 unsigned char data[2] = {0};
230 unsigned char command;
231
232 command = BQ_TIME_TO_EMPTY_CMD;
233
234 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
235
236 if (result == -1) {
237 return 0; //Error
238 } else {
239
240 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
241
242 return value;
243 }
244 }
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42
BQ_TIME_TO_EMPTY_CMD
#define BQ_TIME_TO_EMPTY_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:60

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getTimeToFull | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 246 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_TIME_TO_FULL_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

246 {
247 signed char result = 0;
248 unsigned char data[2] = {0};
249 unsigned char command;
250
251 command = BQ_TIME_TO_FULL_CMD;
252
253 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
254
255 if (result == -1) {
256 return 0; //Error
257 } else {
258
259 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
260
261 return value;
262 }
263 }
BQ_TIME_TO_FULL_CMD
#define BQ_TIME_TO_FULL_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:61
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short BQ_getTTEAtConstantPower | ( | void |  | ) |

Function used to get some information about the cell monitoring.

Definition at line 379 of file BQ27510DRZRG2.c.

References BQ_DEVICE_ADDRESS, BQ_TTEAT_CONSTANT_POWER_CMD, and I2C0Read().

Referenced by BQ_getFullInfo().

379 {
380 signed char result = 0;
381 unsigned char data[2] = {0};
382 unsigned char command;
383
384 command = BQ_TTEAT_CONSTANT_POWER_CMD;
385
386 result = I2C0Read(BQ_DEVICE_ADDRESS, &command, 1, data, 2);
387
388 if (result == -1) {
389 return 0; //Error
390 } else {
391
392 unsigned short value = (((unsigned short)data[1]) << 8 ) | ((unsigned short)data[0]);
393
394 return value;
395 }
396 }
I2C0Read
signed char I2C0Read(unsigned char address, unsigned char *preambule, unsigned char preambuleLength, unsigned char *data, unsigned char dataLength)
Read a packet on the I2C interface.
Definition: i2c0.c:183
BQ_TTEAT_CONSTANT_POWER_CMD
#define BQ_TTEAT_CONSTANT_POWER_CMD
Define the command of the BQ device.
Definition: BQ27510DRZRG2.h:68
BQ_DEVICE_ADDRESS
#define BQ_DEVICE_ADDRESS
Define the I2C BQ address.
Definition: BQ27510DRZRG2.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

## Variable Documentation

tBQBatteryStatus BQBatteryStatus

Variable used to store informations about the cell monitoring.

Definition at line 61 of file BQ27510DRZRG2.c.

Referenced by ButtonManager(), PowerManagerSendBatteryInfo(), and UsbManagerCmdDealer().