no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lt3074.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_i2c.h"
#include "no_os_gpio.h"
#include "no_os_crc8.h"
#include "lt3074.h"
Include dependency graph for lt3074.c:

Macros

#define LT3074_LIN11_MANTISSA_MAX   1023000L
 
#define LT3074_LIN11_MANTISSA_MIN   511000L
 
#define LT3074_LIN11_EXPONENT_MAX   15
 
#define LT3074_LIN11_EXPONENT_MIN   -15
 
#define LT3074_LIN11_MANTISSA_MSK   NO_OS_GENMASK(10,0)
 
#define LT3074_LIN11_EXPONENT_MSK   NO_OS_GENMASK(15,11)
 
#define LT3074_LIN11_EXPONENT(x)
 
#define LT3074_LIN11_MANTISSA(x)
 
#define LT3074_LIN16_EXPONENT   -13
 

Functions

 NO_OS_DECLARE_CRC8_TABLE (lt3074_crc_table)
 
int lt3074_init (struct lt3074_dev **device, struct lt3074_init_param *init_param)
 Initialize the device structure.
 
int lt3074_remove (struct lt3074_dev *dev)
 Free or remove device instance.
 
int lt3074_send_byte (struct lt3074_dev *dev, uint32_t cmd)
 Send a PMBus command to the device.
 
int lt3074_read_byte (struct lt3074_dev *dev, uint32_t cmd, uint8_t *data)
 Perform a raw PMBus read byte operation.
 
int lt3074_write_byte (struct lt3074_dev *dev, uint32_t cmd, uint8_t value)
 Perform a raw PMBus write byte operation.
 
int lt3074_read_word (struct lt3074_dev *dev, uint32_t cmd, uint16_t *word)
 Perform a raw PMBus read word operation.
 
int lt3074_write_word (struct lt3074_dev *dev, uint32_t cmd, uint16_t word)
 Perform a raw PMBus write word operation.
 
int lt3074_read_word_data (struct lt3074_dev *dev, uint32_t cmd, int *data)
 Perform a PMBus read word operation and converts to actual value.
 
int lt3074_write_word_data (struct lt3074_dev *dev, uint32_t cmd, int data)
 Converts value to register data and do PMBus write word operation.
 
int lt3074_read_block_data (struct lt3074_dev *dev, uint32_t cmd, uint8_t *data, size_t nbytes)
 Perform a PMBus read block operation.
 
int lt3074_reg_read (struct lt3074_dev *dev, uint32_t reg, uint32_t *data)
 Generic register read wrapper.
 
int lt3074_reg_write (struct lt3074_dev *dev, uint32_t reg, uint32_t val)
 Generic register write wrapper.
 
int lt3074_read_value (struct lt3074_dev *dev, enum lt3074_value_type value_type, int *value)
 Read a value.
 
int lt3074_read_status (struct lt3074_dev *dev, enum lt3074_status_type status_type, struct lt3074_status *status)
 Read statuses.
 
int lt3074_vout_margin (struct lt3074_dev *dev, enum lt3074_margin margin_high, enum lt3074_margin margin_low)
 Set output voltage margin.
 
int lt3074_set_limit (struct lt3074_dev *dev, enum lt3074_limit_type limit, int limit_val)
 Sets the limit value for a specific fault/warning limits.
 
int lt3074_set_operation (struct lt3074_dev *dev, enum lt3074_operation_type operation)
 Set operation.
 
int lt3074_clear_faults (struct lt3074_dev *dev)
 Clear status registers.
 
int lt3074_set_enable_pin (struct lt3074_dev *dev, bool state)
 Enable/Disable the device using the EN pin.
 
int lt3074_software_reset (struct lt3074_dev *dev)
 Perform a device software reset.
 

Macro Definition Documentation

◆ LT3074_LIN11_EXPONENT

#define LT3074_LIN11_EXPONENT ( x)
Value:
((int16_t)(x) >> 11)

◆ LT3074_LIN11_EXPONENT_MAX

#define LT3074_LIN11_EXPONENT_MAX   15

◆ LT3074_LIN11_EXPONENT_MIN

#define LT3074_LIN11_EXPONENT_MIN   -15

◆ LT3074_LIN11_EXPONENT_MSK

#define LT3074_LIN11_EXPONENT_MSK   NO_OS_GENMASK(15,11)

◆ LT3074_LIN11_MANTISSA

#define LT3074_LIN11_MANTISSA ( x)
Value:
(((int16_t)((x & 0x7FF) << 5)) >> 5)

◆ LT3074_LIN11_MANTISSA_MAX

#define LT3074_LIN11_MANTISSA_MAX   1023000L

◆ LT3074_LIN11_MANTISSA_MIN

#define LT3074_LIN11_MANTISSA_MIN   511000L

◆ LT3074_LIN11_MANTISSA_MSK

#define LT3074_LIN11_MANTISSA_MSK   NO_OS_GENMASK(10,0)

◆ LT3074_LIN16_EXPONENT

