Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board

Driver File for LTC3335: Nanopower Buck-Boost DC/DC with Integrated Coulomb Counter. More...

Detailed Description

Driver File for LTC3335: Nanopower Buck-Boost DC/DC with Integrated Coulomb Counter.

Definition in file LTC3335.cpp.

Go to the source code of this file.

Functions

static int8_t ltc3335_set_register (uint8_t subaddress, uint8_t *ltc3335_data)
 
static int8_t ltc3335_get_register (uint8_t subaddress, uint8_t *ltc3335_data)
 
static uint8_t ltc3335_encode_register_a (boolean enabled, LTC3335_OUTPUT_VOLTAGE_TYPE voltage, uint8_t prescaler)
 
static void ltc3335_decode_register_a (uint8_t register_a)
 
int8_t LTC3335_Init (void)
 Verify that battery capacity isn't so gigantic that it would overflow a 32 bit number. More...
 
int8_t LTC3335_Set_Voltage (boolean enabled, LTC3335_OUTPUT_VOLTAGE_TYPE voltage)
 Enables/Disables software control of the LTC3335 output voltage. More...
 
int8_t LTC3335_Get_Alarms (LTC3335_ALARM_TYPE *alarms)
 Gets the alarms active from the LTC3335. More...
 
int8_t LTC3335_Clear_Int (LTC3335_ALARM_TYPE *alarms)
 Sends the command to clear the INT condition. More...
 
int8_t LTC3335_Get_Discharged_Capacity (uint32_t *discharged_capacity)
 Gets the discharged capacity from the battery in mAs. More...
 
int8_t LTC3335_Set_Counter_Test (boolean enabled)
 Enables/Disables the LTC3335 Counter Test feature. More...
 
int8_t LTC3335_Reset_Counter_Test_Current (void)
 Resets the number of edges and the amount of time stored for the Counter Test feature. More...
 
void LTC3335_Counter_Test_Current_Task (void)
 Task that must be run periodically, for the edges and time to be stored for the LTC3335 Counter Test feature. More...
 
int8_t LTC3335_Get_Counter_Test_Current (uint16_t *microamps)
 Gets the battery current in uA. More...
 

Variables

Cached LTC3335 Data

Cached copies of values in registers, so that they do not need to be read/modified/written each time a function is called to only set a portion of that register.

static uint8_t ltc3335_subaddress_last
 last subaddress written, so that it is not repeatedly sent when the same register is polled. More...
 
static LTC3335_OUTPUT_VOLTAGE_TYPE ltc3335_voltage_selection_last
 last voltage selected through software. More...
 
static boolean ltc3335_voltage_selection_enabled_last
 last enable for software selected voltage. More...
 
static uint8_t ltc3335_prescaler_last
 last prescaler selected. More...
 
static boolean ltc3335_counter_test_last
 value of the counter test bit last written to the LTC3335. More...
 
Counter Test Variables

Variables used to count edges per second when the Counter Test feature is turned on, providing an instantaneous measurement of the battery current.

static uint16_t ltc3335_hw_timer_last
 last value of the hardware timer accessed by LTC3335 driver. More...
 
static uint16_t ltc3335_hw_counter_last
 last value of the hardware counter accessed by LTC3335 driver. More...
 
static uint32_t ltc3335_counter_test_edge_count
 the number of rising edges on the /IRQ pin since the Counter Test results were last cleared. More...
 
static uint32_t ltc3335_counter_test_time
 the amount of timer ticks since the Counter Test results were last cleared. More...
 
static uint8_t ltc3335_accumulator_last
 
static uint32_t ltc3335_quiescent_current_timer
 
static uint32_t ltc3335_discharged_capacity
 

Function Documentation

◆ LTC3335_Clear_Int()

int8_t LTC3335_Clear_Int ( LTC3335_ALARM_TYPE alarms)

Sends the command to clear the INT condition.

NOTE! Additional registers are rewritten in order for the INT condition to be reset.

Returns
0 if the LTC3335 communication was successful.

Definition at line 268 of file LTC3335.cpp.

◆ LTC3335_Counter_Test_Current_Task()

void LTC3335_Counter_Test_Current_Task ( void  )

Task that must be run periodically, for the edges and time to be stored for the LTC3335 Counter Test feature.

Returns
TRUE if the LTC3335 communication was successful.

Definition at line 409 of file LTC3335.cpp.

◆ ltc3335_decode_register_a()

static void ltc3335_decode_register_a ( uint8_t  register_a)
static

Definition at line 530 of file LTC3335.cpp.

◆ ltc3335_encode_register_a()

static uint8_t ltc3335_encode_register_a ( boolean  enabled,
LTC3335_OUTPUT_VOLTAGE_TYPE  voltage,
uint8_t  prescaler 
)
static

Definition at line 524 of file LTC3335.cpp.

◆ LTC3335_Get_Alarms()

int8_t LTC3335_Get_Alarms ( LTC3335_ALARM_TYPE alarms)

Gets the alarms active from the LTC3335.

Returns
0 if the LTC3335 communication was successful.
Parameters
alarmsBitmap containing the LTC3335 active alarms.

Definition at line 225 of file LTC3335.cpp.

