charger29 2.2.0
Loading...
Searching...
No Matches
charger29


Charger 29 Click

Charger 29 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Apr 2025.
  • Type : I2C type

Software Support

Example Description

This example demonstrates the use of the Charger 29 Click board. The application initializes the device and periodically checks the charging status. The status is displayed over the UART terminal and reflects whether the battery is charging in constant current (CC) mode, constant voltage (CV) mode, fully charged, or not charging.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Charger29

Example Key Functions

Application Init

Initializes the logger and the Charger 29 Click driver and applies default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
charger29_cfg_t charger29_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
charger29_cfg_setup( &charger29_cfg );
CHARGER29_MAP_MIKROBUS( charger29_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == charger29_init( &charger29, &charger29_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( CHARGER29_ERROR == charger29_default_cfg ( &charger29 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ CHARGER29_ERROR
Definition charger29.h:455
#define CHARGER29_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition charger29.h:395
void application_init(void)
Definition main.c:31

Application Task

Periodically reads and logs the charging status once per second.

void application_task ( void )
{
static uint8_t chg_stat = 255;
if ( CHARGER29_OK == charger29_read_status ( &charger29, &status ) )
{
if ( chg_stat != ( status.stat0 & CHARGER29_STAT0_CHG_STAT_MASK ) )
{
chg_stat = ( status.stat0 & CHARGER29_STAT0_CHG_STAT_MASK );
switch ( chg_stat )
{
{
log_printf ( &logger, " Not Charging while charging is enabled\r\n\n" );
break;
}
{
log_printf ( &logger, " Constant Current Charging\r\n\n" );
break;
}
{
log_printf ( &logger, " Constant Voltage Charging\r\n\n" );
break;
}
{
log_printf ( &logger, " Charge Done or charging is disabled\r\n\n" );
break;
}
default:
{
log_printf ( &logger, " Unknown Charging Status\r\n\n" );
break;
}
}
}
}
Delay_ms ( 1000 );
}
@ CHARGER29_OK
Definition charger29.h:454
#define CHARGER29_STAT0_CHG_STAT_CC_CHARGING
Definition charger29.h:105
#define CHARGER29_STAT0_CHG_STAT_MASK
Definition charger29.h:108
#define CHARGER29_STAT0_CHG_STAT_CV_CHARGING
Definition charger29.h:106
#define CHARGER29_STAT0_CHG_STAT_CHARGE_DONE
Definition charger29.h:107
#define CHARGER29_STAT0_CHG_STAT_NOT_CHARGING
Definition charger29.h:104
void application_task(void)
Definition main.c:67
uint8_t stat0
Definition charger29.h:409

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.