no-OS
Functions
lt7182s.c File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <errno.h>
#include "no_os_units.h"
#include "no_os_util.h"
#include "no_os_delay.h"
#include "no_os_alloc.h"
#include "no_os_pwm.h"
#include "no_os_i2c.h"
#include "no_os_gpio.h"
#include "no_os_crc8.h"
#include "lt7182s.h"
Include dependency graph for lt7182s.c:

Functions

 NO_OS_DECLARE_CRC8_TABLE (lt7182s_crc_table)
 
int lt7182s_init (struct lt7182s_dev **device, struct lt7182s_init_param *init_param)
 Initialize the device structure. More...
 
int lt7182s_remove (struct lt7182s_dev *dev)
 Free or remove device instance. More...
 
int lt7182s_set_page (struct lt7182s_dev *dev, int page)
 Set page of the device. Page 0x0 - Channel 0 Page 0x1 - Channel 1 Page 0xff - Both channels. More...
 
int lt7182s_send_byte (struct lt7182s_dev *dev, int page, uint8_t cmd)
 Send a PMBus command to the device. More...
 
int lt7182s_read_byte (struct lt7182s_dev *dev, int page, uint8_t cmd, uint8_t *data)
 Perform a raw PMBus read byte operation. More...
 
int lt7182s_write_byte (struct lt7182s_dev *dev, int page, uint8_t cmd, uint8_t value)
 Perform a raw PMBus write byte operation. More...
 
int lt7182s_read_word (struct lt7182s_dev *dev, int page, uint8_t cmd, uint16_t *word)
 Perform a raw PMBus read word operation. More...
 
int lt7182s_write_word (struct lt7182s_dev *dev, int page, uint8_t cmd, uint16_t word)
 Perform a raw PMBus write word operation. More...
 
int lt7182s_read_word_data (struct lt7182s_dev *dev, int page, uint8_t cmd, int *data)
 Perform a PMBus read word operation and converts to actual value. More...
 
int lt7182s_write_word_data (struct lt7182s_dev *dev, int page, uint8_t cmd, int data)
 Converts value to register data and do PMBus write word operation. More...
 
int lt7182s_read_block_data (struct lt7182s_dev *dev, int page, uint8_t cmd, uint8_t *data, size_t nbytes)
 Perform a PMBus read block operation. More...
 
int lt7182s_read_value (struct lt7182s_dev *dev, int channel, enum lt7182s_value_type value_type, int *value)
 Read a value. More...
 
int lt7182s_read_status (struct lt7182s_dev *dev, int channel, enum lt7182s_status_type status_type, struct lt7182s_status *status)
 Read statuses. More...
 
int lt7182s_vout_value (struct lt7182s_dev *dev, int channel, int vout_command, int vout_max)
 Set output voltage and its upper limit. More...
 
int lt7182s_vout_tr (struct lt7182s_dev *dev, int channel, int tr)
 Set output voltage transition rate. More...
 
int lt7182s_vout_margin (struct lt7182s_dev *dev, int channel, int margin_high, int margin_low)
 Set output voltage margin. More...
 
int lt7182s_set_vin (struct lt7182s_dev *dev, int channel, int vin_on, int vin_off)
 Set input voltage window at which power conversion will proceed. More...
 
int lt7182s_set_timing (struct lt7182s_dev *dev, int channel, enum lt7182s_timing_type timing_type, int time)
 Set timing values. More...
 
int lt7182s_switch_freq (struct lt7182s_dev *dev, int freq)
 Set switching frequency. More...
 
int lt7182s_pwm_mode (struct lt7182s_dev *dev, int channel, enum lt7182s_pwm_mode pwm_mode)
 Set output PWM mode. More...
 
int lt7182s_pwm_phase (struct lt7182s_dev *dev, int channel, int phase)
 Set output PWM phase. More...
 
int lt7182s_set_limit (struct lt7182s_dev *dev, int channel, enum lt7182s_limit_type limit, int limit_val)
 Set overvalue and undervalue limits. More...
 
int lt7182s_set_operation (struct lt7182s_dev *dev, int channel, enum lt7182s_operation_type operation)
 Set channel operation. More...
 
int lt7182s_set_channel_state (struct lt7182s_dev *dev, int channel, bool state)
 Set channel state using the RUN pin. More...
 
int lt7182s_sync_config (struct lt7182s_dev *dev, bool input_clk, bool output_clk)
 Configure SYNC pin for clock synchronization. More...
 
int lt7182s_adc_control (struct lt7182s_dev *dev, bool low_freq_telemetry, bool debug_telemetry)
 Configure ADC control. More...
 
int lt7182s_nvm_cmd (struct lt7182s_dev *dev, enum lt7182s_nvm_cmd_type cmd)
 Perform commands for non-volatile memory/EEPROM. More...
 
int lt7182s_clear_faults (struct lt7182s_dev *dev)
 Clear all asserted faults. More...
 
