smartbuck 2.0.0.0

Data Structures

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

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

Function Documentation

◆ smartbuck_block_read_pac()

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.

Parameters
ctxClick object.
reg_addrStart address which from data be read
data_outMemory where data be stored
n_bytesNumber of bytes to be read
Returns
0 - OK, 1 - Wrong register address

Function reads the desired number of bytes from the PAC1934 registers.

◆ smartbuck_cfg_setup()

void smartbuck_cfg_setup ( smartbuck_cfg_t * cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

@description This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ smartbuck_check_diagnostic()

uint8_t smartbuck_check_diagnostic ( smartbuck_t * ctx)

Diagnostic Check function.

Parameters
ctxClick object.

Function checks regulator diagnostic (Power Good state) and returns result.

◆ smartbuck_decr_pot()

uint8_t smartbuck_decr_pot ( smartbuck_t * ctx,
uint8_t wiper_sel,
uint16_t steps )

Potentiometer Decrement function.

Parameters
ctxClick object.
wiper_sel0 - Wiper0, 1 - Wiper1
stepsDetermines for how many steps potentiometer be decremented
Returns
0 - OK, 1 - Number of steps is out of range, 2 - Wrong wiper selection

Function decrements the desired wiper for the desired number of steps.

◆ smartbuck_default_cfg()

void smartbuck_default_cfg ( smartbuck_t * ctx)

Click Default Configuration function.

Parameters
ctxClick object.

@description This function executes default configuration for SMARTBUCK click.

◆ smartbuck_en_regulator1()

void smartbuck_en_regulator1 ( smartbuck_t * ctx,
uint8_t state )

Regulator1 Enable function.

Parameters
ctxClick object.
state0 - OFF, 1 - ON

Function puts Regulator1 to the desired state.

◆ smartbuck_en_regulator2()

void smartbuck_en_regulator2 ( smartbuck_t * ctx,
uint8_t state )

Regulator2 Enable function.

Parameters
ctxClick object.
state0 - OFF, 1 - ON

Function puts Regulator2 to the desired state.

◆ smartbuck_force_pwm_mode()

void smartbuck_force_pwm_mode ( smartbuck_t * ctx,
uint8_t state )

PWM Mode Force function.

Parameters
ctxClick object.
state0 - PWM Forced Mode, 1 - Auto Trickle Mode

Function puts regulator to Forced PWM Mode or to Automatic Trickle Mode.

◆ smartbuck_get_data()

void smartbuck_get_data ( smartbuck_t * ctx,
float * voltage,
float * current,
float * power )

Data Get function.

Parameters
ctxClick object.
voltageMemory where voltage data be stored
currentMemory where current data be stored.
powerMemory where power data be stored.

Function reads and calculates the voltage, current and power data from PAC1934 activated channels.

Note
Results will be stored in order from 0 to the number of activated channels, and begins with channel 1. Voltage value be calculated in V unit, current in mA unit and power in mW unit.

◆ smartbuck_incr_pot()

uint8_t smartbuck_incr_pot ( smartbuck_t * ctx,
uint8_t wiper_sel,
uint16_t steps )

Potentiometer Increment function.

Parameters
ctxClick object.
wiper_sel0 - Wiper0, 1 - Wiper1
stepsDetermines for how many steps potentiometer be incremented
Returns
0 - OK, 1 - Number of steps is out of range, 2 - Wrong wiper selection

Function increments the desired wiper for the desired number of steps.

◆ smartbuck_init()

SMARTBUCK_RETVAL smartbuck_init ( smartbuck_t * ctx,
smartbuck_cfg_t * cfg )

Initialization function.

Parameters
ctxClick object.
cfgClick configuration structure.

@description This function initializes all necessary pins and peripherals used for this click.

◆ smartbuck_read_eeprom()

uint8_t smartbuck_read_eeprom ( smartbuck_t * ctx,
uint8_t eeprom_addr,
uint8_t * data_out )

EEPROM Read function.

Parameters
ctxClick object.
eeprom_addrAddress which from data be read
data_outMemory where data be stored
Returns
0 - OK, 1 - Wrong EEPROM address

Function reads one byte from the EEPROM.

◆ smartbuck_read_pac()

uint8_t smartbuck_read_pac ( smartbuck_t * ctx,
uint8_t reg_addr,
uint8_t * data_out )

PAC1934 Read function.

Parameters
ctxClick object.
reg_addrAddress which from data be read
data_outMemory where data be stored
Returns
0 - OK, 1 - Wrong register address

Function reads one byte from the PAC1934 register.

◆ smartbuck_read_pot()

uint8_t smartbuck_read_pot ( smartbuck_t * ctx,
uint8_t reg_addr,
uint16_t * data_out )

Potentiometer Read function.

Parameters
ctxClick object.
reg_addrAddress which from data be read
data_outMemory where data be stored
Returns
0 - OK, 1 - Wrong register address

Function reads 16bit data from the Potentiometer register (MCP4661).

◆ smartbuck_read_seq_eeprom()

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.

Parameters
ctxClick object.
eeprom_addrStart address which from data be read
data_outMemory where data be stored
n_bytesNumber of bytes to be read
Returns
0 - OK, 1 - Wrong EEPROM address

Function reads the desired number of bytes from the EEPROM.

◆ smartbuck_receive_byte_pac()

void smartbuck_receive_byte_pac ( smartbuck_t * ctx,
uint8_t * data_out )

Byte Receive function.

Parameters
ctxClick object.
data_outMemory where byte be stored

Function receives one byte from the PAC1934 address on which internal address pointer is set up.

◆ smartbuck_send_cmd_pac()

uint8_t smartbuck_send_cmd_pac ( smartbuck_t * ctx,
uint8_t command )

Command Send function.

Parameters
ctxClick object.
commandCommand to be performed
Returns
0 - OK, 1 - Wrong command

Function performs the desired command for PAC1934.

◆ smartbuck_set_addr_ptr_pac()

uint8_t smartbuck_set_addr_ptr_pac ( smartbuck_t * ctx,
uint8_t reg_addr )

Address Pointer Set function.

Parameters
ctxClick object.
reg_addrAddress on which address pointer be set up
Returns
0 - OK, 1 - Wrong register address

Function sets internal address pointer on the desired PAC1934 register.

◆ smartbuck_set_config_pac()

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.

Parameters
ctxClick object.
en_channDetermines which channel be enabled or disabled
data_formatDetermines format of data, signed or unsigned
data_selSelects conversion mode, one sample(0) or averaged data(1)
Returns
0 - OK, 1 - Channel is not exist, 2 - Wrong data selection

Function sets configuration for conversion cycle for PAC1934.

Note
The format of enChann parameter is 0bc1c2c3c4 0000. If 'cn' is 0 that means that channel 'n' is activated. And if 'cn' is 1 that means that channel 'n' is not activated. The format of dataFormat parameter is 0bi1i2i3i4 v1v2v3v4. If 'in' is 0 that means that VSENSE for channel 'n' be unsigned. If 'in' is 1 that means that VSENSE for channel 'n' be signed. Same is for 'vn' but it applies to VBUS for channel 'n'.

◆ smartbuck_write_eeprom()

uint8_t smartbuck_write_eeprom ( smartbuck_t * ctx,
uint8_t eeprom_addr,
uint8_t data_in )

EEPROM Write function.

Parameters
ctxClick object.
eeprom_addrAddress where data be written
data_inData to be written
Returns
0 - OK, 1 - Wrong EEPROM address

Function writes one byte to the EEPROM.

◆ smartbuck_write_pac()

uint8_t smartbuck_write_pac ( smartbuck_t * ctx,
uint8_t reg_addr,
uint8_t data_in )

PAC1934 Write function.

Parameters
ctxClick object.
reg_addrAddress where data be written
data_inData to be written
Returns
0 - OK, 1 - Wrong register address

Function writes one byte to the PAC1934 register.

◆ smartbuck_write_pot()

uint8_t smartbuck_write_pot ( smartbuck_t * ctx,
uint8_t reg_addr,
uint16_t data_in )

Potentiometer Write function.

Parameters
ctxClick object.
reg_addrAddress where data be written
data_inData to be written
Returns
0 - OK, 1 - Wrong register address, 2 - Wrong input data

Function writes 16bit data to the Potentiometer register (MCP4661).

Variable Documentation

◆ enabled_chann

uint8_t enabled_chann
extern

This variable checks which channel is enabled