no-OS
Functions
adp1050.c File Reference

Source file for the ADP1050 Driver. More...

#include <stdlib.h>
#include <string.h>
#include "adp1050.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_error.h"
Include dependency graph for adp1050.c:

Functions

int adp1050_send_command (struct adp1050_desc *desc, uint16_t command)
 Send command byte/word to ADP1050. More...
 
int adp1050_read (struct adp1050_desc *desc, uint16_t command, uint8_t *data, uint8_t bytes_number)
 Read data from ADP1050. More...
 
int adp1050_write (struct adp1050_desc *desc, uint16_t command, uint16_t data, uint8_t bytes_number)
 Write data to ADP1050. More...
 
int adp1050_read_status (struct adp1050_desc *desc, enum adp1050_status_type status, uint16_t *status_val)
 Read statuses. More...
 
int adp1050_read_vsense (struct adp1050_desc *desc, uint16_t *vsense)
 Read Voltage Sense output raw value from the ADP1050. More...
 
int adp1050_read_value (struct adp1050_desc *desc, uint16_t *mant, uint8_t *exp, enum adp1050_value_type val_type)
 Read VIN/IIN/TEMP/DUTY_CYCLE/FREQ raw value from the ADP1050. More...
 
int adp1050_vout_value (struct adp1050_desc *desc, uint16_t vout_command, uint16_t vout_max)
 Set VOUT_COMMAND and VOUT_MAX values. More...
 
int adp1050_vout_offset (struct adp1050_desc *desc, int16_t vout_offset)
 Set output voltage offset. More...
 
int adp1050_vout_tr (struct adp1050_desc *desc, enum adp1050_vout_tr vout_tr)
 Set ADP1050 VOUT transition rate. More...
 
int adp1050_vout_scale (struct adp1050_desc *desc, int8_t exp, uint16_t mant)
 Set ADP1050 VOUT scale, regarding the resistor divider assigned to the VS pins. More...
 
int adp1050_vout_margin (struct adp1050_desc *desc, uint16_t margin_high, uint16_t margin_low)
 Set VOUT margins value. More...
 
int adp1050_pwm_duty_cycle (struct adp1050_desc *desc, uint16_t pulse_width, uint16_t pulse_start, enum adp1050_channel chan)
 Set VOUT duty cycle for requested channel. More...
 
int adp1050_pwm_modulation (struct adp1050_desc *desc, enum adp1050_mod mod, enum adp1050_channel chan, bool sign)
 Set PWM modulation for requested channel. More...
 
int adp1050_set_pwm (struct adp1050_desc *desc, enum adp1050_channel chan, enum adp1050_freq freq)
 Set PWM channel and frequency. More...
 
int adp1050_set_vin (struct adp1050_desc *desc, int16_t mantissa, int8_t exp, bool state_on)
 Set ADP1050 VIN on/off raw value for input voltage limiting. More...
 
int adp1050_set_climit (struct adp1050_desc *desc, enum adp1050_iin_oc_fast_fault fast_fault, enum adp1050_climit_ref climit_ref)
 Set current limit fast fault for overcurrent protection and current limit cycle-by-cycle reference. More...
 
int adp1050_set_cs1_settings (struct adp1050_desc *desc, enum adp1050_cs1_leading_edge leading_edge, enum adp1050_cs1_debounce debounce, bool ignore)
 Set current sense settings. More...
 
int adp1050_set_open_loop (struct adp1050_desc *desc, uint8_t rising_edge, uint8_t falling_edge, enum adp1050_channel chan)
 Set requested ADP1050 channel in Open Loop operation mode. More...
 
int adp1050_set_close_loop (struct adp1050_desc *desc)
 Set close loop operation. More...
 
int adp1050_pulse_skipping (struct adp1050_desc *desc, uint8_t pulse_threshold, bool state_on)
 Enable or disbale the pulse skipping mode. More...
 