◆ LTC3335_Get_Counter_Test_Current()

int8_t LTC3335_Get_Counter_Test_Current ( uint16_t *  microamps)

Gets the battery current in uA.

Returns
0 if the LTC3335 communication was successful.
Parameters
microampsPointer to where current will be returned.

Definition at line 431 of file LTC3335.cpp.

◆ LTC3335_Get_Discharged_Capacity()

int8_t LTC3335_Get_Discharged_Capacity ( uint32_t *  discharged_capacity)

Gets the discharged capacity from the battery in mAs.

Returns
0 if the LTC3335 communication was successful.
Parameters
discharged_capacityPointer to where discharged capacity will be returned.

Definition at line 306 of file LTC3335.cpp.

◆ ltc3335_get_register()

static int8_t ltc3335_get_register ( uint8_t  subaddress,
uint8_t *  ltc3335_data 
)
static

Definition at line 511 of file LTC3335.cpp.

◆ LTC3335_Init()

int8_t LTC3335_Init ( void  )

Verify that battery capacity isn't so gigantic that it would overflow a 32 bit number.

Verify that capacity resolution isn't so tiny that half bits in units of mAs result in 1% discretization error. Initializes the LTC3335 driver, setting the prescaler, output voltage, and alarm threshold selected in LTC3335_Confg.h

Returns
0 if the init was successful.

Definition at line 162 of file LTC3335.cpp.

◆ LTC3335_Reset_Counter_Test_Current()

int8_t LTC3335_Reset_Counter_Test_Current ( void  )

Resets the number of edges and the amount of time stored for the Counter Test feature.

Returns
TRUE if the LTC3335 communication was successful.

Definition at line 396 of file LTC3335.cpp.

◆ LTC3335_Set_Counter_Test()

int8_t LTC3335_Set_Counter_Test ( boolean  enabled)

Enables/Disables the LTC3335 Counter Test feature.

Returns
0 if the LTC3335 communication was successful.
Parameters
enabledTRUE to enable Counter Test feature, FALSE to disable Counter Test feature.

Definition at line 360 of file LTC3335.cpp.

◆ ltc3335_set_register()

static int8_t ltc3335_set_register ( uint8_t  subaddress,
uint8_t *  ltc3335_data 
)
static

Definition at line 503 of file LTC3335.cpp.

◆ LTC3335_Set_Voltage()

int8_t LTC3335_Set_Voltage ( boolean  enabled,
LTC3335_OUTPUT_VOLTAGE_TYPE  voltage 
)

Enables/Disables software control of the LTC3335 output voltage.

If software control is enabled, the voltage is set to the specified setting.

Returns
0 if the LTC3335 communication was successful.
Parameters
enabledTRUE to enable software control of output voltage, FALSE to disable software control (output voltage set by pins 3-5).
voltageThe output voltage setting if software control is enabled.

Definition at line 206 of file LTC3335.cpp.

Variable Documentation

◆ ltc3335_accumulator_last

uint8_t ltc3335_accumulator_last
static

Definition at line 142 of file LTC3335.cpp.

◆ ltc3335_counter_test_edge_count

uint32_t ltc3335_counter_test_edge_count
static

the number of rising edges on the /IRQ pin since the Counter Test results were last cleared.

Definition at line 134 of file LTC3335.cpp.

◆ ltc3335_counter_test_last

boolean ltc3335_counter_test_last
static

value of the counter test bit last written to the LTC3335.

Definition at line 126 of file LTC3335.cpp.

◆ ltc3335_counter_test_time

uint32_t ltc3335_counter_test_time
static

the amount of timer ticks since the Counter Test results were last cleared.

Definition at line 135 of file LTC3335.cpp.

◆ ltc3335_discharged_capacity

uint32_t ltc3335_discharged_capacity
static

Definition at line 144 of file LTC3335.cpp.

◆ ltc3335_hw_counter_last

uint16_t ltc3335_hw_counter_last
static

last value of the hardware counter accessed by LTC3335 driver.

Definition at line 133 of file LTC3335.cpp.

◆ ltc3335_hw_timer_last

uint16_t ltc3335_hw_timer_last
static

last value of the hardware timer accessed by LTC3335 driver.

Definition at line 132 of file LTC3335.cpp.

◆ ltc3335_prescaler_last

uint8_t ltc3335_prescaler_last
static

last prescaler selected.

Definition at line 125 of file LTC3335.cpp.

◆ ltc3335_quiescent_current_timer

uint32_t ltc3335_quiescent_current_timer
static

Definition at line 143 of file LTC3335.cpp.

◆ ltc3335_subaddress_last

uint8_t ltc3335_subaddress_last
static

last subaddress written, so that it is not repeatedly sent when the same register is polled.

Definition at line 122 of file LTC3335.cpp.

◆ ltc3335_voltage_selection_enabled_last

boolean ltc3335_voltage_selection_enabled_last
static

last enable for software selected voltage.

Definition at line 124 of file LTC3335.cpp.

◆ ltc3335_voltage_selection_last

LTC3335_OUTPUT_VOLTAGE_TYPE ltc3335_voltage_selection_last
static

last voltage selected through software.

Definition at line 123 of file LTC3335.cpp.