39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_one_wire.h"
73#define CHARGER_CMD_WRITE_SCRATCHPAD 0x4E
74#define CHARGER_CMD_READ_SCRATCHPAD 0xBE
75#define CHARGER_CMD_COPY_SCRATCHPAD 0x48
76#define CHARGER_CMD_RECALL_MEMORY 0xB8
77#define CHARGER_CMD_CONVERT_T 0x44
78#define CHARGER_CMD_CONVERT_V 0xB4
96#define CHARGER_PAGE_0 0
97#define CHARGER_PAGE_1 1
98#define CHARGER_PAGE_2 2
99#define CHARGER_PAGE_3 3
100#define CHARGER_PAGE_4 4
101#define CHARGER_PAGE_5 5
102#define CHARGER_PAGE_6 6
103#define CHARGER_PAGE_7 7
104#define CHARGER_PAGE_SIZE 8
110#define CHARGER_CONFIG_IAD 0x01
111#define CHARGER_CONFIG_CA 0x02
112#define CHARGER_CONFIG_EE 0x04
113#define CHARGER_CONFIG_AD 0x08
114#define CHARGER_CONFIG_TB 0x10
115#define CHARGER_CONFIG_NVM 0x20
116#define CHARGER_CONFIG_ADB 0x40
122#define CHARGER_TEMPERATURE_RES 0.03125f
123#define CHARGER_VOLTAGE_RES 0.01f
124#define CHARGER_CURRENT_RES 204.8f
130#define CHARGER_FAMILY_CODE 0x26
136#define CHARGER_ADDRESS_0 0x00
137#define CHARGER_ADDRESS_ALL 0xFF
155#define CHARGER_MAP_MIKROBUS( cfg, mikrobus ) \
156 cfg.ow1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
157 cfg.ow2 = MIKROBUS( mikrobus, MIKROBUS_AN );
charger_gpio_sel_t
Charger Click gpio selector.
Definition charger.h:167
@ CHARGER_GPIO_OW2
Definition charger.h:169
@ CHARGER_GPIO_OW1
Definition charger.h:168
charger_return_value_t
Charger Click return value data.
Definition charger.h:206
@ CHARGER_ERROR
Definition charger.h:208
@ CHARGER_OK
Definition charger.h:207
err_t charger_convert_voltage(charger_t *ctx)
Charger convert voltage function.
err_t charger_default_cfg(charger_t *ctx)
Charger default configuration function.
err_t charger_init(charger_t *ctx, charger_cfg_t *cfg)
Charger initialization function.
err_t charger_read_current(charger_t *ctx, float *current)
Charger read current function.
err_t charger_read_scratchpad(charger_t *ctx, uint8_t page, uint8_t *data_out, uint8_t len)
Charger read scratchpad function.
void charger_cfg_setup(charger_cfg_t *cfg)
Charger configuration object setup 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.
void charger_gpio_selection(charger_cfg_t *cfg, charger_gpio_sel_t gpio_sel)
Charger driver interface setup function.
err_t charger_read_temperature(charger_t *ctx, float *temperature)
Charger read temperature function.
err_t charger_copy_scratchpad(charger_t *ctx, uint8_t page)
Charger copy scratchpad function.
err_t charger_calibrate_current(charger_t *ctx)
Charger calibrate current function.
err_t charger_recall_memory(charger_t *ctx, uint8_t page)
Charger recall scratchpad function.
err_t charger_read_elapsed_time(charger_t *ctx, uint32_t *seconds)
Charger read elapsed time function.
err_t charger_convert_temperature(charger_t *ctx)
Charger convert temperature function.
err_t charger_check_communication(charger_t *ctx)
Charger check communication function.
err_t charger_write_elapsed_time(charger_t *ctx, uint32_t seconds)
Charger write elapsed time function.
err_t charger_select_device(charger_t *ctx)
Charger select device function.
err_t charger_write_scratchpad(charger_t *ctx, uint8_t page, uint8_t *data_in, uint8_t len)
Charger write scratchpad function.
Charger Click configuration object.
Definition charger.h:192
pin_name_t ow2
Definition charger.h:195
charger_gpio_sel_t gpio_sel
Definition charger.h:197
pin_name_t ow1
Definition charger.h:194
Charger Click context object.
Definition charger.h:178
one_wire_rom_address_t rom_addr
Definition charger.h:182
uint8_t address
Definition charger.h:183
one_wire_t ow
Definition charger.h:180