no-OS
|
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"
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... | |
Source file for the ADP1050 Driver.
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:
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.
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.
desc | - ADP1050 device descriptor |
old_pass | - Old password value. |
new_pass | - New password value. |
pass_type | - Password type (CHIP/EEPROM). |
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.
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. |
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.
desc | - ADP1050 device descriptor |
state_on | - true - Turn on frequency synchronization. false - Turn off frequency synchronization. |
int adp1050_init | ( | struct adp1050_desc ** | desc, |
struct adp1050_init_param * | init_param | ||
) |
Initialize the ADP1050 device.
desc | - ADP1050 device descriptor |
init_param | - Initialization parameter containing information about the ADP1050 device to be initialized. |
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.
desc | - ADP1050 device descriptor |
password | - Wrong password to be introduced for password lockage. |
pass_type | - Password type to be used for register lockage. |
int adp1050_pulse_skipping | ( | struct adp1050_desc * | desc, |
uint8_t | pulse_threshold, | ||
bool | state_on | ||
) |
Enable or disbale the pulse skipping mode.
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 |
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.
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. |
int adp1050_pwm_modulation | ( | struct adp1050_desc * | desc, |
enum adp1050_mod | mod, | ||
enum adp1050_channel | chan, | ||
bool | sign | ||
) |
Set PWM modulation for requested channel.
desc | - ADP1050 device descriptor |
mod | - Type of modulation. |
chan | - Requested channel. |
sign | - true - Positive modulation sign false - Negative modulation sign. |
int adp1050_read | ( | struct adp1050_desc * | desc, |
uint16_t | command, | ||
uint8_t * | data, | ||
uint8_t | bytes_number | ||
) |
Read data from ADP1050.
desc | - ADP1050 device descriptor |
command | - Command value. |
data | - Buffer with received data. |
bytes_number | - Number of bytes to read. |
int adp1050_read_status | ( | struct adp1050_desc * | desc, |
enum adp1050_status_type | status, | ||
uint16_t * | status_val | ||
) |
Read statuses.
desc | - ADP1050 device descriptor |
status | - Status type. |
status_val | - Status value to be returned. |
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.
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. |
int adp1050_read_vsense | ( | struct adp1050_desc * | desc, |
uint16_t * | vsense | ||
) |
Read Voltage Sense output raw value from the ADP1050.
desc | - ADP1050 device descriptor |
vsense | - VS(VOUT) raw value to be received of the parallel circuit. |
int adp1050_remove | ( | struct adp1050_desc * | desc | ) |
Free the resources allocated by the adp1050_init()
desc | - ADP1050 device descriptor |
int adp1050_send_command | ( | struct adp1050_desc * | desc, |
uint16_t | command | ||
) |
Send command byte/word to ADP1050.
desc | - ADP1050 device descriptor |
command | - Value of the command. |
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.
desc | - ADP1050_device_descriptor. |
fast_fault | - Fast fault limit value for N counter. |
climit_ref | - Current limit cylcle-by-cycle reference. |
int adp1050_set_close_loop | ( | struct adp1050_desc * | desc | ) |
Set close loop operation.
desc | - ADP1050 device descriptor |
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.
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. |
int adp1050_set_feedforward | ( | struct adp1050_desc * | desc, |
bool | state_on | ||
) |
Enable or disable voltage input feedforward for edge modulation.
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. |
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.
desc | - ADP1050 device descriptor |
fault_response | - Device response to flag being set. |
after_fault | - Action when the falg is cleared. |
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.
desc | - ADP1050 device descriptor. |
rising_edge | - Rising edge timing. |
falling_edge | - Falling edge timing. |
chan | - Channel t be set in open-loop. |
int adp1050_set_pwm | ( | struct adp1050_desc * | desc, |
enum adp1050_channel | chan, | ||
enum adp1050_freq | freq | ||
) |
Set PWM channel and frequency.
desc | - ADP1050 device descriptor |
chan | - Selected channel. |
freq | - Selected frequency. |
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.
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. |
int adp1050_software_reset | ( | struct adp1050_desc * | desc | ) |
Software reset the ADP1050.
desc | - ADP1050 device descriptor |
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).
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. |
int adp1050_unlock_pass | ( | struct adp1050_desc * | desc, |
uint16_t | password, | ||
enum adp1050_pass_type | pass_type | ||
) |
Unlock CHIP/EEPROM/TRIM password.
desc | - ADP1050 device descriptor |
password | - Password value. |
pass_type | - Type of password to be unlocked. |
int adp1050_vout_margin | ( | struct adp1050_desc * | desc, |
uint16_t | margin_high, | ||
uint16_t | margin_low | ||
) |
Set VOUT margins value.
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). |
int adp1050_vout_offset | ( | struct adp1050_desc * | desc, |
int16_t | vout_offset | ||
) |
Set output voltage offset.
desc | - ADP1050 device descriptor |
vout_offset | - VOUT offset value. |
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.
desc | - ADP1050 device descriptor |
exp | - Exponent - 5-bit twos complement |
mant | - Mantissa - 11-bit twos complement |
int adp1050_vout_tr | ( | struct adp1050_desc * | desc, |
enum adp1050_vout_tr | vout_tr | ||
) |
Set ADP1050 VOUT transition rate.
desc | - ADP1050 device descriptor |
vout_tr | - VOUT transition rate value to be set. |
int adp1050_vout_value | ( | struct adp1050_desc * | desc, |
uint16_t | vout_command, | ||
uint16_t | vout_max | ||
) |
Set VOUT_COMMAND and VOUT_MAX values.
desc | - ADP1050 device descriptor |
vout_command | - VOUT_COMMAND value. |
vout_max | - VOUT_MAX value. |
int adp1050_write | ( | struct adp1050_desc * | desc, |
uint16_t | command, | ||
uint16_t | data, | ||
uint8_t | bytes_number | ||
) |
Write data to ADP1050.
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. |