smartbuck 2.0.0.0
smartbuck.h File Reference

This file contains API for SMART BUCK Click driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  smartbuck_t
 Click ctx object definition. More...
 
struct  smartbuck_cfg_t
 Click configuration structure definition. More...
 

Macros

#define SMARTBUCK_MAP_MIKROBUS(cfg, mikrobus)
 
#define SMARTBUCK_RETVAL   uint8_t
 
#define SMARTBUCK_OK   0x00
 
#define SMARTBUCK_INIT_ERROR   0xFF
 
#define SMARTBUCK_EEPROM_SLAVE_000   0x50
 
#define SMARTBUCK_EEPROM_SLAVE_001   0x51
 
#define SMARTBUCK_EEPROM_SLAVE_010   0x52
 
#define SMARTBUCK_EEPROM_SLAVE_011   0x53
 
#define SMARTBUCK_EEPROM_SLAVE_100   0x54
 
#define SMARTBUCK_EEPROM_SLAVE_101   0x55
 
#define SMARTBUCK_EEPROM_SLAVE_110   0x56
 
#define SMARTBUCK_EEPROM_SLAVE_111   0x57
 
#define SMARTBUCK_MCP4661_SLAVE_000   0x28
 
#define SMARTBUCK_MCP4661_SLAVE_001   0x29
 
#define SMARTBUCK_MCP4661_SLAVE_010   0x2A
 
#define SMARTBUCK_MCP4661_SLAVE_011   0x2B
 
#define SMARTBUCK_MCP4661_SLAVE_100   0x2C
 
#define SMARTBUCK_MCP4661_SLAVE_101   0x2D
 
#define SMARTBUCK_MCP4661_SLAVE_110   0x2E
 
#define SMARTBUCK_MCP4661_SLAVE_111   0x2F
 
#define SMARTBUCK_PAC1934_SLAVE_0   0x10
 
#define SMARTBUCK_PAC1934_SLAVE_1   0x1F
 
#define SMARTBUCK_WIPER0_VOL_REG   0x00
 
#define SMARTBUCK_WIPER1_VOL_REG   0x01
 
#define SMARTBUCK_WIPER0_NONVOL_REG   0x02
 
#define SMARTBUCK_WIPER1_NONVOL_REG   0x03
 
#define SMARTBUCK_POT_TCON_VOL_REG   0x04
 
#define SMARTBUCK_POT_STATUS_REG   0x05
 
#define SMARTBUCK_WIPER_FULL_SCALE   0x100
 
#define SMARTBUCK_WIPER_HALF_SCALE   0x080
 
#define SMARTBUCK_WIPER_QUARTER_SCALE   0x040
 
#define SMARTBUCK_WIPER_FULL_PER_8_SCALE   0x020
 
#define SMARTBUCK_WIPER_ZERO_SCALE   0x000
 
#define SMARTBUCK_TCON_GENCALL_EN   0x100
 
#define SMARTBUCK_TCON_R1HW_SHDWN_EN   0x080
 
#define SMARTBUCK_TCON_R1A_CONNECT   0x040
 
#define SMARTBUCK_TCON_R1W_CONNECT   0x020
 
#define SMARTBUCK_TCON_R1B_CONNECT   0x010
 
#define SMARTBUCK_TCON_R0HW_SHDWN_EN   0x008
 
#define SMARTBUCK_TCON_R0A_CONNECT   0x004
 
#define SMARTBUCK_TCON_R0W_CONNECT   0x002
 
#define SMARTBUCK_TCON_R0B_CONNECT   0x001
 
#define SMARTBUCK_REFRESH_CMND   0x00
 
#define SMARTBUCK_PAC_CTRL_REG   0x01
 
#define SMARTBUCK_PAC_ACC_COUNT_REG   0x02
 
#define SMARTBUCK_PAC_VPOW1_ACC_REG   0x03
 
#define SMARTBUCK_PAC_VPOW2_ACC_REG   0x04
 
#define SMARTBUCK_PAC_VPOW3_ACC_REG   0x05
 
#define SMARTBUCK_PAC_VPOW4_ACC_REG   0x06
 
#define SMARTBUCK_PAC_VBUS1_REG   0x07
 
#define SMARTBUCK_PAC_VBUS2_REG   0x08
 
#define SMARTBUCK_PAC_VBUS3_REG   0x09
 
#define SMARTBUCK_PAC_VBUS4_REG   0x0A
 