int adp1050_set_feedforward (struct adp1050_desc *desc, bool state_on)
 Enable or disable voltage input feedforward for edge modulation. More...
 
int adp1050_freq_sync (struct adp1050_desc *desc, bool state_on)
 Frequency synchronization of the PWM clock with an external clock Requires syni_desc to be initialized. More...
 
int adp1050_set_flgi_response (struct adp1050_desc *desc, enum adp1050_flgi_fault_response fault_response, enum adp1050_flgi_after_fault after_fault)
 Set FLAGIN response to FLGI pin signal. More...
 
int adp1050_filter (struct adp1050_desc *desc, uint8_t zero, uint8_t pole, uint8_t lf, uint8_t hf)
 Adjust filter settings of the normal mode compensator. More...
 
int adp1050_trim (struct adp1050_desc *desc, enum adp1050_trim_type trim_type, uint16_t vout_command, uint16_t vout_scale, uint16_t trim_val)
 Trim IIN(CS1 pin)/VIN(VF pin)/VOUT(VS pin). More...
 
int adp1050_unlock_pass (struct adp1050_desc *desc, uint16_t password, enum adp1050_pass_type pass_type)
 Unlock CHIP/EEPROM/TRIM password. More...
 
int adp1050_lock_pass (struct adp1050_desc *desc, uint16_t password, enum adp1050_pass_type pass_type)
 Lock CHIP/EEPROM password. TRIM passwor dis locked of the EEPROM password is locked. More...
 
int adp1050_change_pass (struct adp1050_desc *desc, uint16_t old_pass, uint16_t new_pass, enum adp1050_pass_type pass_type)
 Change the CHIP/EEPROM password. TRIM password is the same with EEPROM password. More...
 
int adp1050_software_reset (struct adp1050_desc *desc)
 Software reset the ADP1050. More...
 
int adp1050_init (struct adp1050_desc **desc, struct adp1050_init_param *init_param)
 Initialize the ADP1050 device. More...
 
int adp1050_remove (struct adp1050_desc *desc)
 Free the resources allocated by the adp1050_init() More...
 

Detailed Description

Source file for the ADP1050 Driver.

Author
Radu Sabau (radu..nosp@m.saba.nosp@m.u@ana.nosp@m.log..nosp@m.com)