int lt7182s_software_reset (struct lt7182s_dev *dev)
 Perform a device software reset. More...
 

Function Documentation

◆ lt7182s_adc_control()

int lt7182s_adc_control ( struct lt7182s_dev dev,
bool  low_freq_telemetry,
bool  debug_telemetry 
)

Configure ADC control.

Parameters
dev- Device structure
low_freq_telemetry- Enable for low frequency telemetry (every 100ms)
debug_telemetry- Enable for debug telemetry with EXTVcc and Ith
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_clear_faults()

int lt7182s_clear_faults ( struct lt7182s_dev dev)

Clear all asserted faults.

Parameters
dev- Device structure
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_init()

int lt7182s_init ( struct lt7182s_dev **  device,
struct lt7182s_init_param init_param 
)

Initialize the device structure.

Parameters
device- Device structure
init_param- Initialization parameters
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_nvm_cmd()

int lt7182s_nvm_cmd ( struct lt7182s_dev dev,
enum lt7182s_nvm_cmd_type  cmd 
)

Perform commands for non-volatile memory/EEPROM.

Parameters
dev- Device structure
cmd- NVM commands. Example: LT7182S_LOCK_USER LT7182S_UNLOCK_USER LT7182S_STORE_USER LT7182S_COMPARE_USER LT7182S_RESTORE_USER
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_pwm_mode()

int lt7182s_pwm_mode ( struct lt7182s_dev dev,
int  channel,
enum lt7182s_pwm_mode  pwm_mode 
)

Set output PWM mode.

Parameters
dev- Device structure
channel- Output channel
pwm_mode-
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_pwm_phase()

int lt7182s_pwm_phase ( struct lt7182s_dev dev,
int  channel,
int  phase 
)

Set output PWM phase.

Parameters
dev- Device structure
channel- Channel
phase- Phase in milli-degrees
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_read_block_data()

int lt7182s_read_block_data ( struct lt7182s_dev dev,
int  page,
uint8_t  cmd,
uint8_t *  data,
size_t  nbytes 
)

Perform a PMBus read block operation.

Parameters
dev- Device structure
page- Page/channel of the command
cmd- PMBus command
data- Address of the read block
nbytes- Size of the block in bytes
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_read_byte()

int lt7182s_read_byte ( struct lt7182s_dev dev,
int  page,
uint8_t  cmd,
uint8_t *  data 
)

Perform a raw PMBus read byte operation.

Parameters
dev- Device structure
page- Page or channel of the command
cmd- PMBus command
data- Address of the byte read
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_read_status()

int lt7182s_read_status ( struct lt7182s_dev dev,
int  channel,
enum lt7182s_status_type  status_type,
struct lt7182s_status status 
)

Read statuses.

Parameters
dev- Device structure
channel- Channel of the status to read
status_type- Status type. Example values: LT7182S_STATUS_BYTE_TYPE LT7182S_STATUS_VOUT_TYPE LT7182S_STATUS_IOUT_TYPE LT7182S_STATUS_INPUT_TYPE LT7182S_STATUS_CML_TYPE
status- Address of the status structure
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_read_value()

int lt7182s_read_value ( struct lt7182s_dev dev,
int  channel,
enum lt7182s_value_type  value_type,
int *  value 
)

Read a value.

Parameters
dev- Device structure
channel- Channel selected
value_type- Value type. Example values: LT7182S_VIN LT7182S_VOUT LT7182S_IIN LT7182S_IOUT LT7182S_TEMP LT7182S_FREQUENCY
value- Address of the read value
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_read_word()

int lt7182s_read_word ( struct lt7182s_dev dev,
int  page,
uint8_t  cmd,
uint16_t *  word 
)

Perform a raw PMBus read word operation.

Parameters
dev- Device structure
page- Page/channel of the command
cmd- PMBus command
word- Address of the read word
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_read_word_data()

int lt7182s_read_word_data ( struct lt7182s_dev dev,
int  page,
uint8_t  cmd,
int *  data 
)

Perform a PMBus read word operation and converts to actual value.

Parameters
dev- Device structure
page- Page/channel of the command
cmd- PMBus command
data- Address of data read
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_remove()

int lt7182s_remove ( struct lt7182s_dev dev)

Free or remove device instance.

Parameters
dev- The device structure
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_send_byte()

int lt7182s_send_byte ( struct lt7182s_dev dev,
int  page,
uint8_t  cmd 
)

Send a PMBus command to the device.

Parameters
dev- Device structure
page- Page or channel of the command
cmd- PMBus command
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_set_channel_state()

int lt7182s_set_channel_state ( struct lt7182s_dev dev,
int  channel,
bool  state 
)

Set channel state using the RUN pin.

Parameters
dev- Device structure
channel- Channel
state- true for ON, false for OFF
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_set_limit()

