Charger 2 click
Charger 2 click is a LiPo/Li-Ion battery charger with the additional monitoring IC onboard. This Click boardâ„¢ as a whole, offers unpreceded battery charging and monitoring solution for 3.7V LiPo/Li-Ion batteries, with the capacity measurement/gas gauge function, for up to 7000 mAh.
click Product page
Click library
- Author : MikroE Team
- Date : Dec 2019.
- Type : I2C type
Software Support
We provide a library for the Charger2 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.
Library Description
This library contains API for Charger2 Click driver.
Standard key functions :
- Config Object Initialization function.
void charger2_cfg_setup ( charger2_cfg_t *cfg );
- Initialization function.
CHARGER2_RETVAL charger2_init ( charger2_t *ctx, charger2_cfg_t *cfg );
- Click Default Configuration function.
void charger2_default_cfg ( charger2_t *ctx );
Example key functions :
- This function writes one byte data to the register.
uint8_t charger2_write_reg ( charger2_t *ctx, uint8_t register_address, uint8_t transfer_data );
- This function reads the desired data from data registers and converts this data to the appropriate unit.
uint8_t charger2_read_data ( charger2_t *ctx, uint8_t data_mode, uint32_t *data_out );
- This function checks is conversion cycle for battery current, or for battery voltage and temperature, finished, and if is not, waits until one of this conversions be finished.
uint8_t charger2_check_conv_cycle( charger2_t *ctx, uint8_t conv_mode );
Examples Description
This app charges the battery.
The demo application is composed of two sections :
Application Init
Initializes device.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
Delay_ms ( 500 );
Delay_ms ( 1000 );
log_printf( &logger, "Charger 2 is initialized \r\n" );
log_printf( &logger, "------------------------------ \r\n" );
Delay_ms ( 300 );
}
#define CHARGER2_MAP_MIKROBUS(cfg, mikrobus)
Definition charger2.h:66
uint8_t charger2_write_reg(charger2_t *ctx, uint8_t register_address, uint8_t transfer_data)
Write reg function.
uint8_t charger2_reset(charger2_t *ctx, uint8_t reset_mode)
Reset function.
CHARGER2_RETVAL charger2_init(charger2_t *ctx, charger2_cfg_t *cfg)
Initialization function.
void charger2_cfg_setup(charger2_cfg_t *cfg)
Config Object Initialization function.
#define CHARGER2_REG_MODE
Definition charger2.h:92
#define CHARGER2_14_BITS_RESOLUTION
Definition charger2.h:152
#define CHARGER2_OPERATING_MODE
Definition charger2.h:157
#define CHARGER2_RESET_COUNTER_MODE
Definition charger2.h:175
#define CHARGER2_AUTO_DETECT
Definition charger2.h:150
void application_init(void)
Definition main.c:78
Click configuration structure definition.
Definition charger2.h:215
Application Task
Reads the all necessary information for the battery charging status and logs this results on UART. Repeats operation every second. The LED diodes are used to indicate the Vcc presence when this voltage is in operating range, and to show the charging status.
{
log_printf( &logger, "------------------------------ \r\n" );
Delay_ms ( 1000 );
}
uint8_t charger2_read_data(charger2_t *ctx, uint8_t data_mode, uint32_t *data_out)
Data Read function.
#define CHARGER2_SHUNT_VOLTAGE
Definition charger2.h:181
#define CHARGER2_BATTERY_CURRENT
Definition charger2.h:184
#define CHARGER2_GAS_GAUGE_CHARGE_DATA
Definition charger2.h:179
#define CHARGER2_CONV_NUMBER
Definition charger2.h:180
#define CHARGER2_BATTERY_VOLTAGE
Definition charger2.h:182
#define CHARGER2_TEMPERATURE
Definition charger2.h:183
void application_task(void)
Definition main.c:112
uint32_t battery_data
Definition main.c:31
void results_logger(charger2_t *ctx)
Definition main.c:35
The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.
Other mikroE Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.Charger2
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.