#define LT3074_LIN16_EXPONENT   -13

Function Documentation

◆ lt3074_clear_faults()

int lt3074_clear_faults ( struct lt3074_dev * dev)

Clear status registers.

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

◆ lt3074_init()

int lt3074_init ( struct lt3074_dev ** device,
struct lt3074_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:

◆ lt3074_read_block_data()

int lt3074_read_block_data ( struct lt3074_dev * dev,
uint32_t cmd,
uint8_t * data,
size_t nbytes )

Perform a PMBus read block operation.

Parameters
dev- Device structure
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:

◆ lt3074_read_byte()

int lt3074_read_byte ( struct lt3074_dev * dev,
uint32_t cmd,
uint8_t * data )

Perform a raw PMBus read byte operation.

Parameters
dev- Device structure
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:

◆ lt3074_read_status()

int lt3074_read_status ( struct lt3074_dev * dev,
enum lt3074_status_type status_type,
struct lt3074_status * status )

Read statuses.

Parameters
dev- Device structure
status_type- Status type. Example values: LT3074_STATUS_BYTE_TYPE LT3074_STATUS_VOUT_TYPE LT3074_STATUS_IOUT_TYPE LT3074_STATUS_INPUT_TYPE LT3074_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:

◆ lt3074_read_value()

int lt3074_read_value ( struct lt3074_dev * dev,
enum lt3074_value_type value_type,
int * value )

Read a value.

Parameters
dev- Device structure
value_type- Value type. Example values: LT3074_VIN LT3074_VOUT LT3074_IOUT LT3074_TEMP LT3074_VBIAS
value- Address of the read value
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt3074_read_word()

int lt3074_read_word ( struct lt3074_dev * dev,
uint32_t cmd,
uint16_t * word )

Perform a raw PMBus read word operation.

Parameters
dev- Device structure
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:

◆ lt3074_read_word_data()

int lt3074_read_word_data ( struct lt3074_dev * dev,
uint32_t cmd,
int * data )

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

Parameters
dev- Device structure
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:

◆ lt3074_reg_read()

int lt3074_reg_read ( struct lt3074_dev * dev,
uint32_t reg,
uint32_t * data )

Generic register read wrapper.

Parameters
dev- Device structure
reg- PMBus regiser
data- Address of the read data
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt3074_reg_write()

int lt3074_reg_write ( struct lt3074_dev * dev,
uint32_t reg,
uint32_t val )

Generic register write wrapper.

Parameters
dev- Device structure
reg- PMBus register
val- Value to write
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt3074_remove()

int lt3074_remove ( struct lt3074_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:

◆ lt3074_send_byte()

int lt3074_send_byte ( struct lt3074_dev * dev,
uint32_t cmd )

Send a PMBus command to the device.

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

◆ lt3074_set_enable_pin()

int lt3074_set_enable_pin ( struct lt3074_dev * dev,
bool state )

Enable/Disable the device using the EN pin.

Parameters
dev- Device structure
state- Enable/Disable state. 0 for disable, 1 for enable.
Returns
0 in case of success, negative error code otherwise

◆ lt3074_set_limit()

int lt3074_set_limit ( struct lt3074_dev * dev,
enum lt3074_limit_type limit,
int limit_val )

Sets the limit value for a specific fault/warning limits.

Parameters
dev- Device structure
limit- The type of limit to set.
limit_val- The value to set for the specified limit type.
Returns
Returns 0 on success, or a negative error code on failure.
Here is the caller graph for this function:

◆ lt3074_set_operation()

int lt3074_set_operation ( struct lt3074_dev * dev,
enum lt3074_operation_type operation )

Set operation.

Parameters
dev- Device structure
operation- Operation. Accepted values are: LT3074_OPERATION_OFF LT3074_OPERATION_ON LT3074_OPERATION_MARGIN_HIGH LT3074_OPERATION_MARGIN_LOW
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt3074_software_reset()

int lt3074_software_reset ( struct lt3074_dev * dev)

Perform a device software reset.

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

◆ lt3074_vout_margin()

int lt3074_vout_margin ( struct lt3074_dev * dev,
enum lt3074_margin margin_high,
enum lt3074_margin margin_low )

Set output voltage margin.

Parameters
dev- Device structure
margin_high- Upper margin
margin_low- Lower margin
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt3074_write_byte()

int lt3074_write_byte ( struct lt3074_dev * dev,
uint32_t cmd,
uint8_t value )

Perform a raw PMBus write byte operation.

Parameters
dev- Device structure
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:

◆ lt3074_write_word()

int lt3074_write_word ( struct lt3074_dev * dev,
uint32_t cmd,
uint16_t word )

Perform a raw PMBus write word operation.

Parameters
dev- Device structure
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:

◆ lt3074_write_word_data()

int lt3074_write_word_data ( struct lt3074_dev * dev,
uint32_t cmd,
int data )

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

Parameters
dev- Device structure
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 ( lt3074_crc_table )