int lt7182s_set_limit ( struct lt7182s_dev dev,
int  channel,
enum lt7182s_limit_type  limit,
int  limit_val 
)

Set overvalue and undervalue limits.

Parameters
dev- Device structure
channel- Channel
limit- Limit value type. Example: LT7182S_VOUT_OV_FAULT_LIMIT_TYPE LT7182S_OT_WARN_LIMIT_TYPE LT7182S_TON_MAX_FAULT_LIMIT_TYPE LT7182S_IIN_OC_WARN_LIMIT_TYPE
limit_val- Limit value in milli-units for voltage and current, and microseconds for timing.
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_set_operation()

int lt7182s_set_operation ( struct lt7182s_dev dev,
int  channel,
enum lt7182s_operation_type  operation 
)

Set channel operation.

Parameters
dev- Device structure
channel- Channel
operation- Operation. Accepted values are: LT7182S_OPERATION_OFF LT7182S_OPERATION_ON LT7182S_OPERATION_MARGIN_HIGH LT7182S_OPERATION_MARGIN_LOW LT7182S_OPERATION_SEQ_OFF
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_set_page()

int lt7182s_set_page ( struct lt7182s_dev dev,
int  page 
)

Set page of the device. Page 0x0 - Channel 0 Page 0x1 - Channel 1 Page 0xff - Both channels.

Parameters
dev- Device structure
page- Page to set
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_set_timing()

int lt7182s_set_timing ( struct lt7182s_dev dev,
int  channel,
enum lt7182s_timing_type  timing_type,
int  time 
)

Set timing values.

Parameters
dev- Device structure
channel- Channel
timing_type- Timing value type. Example: LT7182S_TON_DELAY_TYPE LT7182S_TON_RISE_TYPE LT7182S_TOFF_DELAY_TYPE LT7182_RETRY_DELAY_TYPE
time- Time value in microseconds
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_set_vin()

int lt7182s_set_vin ( struct lt7182s_dev dev,
int  channel,
int  vin_on,
int  vin_off 
)

Set input voltage window at which power conversion will proceed.

Parameters
dev- Device structure
channel- Channel
vin_on- Input voltage in millivolts at which conversion will start
vin_off- Input voltage in millivolts at which conversion will stop
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_software_reset()

int lt7182s_software_reset ( struct lt7182s_dev dev)

Perform a device software reset.

Parameters
dev- Device structure
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_switch_freq()

int lt7182s_switch_freq ( struct lt7182s_dev dev,
int  freq 
)

Set switching frequency.

Parameters
dev- Device structure
freq- Frequency to set in Hz. Value should be between 400 kHz and 4000 kHz.
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_sync_config()

int lt7182s_sync_config ( struct lt7182s_dev dev,
bool  input_clk,
bool  output_clk 
)

Configure SYNC pin for clock synchronization.

Parameters
dev- Device structure
input_clk- Enable to use SYNC clock input
output_clk- Enable to use SYNC output clock
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_vout_margin()

int lt7182s_vout_margin ( struct lt7182s_dev dev,
int  channel,
int  margin_high,
int  margin_low 
)

Set output voltage margin.

Parameters
dev- Device structure
channel- Channel
margin_high- Upper margin in millivolts
margin_low- Lower margin in millivolts
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_vout_tr()

int lt7182s_vout_tr ( struct lt7182s_dev dev,
int  channel,
int  tr 
)

Set output voltage transition rate.

Parameters
dev- Device structure
channel- Channel
tr- Transition rate in V/s or mV/ms
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_vout_value()

int lt7182s_vout_value ( struct lt7182s_dev dev,
int  channel,
int  vout_command,
int  vout_max 
)

Set output voltage and its upper limit.

Parameters
dev- Device structure
channel- Channel
vout_command- Output voltage in millivolts
vout_max- Output voltage upper limit in millivolts
Returns
0 in case of success, negative error code otherwise

◆ lt7182s_write_byte()

int lt7182s_write_byte ( struct lt7182s_dev dev,
int  page,
uint8_t  cmd,
uint8_t  value 
)

Perform a raw PMBus write byte operation.

Parameters
dev- Device structure
page- Page/channel of the command
cmd- PMBus command
value- Byte to be written
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_write_word()

int lt7182s_write_word ( struct lt7182s_dev dev,
int  page,
uint8_t  cmd,
uint16_t  word 
)

Perform a raw PMBus write word operation.

Parameters
dev- Device structure
page- Page/channel of the command
cmd- PMBus command
word- Word to write
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt7182s_write_word_data()

int lt7182s_write_word_data ( struct lt7182s_dev dev,
int  page,
uint8_t  cmd,
int  data 
)

Converts value to register data and do PMBus write word operation.

Parameters
dev- Device structure
page- Page/channel of the command
cmd- PMBus command
data- Value to write
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ NO_OS_DECLARE_CRC8_TABLE()

NO_OS_DECLARE_CRC8_TABLE ( lt7182s_crc_table  )