Copyright 2024(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ adp1050_change_pass()

int adp1050_change_pass ( struct adp1050_desc desc,
uint16_t  old_pass,
uint16_t  new_pass,
enum adp1050_pass_type  pass_type 
)

Change the CHIP/EEPROM password. TRIM password is the same with EEPROM password.

Parameters
desc- ADP1050 device descriptor
old_pass- Old password value.
new_pass- New password value.
pass_type- Password type (CHIP/EEPROM).
Returns
0 in case of succes, negative error code otherwise

◆ adp1050_filter()

int adp1050_filter ( struct adp1050_desc desc,
uint8_t  zero,
uint8_t  pole,
uint8_t  lf,
uint8_t  hf 
)

Adjust filter settings of the normal mode compensator.

Parameters
desc- ADP1050 device descriptor
zero- Normal mode zero settings.
pole- Normal mode pole settings.
lf- Normal mode low filter gain settings.
hf- Normal mode high filter gain settings.
Returns
0 in case of succes, negative error code otherwise

◆ adp1050_freq_sync()

int adp1050_freq_sync ( struct adp1050_desc desc,
bool  state_on 
)

Frequency synchronization of the PWM clock with an external clock Requires syni_desc to be initialized.

Parameters
desc- ADP1050 device descriptor
state_on- true - Turn on frequency synchronization. false - Turn off frequency synchronization.
Returns
0 in case of succes, negative error code otherwise

◆ adp1050_init()

int adp1050_init ( struct adp1050_desc **  desc,
struct adp1050_init_param init_param 
)

Initialize the ADP1050 device.

Parameters
desc- ADP1050 device descriptor
init_param- Initialization parameter containing information about the ADP1050 device to be initialized.
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_lock_pass()

int adp1050_lock_pass ( struct adp1050_desc desc,
uint16_t  password,
enum adp1050_pass_type  pass_type 
)

Lock CHIP/EEPROM password. TRIM passwor dis locked of the EEPROM password is locked.

Parameters
desc- ADP1050 device descriptor
password- Wrong password to be introduced for password lockage.
pass_type- Password type to be used for register lockage.
Returns
0 in case of succes, negative error code otherwise.

◆ adp1050_pulse_skipping()

int adp1050_pulse_skipping ( struct adp1050_desc desc,
uint8_t  pulse_threshold,
bool  state_on 
)

Enable or disbale the pulse skipping mode.

Parameters
desc- ADP1050 device descriptor.
pulse_threshold- Pulse threshold value, each LSB corresponds to a 5ns resolution.
state_on- true - enable pulse skipping false - disable pulse skipping
Returns
0 in case of succes, negative error code otherwise.

◆ adp1050_pwm_duty_cycle()

int adp1050_pwm_duty_cycle ( struct adp1050_desc desc,
uint16_t  pulse_width,
uint16_t  pulse_start,
enum adp1050_channel  chan 
)

Set VOUT duty cycle for requested channel.

Parameters
desc- ADP1050 device descriptor
pulse_width- Width of the pulse wanted for the signal (used for calculation of the 12-bit rising and falling edge timings for the requested channels, it depends on each channel how the falling and rising edges are calculated using this value). Each LSB corresponds to a 5ns resolution.
pulse_start- Start of the pulse wanted for the signal (used for calculation of the 12-bit rising and falling edge timings for the requested channels, it depends on each channel how the falling and rising edges are calculated using this value). Each LSB corresponds to a 5ns resolution.
chan- Requested channel.
Returns
0 in case of succes, negative error code otherwise.
Here is the caller graph for this function:

◆ adp1050_pwm_modulation()

int adp1050_pwm_modulation ( struct adp1050_desc desc,
enum adp1050_mod  mod,
enum adp1050_channel  chan,
bool  sign 
)

Set PWM modulation for requested channel.

Parameters
desc- ADP1050 device descriptor
mod- Type of modulation.
chan- Requested channel.
sign- true - Positive modulation sign false - Negative modulation sign.
Returns
0 in case of succes, negative error code otherwise

◆ adp1050_read()

int adp1050_read ( struct adp1050_desc desc,
uint16_t  command,
uint8_t *  data,
uint8_t  bytes_number 
)

Read data from ADP1050.

Parameters
desc- ADP1050 device descriptor
command- Command value.
data- Buffer with received data.
bytes_number- Number of bytes to read.
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_read_status()

int adp1050_read_status ( struct adp1050_desc desc,
enum adp1050_status_type  status,
uint16_t *  status_val 
)

Read statuses.

Parameters
desc- ADP1050 device descriptor
status- Status type.
status_val- Status value to be returned.
Returns
0 in case of succes, negative error code otherwise

◆ adp1050_read_value()

int adp1050_read_value ( struct adp1050_desc desc,
uint16_t *  mant,
uint8_t *  exp,
enum adp1050_value_type  val_type 
)

Read VIN/IIN/TEMP/DUTY_CYCLE/FREQ raw value from the ADP1050.

Parameters
desc- ADP1050 device descriptor
mant- Raw mantissa value to be received.
exp- Raw exponent value to be received.
val_type- Type of avlue to be read.
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_read_vsense()

int adp1050_read_vsense ( struct adp1050_desc desc,
uint16_t *  vsense 
)

Read Voltage Sense output raw value from the ADP1050.

Parameters
desc- ADP1050 device descriptor
vsense- VS(VOUT) raw value to be received of the parallel circuit.
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_remove()

int adp1050_remove ( struct adp1050_desc desc)

Free the resources allocated by the adp1050_init()

Parameters
desc- ADP1050 device descriptor
Returns
- 0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_send_command()

int adp1050_send_command ( struct adp1050_desc desc,
uint16_t  command 
)

Send command byte/word to ADP1050.

Parameters
desc- ADP1050 device descriptor
command- Value of the command.
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_set_climit()

int adp1050_set_climit ( struct adp1050_desc desc,
enum adp1050_iin_oc_fast_fault  fast_fault,
enum adp1050_climit_ref  climit_ref 
)

Set current limit fast fault for overcurrent protection and current limit cycle-by-cycle reference.

Parameters
desc- ADP1050_device_descriptor.
fast_fault- Fast fault limit value for N counter.
climit_ref- Current limit cylcle-by-cycle reference.
Returns
0 in case of succes, negative error code otherwise.

◆ adp1050_set_close_loop()

int adp1050_set_close_loop ( struct adp1050_desc desc)

Set close loop operation.

Parameters
desc- ADP1050 device descriptor
Returns
0 in case of succes, negative error code otherwise.
Here is the caller graph for this function:

◆ adp1050_set_cs1_settings()

int adp1050_set_cs1_settings ( struct adp1050_desc desc,
enum adp1050_cs1_leading_edge  leading_edge,
enum adp1050_cs1_debounce  debounce,
bool  ignore 
)

Set current sense settings.

Parameters
desc- ADP1050 device descriptor
leading_edge- Leading edge blanking time.
debounce- Current sense cycle-by-cycle current-limit debounce time.
ignore- CS1 overcurrent protection comparator to be ignored.
Returns
0 in case of succes, negative error code otherwise.

◆ adp1050_set_feedforward()

int adp1050_set_feedforward ( struct adp1050_desc desc,
bool  state_on 
)

Enable or disable voltage input feedforward for edge modulation.

Parameters
desc- ADP1050 device descriptor.
state_on- State of the feedforward to be set. If set true, every value above the 1V up until the 1.6V on the VF pin will decrease the time of the rising and falling edges, and every value below the 1V down until the 0.5V on the VF pin will increase the value of the rising and falling edges.
Returns
0 in case of succes, negative error code otherwise.

◆ adp1050_set_flgi_response()

int adp1050_set_flgi_response ( struct adp1050_desc desc,
enum adp1050_flgi_fault_response  fault_response,
enum adp1050_flgi_after_fault  after_fault 
)

Set FLAGIN response to FLGI pin signal.

Parameters
desc- ADP1050 device descriptor
fault_response- Device response to flag being set.
after_fault- Action when the falg is cleared.
Returns
0 in case of succes, negative error code otherwise

◆ adp1050_set_open_loop()

int adp1050_set_open_loop ( struct adp1050_desc desc,
uint8_t  rising_edge,
uint8_t  falling_edge,
enum adp1050_channel  chan 
)

Set requested ADP1050 channel in Open Loop operation mode.

Parameters
desc- ADP1050 device descriptor.
rising_edge- Rising edge timing.
falling_edge- Falling edge timing.
chan- Channel t be set in open-loop.
Returns
0 in case of succes, negative error code otherwise.

◆ adp1050_set_pwm()

int adp1050_set_pwm ( struct adp1050_desc desc,
enum adp1050_channel  chan,
enum adp1050_freq  freq 
)

Set PWM channel and frequency.

Parameters
desc- ADP1050 device descriptor
chan- Selected channel.
freq- Selected frequency.
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_set_vin()

int adp1050_set_vin ( struct adp1050_desc desc,
int16_t  mantissa,
int8_t  exp,
bool  state_on 
)

Set ADP1050 VIN on/off raw value for input voltage limiting.

Parameters
desc- ADP1050 device descriptor
mantissa- Mantissa value to be transmitted, 11 bit twos complement.
exp- Exponent value to be transmitted, 5 bit twos complement.
state_on- true - Set VIN_ON. false - Set VIN_OFF.
Returns
0 in case of succes, negative error code otherwise

◆ adp1050_software_reset()

int adp1050_software_reset ( struct adp1050_desc desc)

Software reset the ADP1050.

Parameters
desc- ADP1050 device descriptor
Returns
0 in case of succes, negative error code otherwise

◆ adp1050_trim()

int adp1050_trim ( struct adp1050_desc desc,
enum adp1050_trim_type  trim_type,
uint16_t  vout_command,
uint16_t  vout_scale,
uint16_t  trim_val 
)

Trim IIN(CS1 pin)/VIN(VF pin)/VOUT(VS pin).

Parameters
desc- ADP1050 device descriptor
trim_type- Type of trim requested.
vout_command- VOUT_COMMAND value to be set in case of a VOUT trim, if a VOUT trim isn't requested, this parameter won't be used.
vout_scale- VOUT_SCALE value to be set in case of a VOUT trim, if a VOUT trim isn't requested, this parameter won't be used.
trim_val- This parameter will only be used in case of either a VIN or VOUT trim. VIN trim - Value of VIN_SCALE_MONITOR to be set. VOUT trim - Value of output voltage set on the VS pin.
Returns
0 in case of succes, negative error code otherwise

◆ adp1050_unlock_pass()

int adp1050_unlock_pass ( struct adp1050_desc desc,
uint16_t  password,
enum adp1050_pass_type  pass_type 
)

Unlock CHIP/EEPROM/TRIM password.

Parameters
desc- ADP1050 device descriptor
password- Password value.
pass_type- Type of password to be unlocked.
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_vout_margin()

int adp1050_vout_margin ( struct adp1050_desc desc,
uint16_t  margin_high,
uint16_t  margin_low 
)

Set VOUT margins value.

Parameters
desc- ADP1050 device descriptor
margin_high- VOUT margin high value (Y value for V = Y x 2^N format), N defined in VOUT_MODE (-10).
margin_low- VOUT margin low value (Y value for V = Y x 2^N format), N defined in VOUT_MODE (-10).
Returns
0 in case of succes, negative error code otherwise.

◆ adp1050_vout_offset()

int adp1050_vout_offset ( struct adp1050_desc desc,
int16_t  vout_offset 
)

Set output voltage offset.

Parameters
desc- ADP1050 device descriptor
vout_offset- VOUT offset value.
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_vout_scale()

int adp1050_vout_scale ( struct adp1050_desc desc,
int8_t  exp,
uint16_t  mant 
)

Set ADP1050 VOUT scale, regarding the resistor divider assigned to the VS pins.

Parameters
desc- ADP1050 device descriptor
exp- Exponent - 5-bit twos complement
mant- Mantissa - 11-bit twos complement
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_vout_tr()

int adp1050_vout_tr ( struct adp1050_desc desc,
enum adp1050_vout_tr  vout_tr 
)

Set ADP1050 VOUT transition rate.

Parameters
desc- ADP1050 device descriptor
vout_tr- VOUT transition rate value to be set.
Returns
0 in case of succes, negative error code otherwise

◆ adp1050_vout_value()

int adp1050_vout_value ( struct adp1050_desc desc,
uint16_t  vout_command,
uint16_t  vout_max 
)

Set VOUT_COMMAND and VOUT_MAX values.

Parameters
desc- ADP1050 device descriptor
vout_command- VOUT_COMMAND value.
vout_max- VOUT_MAX value.
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function:

◆ adp1050_write()

int adp1050_write ( struct adp1050_desc desc,
uint16_t  command,
uint16_t  data,
uint8_t  bytes_number 
)

Write data to ADP1050.

Parameters
desc- ADP1050 device descriptor
command- Command value
data- Data value to write to the ADP1050. Can be either just a byte or a word.
bytes_number- Number of bytes to write.
Returns
0 in case of succes, negative error code otherwise
Here is the caller graph for this function: