no-OS
Loading...
Searching...
No Matches
ltm4700.c File Reference

Source code of the LTM4700 driver. More...

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <limits.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 "ltm4700.h"
Include dependency graph for ltm4700.c:

Functions

 NO_OS_DECLARE_CRC8_TABLE (ltm4700_crc_table)
 
int ltm4700_verify_manufacturer_id (struct ltm4700_dev *dev)
 Verify manufacturer ID.
 
int ltm4700_verify_manufacturer_model (struct ltm4700_dev *dev)
 Verify manufacturer model.
 
int ltm4700_init (struct ltm4700_dev **device, struct ltm4700_init_param *init_param)
 Initialize the device structure.
 
int ltm4700_remove (struct ltm4700_dev *dev)
 Free or remove device instance.
 
int ltm4700_set_page (struct ltm4700_dev *dev, int page)
 Set PMBus page.
 
int ltm4700_send_byte (struct ltm4700_dev *dev, int page, uint8_t cmd)
 Send a PMBus command to the device.
 
int ltm4700_read_byte (struct ltm4700_dev *dev, int page, uint8_t cmd, uint8_t *data)
 Perform a PMBus read_byte operation.
 
int ltm4700_write_byte (struct ltm4700_dev *dev, int page, uint8_t cmd, uint8_t value)
 Perform a PMBus write_byte operation.
 
int ltm4700_read_word (struct ltm4700_dev *dev, int page, uint8_t cmd, uint16_t *word)
 Perform a PMBus read_word operation.
 
int ltm4700_write_word (struct ltm4700_dev *dev, int page, uint8_t cmd, uint16_t word)
 Perform a PMBus write_word operation.
 
int ltm4700_read_word_data (struct ltm4700_dev *dev, int page, uint8_t cmd, int *data)
 Perform a PMBus read_word operation then perform conversion.
 
int ltm4700_write_word_data (struct ltm4700_dev *dev, int page, uint8_t cmd, int data)
 Perform conversion then perform a PMBus write_word operation.
 
int ltm4700_read_block_data (struct ltm4700_dev *dev, int page, uint8_t cmd, uint8_t *data, size_t nbytes)
 Read a block of bytes.
 
int ltm4700_read_value (struct ltm4700_dev *dev, uint8_t channel, enum ltm4700_value_type value_type, int *value)
 Read specific value type.
 
int ltm4700_read_status (struct ltm4700_dev *dev, uint8_t channel, enum ltm4700_status_type status_type, struct ltm4700_status *status)
 Read status.
 
int ltm4700_vout_value (struct ltm4700_dev *dev, uint8_t channel, int vout_command, int vout_max)
 Set VOUT parameters.
 
int ltm4700_vout_margin (struct ltm4700_dev *dev, uint8_t channel, int margin_low, int margin_high)
 Set VOUT margins.
 
int ltm4700_set_timing (struct ltm4700_dev *dev, uint8_t channel, enum ltm4700_timing_type timing_type, int time)
 Set timing values.
 
int ltm4700_set_operation (struct ltm4700_dev *dev, uint8_t channel, enum ltm4700_operation_type operation)
 Set operation mode.
 
int ltm4700_nvm_cmd (struct ltm4700_dev *dev, enum ltm4700_nvm_cmd_type cmd)
 NVM/EEPROM user commands.
 
int ltm4700_software_reset (struct ltm4700_dev *dev)
 Software reset.
 
int ltm4700_clear_peaks (struct ltm4700_dev *dev)
 Clear peak values.
 

Detailed Description

Source code of the LTM4700 driver.

Author
Carlos Jones Jr (carlo.nosp@m.sjr..nosp@m.jones.nosp@m.@ana.nosp@m.log.c.nosp@m.om)

Copyright 2026(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ ltm4700_clear_peaks()

int ltm4700_clear_peaks ( struct ltm4700_dev * dev)

Clear peak values.

Clear all peak value tracking registers.

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

◆ ltm4700_init()

int ltm4700_init ( struct ltm4700_dev ** device,
struct ltm4700_init_param * init_param )

Initialize the device structure.

Initialize the LTM4700 device structure.

Parameters
device- The device structure
init_param- Initialization parameters
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_nvm_cmd()

int ltm4700_nvm_cmd ( struct ltm4700_dev * dev,
enum ltm4700_nvm_cmd_type cmd )

NVM/EEPROM user commands.

Execute NVM/EEPROM user commands.

Parameters
dev- The device structure
cmd- NVM command type
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_read_block_data()

int ltm4700_read_block_data ( struct ltm4700_dev * dev,
int page,
uint8_t cmd,
uint8_t * data,
size_t nbytes )

Read a block of bytes.

Read a block of bytes from device.

Parameters
dev- The device structure
page- Page number for paged commands
cmd- PMBus command
data- Read data buffer
nbytes- Number of bytes to read
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_read_byte()

int ltm4700_read_byte ( struct ltm4700_dev * dev,
int page,
uint8_t cmd,
uint8_t * data )

Perform a PMBus read_byte operation.

Parameters
dev- The device structure
page- Page number for paged commands
cmd- PMBus command
data- Read data
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_read_status()

int ltm4700_read_status ( struct ltm4700_dev * dev,
uint8_t channel,
enum ltm4700_status_type status_type,
struct ltm4700_status * status )

Read status.

Read status information from device.

Parameters
dev- The device structure
channel- Channel number
status_type- Type of status to read
status- Status structure to fill
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_read_value()

int ltm4700_read_value ( struct ltm4700_dev * dev,
uint8_t channel,
enum ltm4700_value_type value_type,
int * value )

Read specific value type.

Read specific value type (voltage, current, power, temperature)

Parameters
dev- The device structure
channel- Channel number
value_type- Type of value to read
value- Read value in milli-units (mV, mA, mW, m°C, etc.)
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_read_word()

int ltm4700_read_word ( struct ltm4700_dev * dev,
int page,
uint8_t cmd,
uint16_t * word )

Perform a PMBus read_word operation.

Parameters
dev- The device structure
page- Page number for paged commands
cmd- PMBus command
word- Read word data
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_read_word_data()

int ltm4700_read_word_data ( struct ltm4700_dev * dev,
int page,
uint8_t cmd,
int * data )

Perform a PMBus read_word operation then perform conversion.

Parameters
dev- The device structure
page- Page number for paged commands
cmd- PMBus command
data- Converted data in milli-units (mV, mA, mW, m°C, etc.)
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_remove()

int ltm4700_remove ( struct ltm4700_dev * dev)

Free or remove device instance.

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

◆ ltm4700_send_byte()

int ltm4700_send_byte ( struct ltm4700_dev * dev,
int page,
uint8_t cmd )

Send a PMBus command to the device.

Parameters
dev- The device structure
page- Page number for paged commands
cmd- PMBus command
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_set_operation()

int ltm4700_set_operation ( struct ltm4700_dev * dev,
uint8_t channel,
enum ltm4700_operation_type operation )

Set operation mode.

Set operation mode for specified channel.

Parameters
dev- The device structure
channel- Channel number (0, 1, or LTM4700_CHAN_ALL for broadcast)
operation- Operation type
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_set_page()

int ltm4700_set_page ( struct ltm4700_dev * dev,
int page )

Set PMBus page.

Set PMBus page and phase.

Parameters
dev- The device structure
page- Page number (0 or 1 for dual channel device, or 0xFF for broadcast)
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_set_timing()

int ltm4700_set_timing ( struct ltm4700_dev * dev,
uint8_t channel,
enum ltm4700_timing_type timing_type,
int time )

Set timing values.

Set timing values in microseconds.

Parameters
dev- The device structure
channel- Channel number
timing_type- Type of timing to set
time- Time value in microseconds
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_software_reset()

int ltm4700_software_reset ( struct ltm4700_dev * dev)

Software reset.

Perform software reset of the device.

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

◆ ltm4700_verify_manufacturer_id()

int ltm4700_verify_manufacturer_id ( struct ltm4700_dev * dev)

Verify manufacturer ID.

Parameters
dev- Device structure
Returns
0 on success, negative error code otherwise

◆ ltm4700_verify_manufacturer_model()

int ltm4700_verify_manufacturer_model ( struct ltm4700_dev * dev)

Verify manufacturer model.

Parameters
dev- Device structure
Returns
0 on success, negative error code otherwise

◆ ltm4700_vout_margin()

int ltm4700_vout_margin ( struct ltm4700_dev * dev,
uint8_t channel,
int margin_low,
int margin_high )

Set VOUT margins.

Set VOUT margins for overvoltage/undervoltage protection.

Parameters
dev- The device structure
channel- Channel number
margin_low- Low margin value in microvolts
margin_high- High margin value in microvolts
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_vout_value()

int ltm4700_vout_value ( struct ltm4700_dev * dev,
uint8_t channel,
int vout_command,
int vout_max )

Set VOUT parameters.

Set VOUT parameters: VOUT_COMMAND and VOUT_MAX.

Parameters
dev- The device structure
channel- Channel number
vout_command- VOUT command value in microvolts
vout_max- VOUT max value in microvolts
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_write_byte()

int ltm4700_write_byte ( struct ltm4700_dev * dev,
int page,
uint8_t cmd,
uint8_t value )

Perform a PMBus write_byte operation.

Parameters
dev- The device structure
page- Page number for paged commands
cmd- PMBus command
value- Data to write
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_write_word()

int ltm4700_write_word ( struct ltm4700_dev * dev,
int page,
uint8_t cmd,
uint16_t word )

Perform a PMBus write_word operation.

Parameters
dev- The device structure
page- Page number for paged commands
cmd- PMBus command
word- Word data to write
Returns
0 in case of success, negative error code otherwise

◆ ltm4700_write_word_data()

int ltm4700_write_word_data ( struct ltm4700_dev * dev,
int page,
uint8_t cmd,
int data )

Perform conversion then perform a PMBus write_word operation.

Parameters
dev- The device structure
page- Page number for paged commands
cmd- PMBus command
data- Data in milli-units (mV, mA, mW, m°C, etc.) to convert and write
Returns
0 in case of success, negative error code otherwise

◆ NO_OS_DECLARE_CRC8_TABLE()

NO_OS_DECLARE_CRC8_TABLE ( ltm4700_crc_table )