Dear,
I used ncs_v1.0.0_joakim to adapt the battery of my thingy91:
#include <stdbool.h>
#include <string.h>
#include <zephyr.h>
#include <zephyr/types.h>
#include <drivers/adp536x.h>
//#include <adp536x.h>
#define ADP536X_I2C_DEV_NAME DT_NORDIC_NRF_I2C_I2C_2_LABEL
//#define ADP536X_I2C_DEV_NAME DT_NORDIC_NRF_TWIM_I2C_2_LABEL
#define BATTERY_CHARGE_CAPACITY 0xFF /* Maximum battery capacity. */
#define BATTERY_CHARGE_SLEEP_MODE true /* Set sleep mode. */
#define BATTERY_CHARGE_UPDATE_RATE 3 /* Sample every 16 minute. */
void battery_monitor_init(void)
{
int ret;
ret = adp536x_init(ADP536X_I2C_DEV_NAME);
//ret = adp536x_init();
// ret = adp536x_init();
if (ret) {
return;
}
ret = adp536x_bat_cap_set(BATTERY_CHARGE_CAPACITY);
if (ret) {
printk("Failed to set battery capacity.\n");
return;
}
ret = adp536x_fuel_gauge_enable_sleep_mode(BATTERY_CHARGE_SLEEP_MODE);
if (ret) {
printk("Failed to enable fuel gauge sleep mode.\n");
return;
}
ret = adp536x_fuel_gauge_update_rate_set(BATTERY_CHARGE_UPDATE_RATE);
if (ret) {
printk("Failed to set fuel gauge update rate.\n");
return;
}
ret = adp536x_fuel_gauge_set(true);
if (ret) {
printk("Failed to enable fuel gauge.\n");
return;
}
}
int battery_monitor_read(u8_t *buf)
{
return adp536x_bat_soc_read(buf);
}
I used: battery_monitor_read(); to read the %battery, and it worked well
I just updated new version of ncs_master
I found the driver of adp536x.h
#include <adp536x.h>
then, it does NOT work, too much different
Do you have any example to read the value of battery with ncs_master
Thanks,
BR
Hoang