#define SMARTBUCK_PAC_VSENSE1_REG   0x0B
 
#define SMARTBUCK_PAC_VSENSE2_REG   0x0C
 
#define SMARTBUCK_PAC_VSENSE3_REG   0x0D
 
#define SMARTBUCK_PAC_VSENSE4_REG   0x0E
 
#define SMARTBUCK_PAC_VBUS1_AVG_REG   0x0F
 
#define SMARTBUCK_PAC_VBUS2_AVG_REG   0x10
 
#define SMARTBUCK_PAC_VBUS3_AVG_REG   0x11
 
#define SMARTBUCK_PAC_VBUS4_AVG_REG   0x12
 
#define SMARTBUCK_PAC_VSENSE1_AVG_REG   0x13
 
#define SMARTBUCK_PAC_VSENSE2_AVG_REG   0x14
 
#define SMARTBUCK_PAC_VSENSE3_AVG_REG   0x15
 
#define SMARTBUCK_PAC_VSENSE4_AVG_REG   0x16
 
#define SMARTBUCK_PAC_VPOW1_REG   0x17
 
#define SMARTBUCK_PAC_VPOW2_REG   0x18
 
#define SMARTBUCK_PAC_VPOW3_REG   0x19
 
#define SMARTBUCK_PAC_VPOW4_REG   0x1A
 
#define SMARTBUCK_PAC_CHANN_DIS_REG   0x1C
 
#define SMARTBUCK_PAC_NEG_PWR_REG   0x1D
 
#define SMARTBUCK_REFRESH_G_CMND   0x1E
 
#define SMARTBUCK_REFRESH_V_CMND   0x1F
 
#define SMARTBUCK_PAC_SLOW_REG   0x20
 
#define SMARTBUCK_PAC_CTRL_STAT_REG   0x21
 
#define SMARTBUCK_PAC_CHANN_DIS_STAT_REG   0x22
 
#define SMARTBUCK_PAC_NEG_PWR_STAT_REG   0x23
 
#define SMARTBUCK_PAC_CTRL_LATCH_REG   0x24
 
#define SMARTBUCK_PAC_CHANN_DIS_LATCH_REG   0x25
 
#define SMARTBUCK_PAC_NEG_PWR_LATCH_REG   0x26
 
#define SMARTBUCK_PAC_PID_REG   0xFD
 
#define SMARTBUCK_PAC_MANU_ID_REG   0xFE
 
#define SMARTBUCK_PAC_REV_ID_REG   0xFF
 
#define SMARTBUCK_PAC_1024_SAMPL   0x00
 
#define SMARTBUCK_PAC_256_SAMPL   0x40
 
#define SMARTBUCK_PAC_64_SAMPL   0x80
 
#define SMARTBUCK_PAC_8_SAMPL   0xC0
 
#define SMARTBUCK_PAC_SLEEP_MODE   0x20
 
#define SMARTBUCK_PAC_SEQUENTIAL_MODE   0x00
 
#define SMARTBUCK_PAC_SINGLE_SHOT_MODE   0x10
 
#define SMARTBUCK_PAC_ALERT_PIN_EN   0x0C
 
#define SMARTBUCK_PAC_OVF_ALERT_EN   0x02
 
#define SMARTBUCK_WIPER0_SEL   0x00
 
#define SMARTBUCK_WIPER1_SEL   0x01
 
#define SMARTBUCK_REGULATOR_DIS   0x00
 
#define SMARTBUCK_REGULATOR_EN   0x01
 
#define SMARTBUCK_AUTO_TRICKLE_MODE   0x01
 
#define SMARTBUCK_FORCE_PWM_MODE   0x00
 
#define SMARTBUCK_ALL_CHANN_OFF   0xF0
 
#define SMARTBUCK_ALL_CHANN_ON   0x00
 
#define SMARTBUCK_CH1_ON   0x70
 
#define SMARTBUCK_CH2_ON   0xB0
 
#define SMARTBUCK_CH3_ON   0xD0
 
#define SMARTBUCK_CH4_ON   0xE0
 
#define SMARTBUCK_ALL_DATA_UNSIGN_FORM   0x00
 
#define SMARTBUCK_ALL_DATA_SIGN_FORM   0xFF
 
#define SMARTBUCK_CH1_VSENSE_SIGN_FORM   0x80
 
#define SMARTBUCK_CH2_VSENSE_SIGN_FORM   0x40
 
#define SMARTBUCK_CH3_VSENSE_SIGN_FORM   0x20
 
#define SMARTBUCK_CH4_VSENSE_SIGN_FORM   0x10
 
#define SMARTBUCK_CH1_VBUS_SIGN_FORM   0x08
 
#define SMARTBUCK_CH2_VBUS_SIGN_FORM   0x04
 
#define SMARTBUCK_CH3_VBUS_SIGN_FORM   0x02
 
#define SMARTBUCK_CH4_VBUS_SIGN_FORM   0x01
 
#define SMARTBUCK_SAMPL_DATA_MODE   0x00
 
#define SMARTBUCK_AVRG_DATA_MODE   0x01
 
#define SMARTBUCK_POT_WRITE_CMND   0x00
 
#define SMARTBUCK_POT_INCR_CMND   0x04
 
#define SMARTBUCK_POT_DECR_CMND   0x08
 
#define SMARTBUCK_POT_READ_CMND   0x0C
 
#define SMARTBUCK_PAC_GENERAL_CALL_SLAVE   0x00
 

Functions

void smartbuck_cfg_setup (smartbuck_cfg_t *cfg)
 Config Object Initialization function.
 
SMARTBUCK_RETVAL smartbuck_init (smartbuck_t *ctx, smartbuck_cfg_t *cfg)
 Initialization function.
 
void smartbuck_default_cfg (smartbuck_t *ctx)
 Click Default Configuration function.
 
uint8_t smartbuck_write_eeprom (smartbuck_t *ctx, uint8_t eeprom_addr, uint8_t data_in)
 EEPROM Write function.
 
uint8_t smartbuck_read_eeprom (smartbuck_t *ctx, uint8_t eeprom_addr, uint8_t *data_out)
 EEPROM Read function.
 
uint8_t smartbuck_read_seq_eeprom (smartbuck_t *ctx, uint8_t eeprom_addr, uint8_t *data_out, uint8_t n_bytes)
 Sequential EEPROM Read function.
 
uint8_t smartbuck_write_pot (smartbuck_t *ctx, uint8_t reg_addr, uint16_t data_in)
 Potentiometer Write function.
 
uint8_t smartbuck_read_pot (smartbuck_t *ctx, uint8_t reg_addr, uint16_t *data_out)
 Potentiometer Read function.
 
uint8_t smartbuck_incr_pot (smartbuck_t *ctx, uint8_t wiper_sel, uint16_t steps)
 Potentiometer Increment function.
 
uint8_t smartbuck_decr_pot (smartbuck_t *ctx, uint8_t wiper_sel, uint16_t steps)
 Potentiometer Decrement function.
 
void smartbuck_en_regulator1 (smartbuck_t *ctx, uint8_t state)
 Regulator1 Enable function.
 
void smartbuck_en_regulator2 (smartbuck_t *ctx, uint8_t state)
 Regulator2 Enable function.
 
void smartbuck_force_pwm_mode (smartbuck_t *ctx, uint8_t state)
 PWM Mode Force function.
 
uint8_t smartbuck_check_diagnostic (smartbuck_t *ctx)
 Diagnostic Check function.
 
uint8_t smartbuck_send_cmd_pac (smartbuck_t *ctx, uint8_t command)
 Command Send function.
 
uint8_t smartbuck_write_pac (smartbuck_t *ctx, uint8_t reg_addr, uint8_t data_in)
 PAC1934 Write function.
 
uint8_t smartbuck_read_pac (smartbuck_t *ctx, uint8_t reg_addr, uint8_t *data_out)
 PAC1934 Read function.
 
uint8_t smartbuck_set_addr_ptr_pac (smartbuck_t *ctx, uint8_t reg_addr)
 Address Pointer Set function.
 
void smartbuck_receive_byte_pac (smartbuck_t *ctx, uint8_t *data_out)
 Byte Receive function.
 
uint8_t smartbuck_block_read_pac (smartbuck_t *ctx, uint8_t reg_addr, uint8_t *data_out, uint8_t n_bytes)
 PAC1934 Block Read function.
 
uint8_t smartbuck_set_config_pac (smartbuck_t *ctx, uint8_t en_chann, uint8_t data_format, uint8_t data_sel)
 PAC1934 Configuration Set function.
 
void smartbuck_get_data (smartbuck_t *ctx, float *voltage, float *current, float *power)
 Data Get function.
 

Variables

uint8_t enabled_chann
 

Detailed Description

This file contains API for SMART BUCK Click driver.