balancer2 2.0.0.0
balancer2.h File Reference

This file contains API for BALANCER 2 Click driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_spi_master.h"

Go to the source code of this file.

Data Structures

struct  balancer2_t
 Click ctx object definition. More...
 
struct  balancer2_cfg_t
 Click configuration structure definition. More...
 

Macros

#define BALANCER2_MAP_MIKROBUS(cfg, mikrobus)
 
#define BALANCER2_RETVAL   uint8_t
 
#define BALANCER2_OK   0x00
 
#define BALANCER2_INIT_ERROR   0xFF
 
#define BALANCER2_VREF_5V   5000
 
#define BALANCER2_VREF_3V3   3300
 
#define BALANCER2_CMD_START   0x01
 
#define BALANCER2_CMD_MSBF_LSB   0x20
 
#define BALANCER2_CMD_MSBF_MSB   0x00
 
#define BALANCER2_CMD_SINGLE_MODE_CH0   0x80
 
#define BALANCER2_CMD_SINGLE_MODE_CH1   0xC0
 
#define BALANCER2_CMD_DIFF_MODE_CH0M_CH1P   0x40
 
#define BALANCER2_CMD_DIFF_MODE_CH0P_CH1M   0x00
 
#define BALANCER2_CMD_DUMMY   0x00
 
#define BALANCER2_MASK   0x0F
 
#define BALANCER2_BATT1   0xAA
 
#define BALANCER2_BATT2   0xBB
 
#define BALANCER2_BATT_BOTH   0xCC
 
#define BALANCER2_PIN_STATE_HIGH   1
 
#define BALANCER2_PIN_STATE_LOW   0
 
#define BALANCER2_MODE_CHARGING   0x10
 
#define BALANCER2_MODE_BALANCING_P   0x20
 
#define BALANCER2_MODE_BALANCING_NP   0x30
 
#define BALANCER2_MODE_BALANCING_PP   0x40
 
#define BALANCER2_MODE_BALANCING_NPP   0x50
 
#define BALANCER2_MODE_BALANCING_P1   0x60
 
#define BALANCER2_MODE_BALANCING_NP1   0x70
 
#define BALANCER2_MODE_BALANCING_P2   0x80
 
#define BALANCER2_MODE_BALANCING_NP2   0x90
 
#define CHN_0_MV_MULT   3.0
 
#define CHN_1_MV_MULT   1.5
 
#define ADC_RESOLUTION   4096.0
 

Functions

void balancer2_cfg_setup (balancer2_cfg_t *cfg)
 Config Object Initialization function.
 
BALANCER2_RETVAL balancer2_init (balancer2_t *ctx, balancer2_cfg_t *cfg)
 Initialization function.
 
void balancer2_default_cfg (balancer2_t *ctx)
 Click Default Configuration function.
 
void balancer2_cell_1_state (balancer2_t *ctx, uint8_t state)
 Generic function for setting cell 1 pin status.
 
void balancer2_cell_2_state (balancer2_t *ctx, uint8_t state)
 Generic function for setting cell 2 pin status.
 
void balancer2_supply_state (balancer2_t *ctx, uint8_t state)
 Generic function for setting supply pin status.
 
void balancer2_status_led_state (balancer2_t *ctx, uint8_t state)
 Generic function for setting status led pin status.
 
uint16_t balancer2_read_adc (balancer2_t *ctx, uint8_t cmd_byte)
 Function for reading adc value.
 
void balancer2_set_vref (balancer2_t *ctx, uint16_t vref)
 Function for setting reference value.
 
float balancer2_get_batttery_lvl (balancer2_t *ctx, uint8_t bat_num)
 Function for getting real battery lvl.
 
float balancer2_adc_to_mv (balancer2_t *ctx, uint16_t adc_val)
 Function for converting adc value to mV.
 

Detailed Description

This file contains API for BALANCER 2 Click driver.