charger 2.1.0.0
charger.h File Reference

This file contains API for Charger Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_one_wire.h"

Go to the source code of this file.

Data Structures

struct  charger_t
 Charger Click context object. More...
 
struct  charger_cfg_t
 Charger Click configuration object. More...
 

Macros

#define CHARGER_CMD_WRITE_SCRATCHPAD   0x4E
 Charger commands list.
 
#define CHARGER_CMD_READ_SCRATCHPAD   0xBE
 
#define CHARGER_CMD_COPY_SCRATCHPAD   0x48
 
#define CHARGER_CMD_RECALL_MEMORY   0xB8
 
#define CHARGER_CMD_CONVERT_T   0x44
 
#define CHARGER_CMD_CONVERT_V   0xB4
 
#define CHARGER_PAGE_0   0
 Charger memory page setting.
 
#define CHARGER_PAGE_1   1
 
#define CHARGER_PAGE_2   2
 
#define CHARGER_PAGE_3   3
 
#define CHARGER_PAGE_4   4
 
#define CHARGER_PAGE_5   5
 
#define CHARGER_PAGE_6   6
 
#define CHARGER_PAGE_7   7
 
#define CHARGER_PAGE_SIZE   8
 
#define CHARGER_CONFIG_IAD   0x01
 Charger Status/Config register setting.
 
#define CHARGER_CONFIG_CA   0x02
 
#define CHARGER_CONFIG_EE   0x04
 
#define CHARGER_CONFIG_AD   0x08
 
#define CHARGER_CONFIG_TB   0x10
 
#define CHARGER_CONFIG_NVM   0x20
 
#define CHARGER_CONFIG_ADB   0x40
 
#define CHARGER_TEMPERATURE_RES   0.03125f
 Charger measurement values.
 
#define CHARGER_VOLTAGE_RES   0.01f
 
#define CHARGER_CURRENT_RES   204.8f
 
#define CHARGER_FAMILY_CODE   0x26
 Charger family code value.
 
#define CHARGER_ADDRESS_0   0x00
 Charger address selection macros.
 
#define CHARGER_ADDRESS_ALL   0xFF
 
#define CHARGER_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  charger_gpio_sel_t { CHARGER_GPIO_OW1 , CHARGER_GPIO_OW2 }
 Charger Click gpio selector. More...
 
enum  charger_return_value_t { CHARGER_OK = 0 , CHARGER_ERROR = -1 }
 Charger Click return value data. More...
 

Functions

void charger_cfg_setup (charger_cfg_t *cfg)
 Charger configuration object setup function.
 
void charger_gpio_selection (charger_cfg_t *cfg, charger_gpio_sel_t gpio_sel)
 Charger driver interface setup function.
 
err_t charger_init (charger_t *ctx, charger_cfg_t *cfg)
 Charger initialization function.
 
err_t charger_default_cfg (charger_t *ctx)
 Charger default configuration function.
 
err_t charger_check_communication (charger_t *ctx)
 Charger check communication function.
 
err_t charger_select_device (charger_t *ctx)
 Charger select device function.
 
err_t charger_read_scratchpad (charger_t *ctx, uint8_t page, uint8_t *data_out, uint8_t len)
 Charger read scratchpad function.
 
err_t charger_write_scratchpad (charger_t *ctx, uint8_t page, uint8_t *data_in, uint8_t len)
 Charger write scratchpad function.
 
err_t charger_copy_scratchpad (charger_t *ctx, uint8_t page)
 Charger copy scratchpad function.
 
err_t charger_recall_memory (charger_t *ctx, uint8_t page)
 Charger recall scratchpad function.
 
err_t charger_convert_temperature (charger_t *ctx)
 Charger convert temperature function.
 
err_t charger_convert_voltage (charger_t *ctx)
 Charger convert voltage function.
 
err_t charger_read_temperature (charger_t *ctx, float *temperature)
 Charger read temperature function.
 
err_t charger_read_batt_vdd (charger_t *ctx, float *voltage)
 Charger read battery VDD function.
 
err_t charger_read_system_vdd (charger_t *ctx, float *voltage)
 Charger read system VDD function.
 
err_t charger_read_current (charger_t *ctx, float *current)
 Charger read current function.
 
err_t charger_calibrate_current (charger_t *ctx)
 Charger calibrate current function.
 
err_t charger_write_elapsed_time (charger_t *ctx, uint32_t seconds)
 Charger write elapsed time function.
 
err_t charger_read_elapsed_time (charger_t *ctx, uint32_t *seconds)
 Charger read elapsed time function.
 

Detailed Description

This file contains API for Charger Click Driver.

Enumeration Type Documentation

◆ charger_gpio_sel_t

Charger Click gpio selector.

Selects gpio pin of Charger Click driver.

Enumerator
CHARGER_GPIO_OW1 

GPIO OW1 pin.

CHARGER_GPIO_OW2 

GPIO OW2 pin.

◆ charger_return_value_t

Charger Click return value data.

Predefined enum values for driver return values.

Enumerator
CHARGER_OK 
CHARGER_ERROR