Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LTC29421 Class Reference
#include <LTC294X.h>
Public Member Functions | |
| LTC29421 (PinName, PinName, PinName, void(*interruptFunc)(void)) | |
| create LTC29421 instance based on I2C, WARNING! use setPrescAndBattCap() to set Battery Capacity | |
| LTC29421 (PinName, PinName, PinName, void(*interruptFunc)(void), float) | |
| create LTC29421 instance based on I2C, this will computer internal M prescale value and set internal max charge level | |
| void | setADCMode (int) |
| select an ADC measurement option for voltage / temperature | |
| void | setPrescaler (int) |
| select a prescaler value (not required if object initialized with battery capacity | |
| int | getPrescaler () |
| returns prescale value in integer | |
| void | configALCC (int) |
| configure the AL/CC interrupt: TODO works as Alarm only | |
| void | shutdown () |
| shutsdown the analog section of LTC2942, also used to read accumulated charge registers | |
| void | wake () |
| wakes the analog section of LTC2942 | |
| void | setPrescAndBattCap (float) |
| wakes the analog section of LTC2942 | |
| int | accumulatedChargeReg () |
| returns the 2 Byte accumulated charge register | |
| void | accumulatedChargeReg (int) |
| write into the 2 Byte accumulated charge register | |
| float | accumulatedCharge () |
| reads the accumulated charge register as a percent value computed from max battery capacity | |
| void | accumulatedCharge (float) |
| writes the accumulated charge register as a percent value computed from max battery capacity use this to initialise the battery capacity if known, or set it to 50% or set it to 100% if battery capacity reaches max | |
| void | setChargeThresholdLow (float) |
| set low battery capacity threshhold | |
| void | setChargeThresholdHigh (float) |
| set high battery capacity threshhold | |
| float | voltage () |
| obtains battery voltage at (sense-) pin if required ADC is set | |
| void | setVoltageThresholdLow (float) |
| set low battery level threshhold | |
| void | setVoltageThresholdHigh (float) |
| set high battery level threshhold | |
| float | temperature () |
| obtains IC temperature, if required ADC is set | |
| void | setTemperatureThresholdLow (float) |
| set IC temperature low threshold | |
| void | setTemperatureThresholdHigh (float) |
| set IC temperature high threshold | |
| void | readAll () |
| reads all LTC2942 register values prints on serial terminal | |
| int | alertResponse () |
| reads the status register first uses the ARA alert response protocol for SMBus to clear AL/CC pin | |
Detailed Description
LTC29421 class.
interface LTC29421 coloumb counter on i2c port with interrupt, function name (and battery capacity in Ah Amp-hour).
Example:
#include "mbed.h" #include "LTC29421.h" LTC29421 ltc(PTC9, PTC8, PTA4, &interrDOWN, 0.560); int main() { float chLevel = ltc.accumulatedCharge(); }
Definition at line 102 of file LTC294X.h.
Constructor & Destructor Documentation
| LTC29421 | ( | PinName | , |
| PinName | , | ||
| PinName | , | ||
| void(*)(void) | interruptFunc | ||
| ) |
create LTC29421 instance based on I2C, WARNING! use setPrescAndBattCap() to set Battery Capacity
- Parameters:
-
pin sda pin scl pin al/cc interrupt
| LTC29421 | ( | PinName | , |
| PinName | , | ||
| PinName | , | ||
| void(*)(void) | interruptFunc, | ||
| float | |||
| ) |
create LTC29421 instance based on I2C, this will computer internal M prescale value and set internal max charge level
- Parameters:
-
pin sda pin scl pin al/cc interrupt float battery capacity in Ah (Amp-hour)
Member Function Documentation
| float accumulatedCharge | ( | ) |
reads the accumulated charge register as a percent value computed from max battery capacity
- Returns:
- accumulated charge read as percent
Definition at line 168 of file LTC294X.cpp.
| void accumulatedCharge | ( | float | inp ) |
writes the accumulated charge register as a percent value computed from max battery capacity use this to initialise the battery capacity if known, or set it to 50% or set it to 100% if battery capacity reaches max
- Parameters:
-
accumulated charge as percent (0-100)
Definition at line 185 of file LTC294X.cpp.
| int accumulatedChargeReg | ( | ) |
returns the 2 Byte accumulated charge register
- Returns:
- accumulated charge read as 2 byte hex value
Definition at line 158 of file LTC294X.cpp.
| void accumulatedChargeReg | ( | int | inp ) |
write into the 2 Byte accumulated charge register
- Parameters:
-
accumulated charge write as 2 byte hex value
Definition at line 174 of file LTC294X.cpp.
| int alertResponse | ( | ) |
reads the status register first uses the ARA alert response protocol for SMBus to clear AL/CC pin
int resp = ic.alertResponse(); if((resp & TEMPERATURE_ALERT) == TEMPERATURE_ALERT) { }
- Returns:
- STATUS register
Definition at line 290 of file LTC294X.cpp.
| void configALCC | ( | int | modeSel ) |
configure the AL/CC interrupt: TODO works as Alarm only
- Parameters:
-
ALCC_x
Definition at line 121 of file LTC294X.cpp.
| int getPrescaler | ( | ) |
returns prescale value in integer
- Returns:
- int prescale value
Definition at line 97 of file LTC294X.cpp.
| void readAll | ( | ) |
reads all LTC2942 register values prints on serial terminal
- Parameters:
-
none
Definition at line 269 of file LTC294X.cpp.
| void setADCMode | ( | int | modeSel ) |
select an ADC measurement option for voltage / temperature
- Parameters:
-
ADC_x
Definition at line 42 of file LTC294X.cpp.
| void setChargeThresholdHigh | ( | float | prect ) |
set high battery capacity threshhold
- Parameters:
-
float percent remaining value(0-100)
Definition at line 200 of file LTC294X.cpp.
| void setChargeThresholdLow | ( | float | prect ) |
set low battery capacity threshhold
- Parameters:
-
float percent remaining value(0-100)
Definition at line 190 of file LTC294X.cpp.
| void setPrescaler | ( | int | val ) |
select a prescaler value (not required if object initialized with battery capacity
- Parameters:
-
PRESCALE_x
Definition at line 69 of file LTC294X.cpp.
| void setPrescAndBattCap | ( | float | battcap ) |
wakes the analog section of LTC2942
- Parameters:
-
none amend the battery capacity, also computers prescaler M and adjusts internal Max battery capacity battery capacity in Ah (Amp-hour)
Definition at line 26 of file LTC294X.cpp.
| void setTemperatureThresholdHigh | ( | float | inp ) |
set IC temperature high threshold
- Parameters:
-
temperauture in centigrade
Definition at line 260 of file LTC294X.cpp.
| void setTemperatureThresholdLow | ( | float | inp ) |
set IC temperature low threshold
- Parameters:
-
temperauture in centigrade
Definition at line 251 of file LTC294X.cpp.
| void setVoltageThresholdHigh | ( | float | inp ) |
set high battery level threshhold
- Parameters:
-
Voltage level in Volts
Definition at line 230 of file LTC294X.cpp.
| void setVoltageThresholdLow | ( | float | inp ) |
set low battery level threshhold
- Parameters:
-
Voltage level in Volts
Definition at line 221 of file LTC294X.cpp.
| void shutdown | ( | ) |
shutsdown the analog section of LTC2942, also used to read accumulated charge registers
- Parameters:
-
none
Definition at line 144 of file LTC294X.cpp.
| float temperature | ( | ) |
obtains IC temperature, if required ADC is set
- Returns:
- temperature in centigrade
Definition at line 240 of file LTC294X.cpp.
| float voltage | ( | ) |
obtains battery voltage at (sense-) pin if required ADC is set
- Returns:
- battery level in Volts
Definition at line 210 of file LTC294X.cpp.
| void wake | ( | ) |
Generated on Sat Jul 16 2022 08:04:36 by
1.7.2