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
- charger29_cfg_setup This function initializes Click configuration structure to initial values.
void charger29_cfg_setup(charger29_cfg_t *cfg)
Charger 29 configuration object setup function.
Charger 29 Click configuration object.
Definition charger29.h:437
- charger29_init This function initializes all necessary pins and peripherals used for this Click board.
err_t charger29_init(charger29_t *ctx, charger29_cfg_t *cfg)
Charger 29 initialization function.
Charger 29 Click context object.
Definition charger29.h:420
- charger29_default_cfg This function executes a default configuration of Charger 29 Click board.
err_t charger29_default_cfg(charger29_t *ctx)
Charger 29 default configuration function.
- charger29_enable_charging This function enables charging by clearing the charging disable bit.
err_t charger29_enable_charging(charger29_t *ctx)
Charger 29 enable charging function.
- charger29_set_charging_current This function sets the charging current based on the specified value in milliamps.
err_t charger29_set_charging_current(charger29_t *ctx, uint16_t ichg)
Charger 29 set charging current function.
- charger29_read_status This function reads the status and flag registers of the Charger 29 Click board.
err_t charger29_read_status(charger29_t *ctx, charger29_status_t *status)
Charger 29 read status function.
Charger 29 Click status object.
Definition charger29.h:408
Application Init
Initializes the logger and the Charger 29 Click driver and applies default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
charger29_init( &charger29, &charger29_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
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.
{
static uint8_t chg_stat = 255;
{
{
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.