no-OS
Functions | Variables
ltm4686.c File Reference

Source code of the LTM4686 driver. More...

#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 "ltm4686.h"
Include dependency graph for ltm4686.c:

Functions

 NO_OS_DECLARE_CRC8_TABLE (ltm4686_crc_table)
 
int ltm4686_init (struct ltm4686_dev **device, struct ltm4686_init_param *init_param)
 Initialize the device structure. More...
 
int ltm4686_remove (struct ltm4686_dev *dev)
 Free or remove device instance. More...
 
int ltm4686_set_page (struct ltm4686_dev *dev, int page)
 Set page of the device. Page 0x0 - Channel 0 Page 0x1 - Channel 1 Page 0x2 - Channel 2 Page 0x3 - Channel 3 Page 0xff - All channels. More...
 
int ltm4686_send_byte (struct ltm4686_dev *dev, int page, uint8_t cmd)
 Send a PMBus command to the device. More...
 
int ltm4686_read_byte (struct ltm4686_dev *dev, int page, uint8_t cmd, uint8_t *data)
 Perform a raw PMBus read byte operation. More...
 
int ltm4686_write_byte (struct ltm4686_dev *dev, int page, uint8_t cmd, uint8_t value)
 Perform a raw PMBus write byte operation. More...
 
int ltm4686_read_word (struct ltm4686_dev *dev, int page, uint8_t cmd, uint16_t *word)
 Perform a raw PMBus read word operation. More...
 
int ltm4686_write_word (struct ltm4686_dev *dev, int page, uint8_t cmd, uint16_t word)
 Perform a raw PMBus write word operation. More...
 
int ltm4686_read_word_data (struct ltm4686_dev *dev, int page, uint8_t cmd, int *data)
 Perform a PMBus read word operation and converts to actual value. More...
 
int ltm4686_write_word_data (struct ltm4686_dev *dev, int page, uint8_t cmd, int data)
 Converts value to register data and do PMBus write word operation. More...
 
int ltm4686_read_block_data (struct ltm4686_dev *dev, int page, uint8_t cmd, uint8_t *data, size_t nbytes)
 Perform a PMBus read block operation. More...
 
int ltm4686_read_value (struct ltm4686_dev *dev, uint8_t channel, enum ltm4686_value_type value_type, int *value)
 Read a value. More...
 
int ltm4686_read_status (struct ltm4686_dev *dev, uint8_t channel, enum ltm4686_status_type status_type, struct ltm4686_status *status)
 Read statuses. More...
 
int ltm4686_vout_value (struct ltm4686_dev *dev, uint8_t channel, int vout_command, int vout_max)
 Set output voltage and its upper limit. More...
 
int ltm4686_vout_tr (struct ltm4686_dev *dev, uint8_t channel, int tr)
 Set output voltage transition rate. More...
 
int ltm4686_vout_margin (struct ltm4686_dev *dev, uint8_t channel, int margin_low, int margin_high)
 Set output voltage margin. More...
 
int ltm4686_set_vin (struct ltm4686_dev *dev, int vin_on, int vin_off)
 Set input voltage window at which power conversion will proceed. More...
 
int ltm4686_set_timing (struct ltm4686_dev *dev, uint8_t channel, enum ltm4686_timing_type timing_type, int time)
 Set timing values. More...
 
int ltm4686_switch_freq (struct ltm4686_dev *dev, enum ltm4686_freq freq)
 Set switching frequency. More...
 
int ltm4686_pwm_mode (struct ltm4686_dev *dev, uint8_t channel, enum ltm4686_pwm_mode pwm_mode)
 Sets the PWM mode for a specific channel of the LTM4686 device. More...
 
int ltm4686_set_operation (struct ltm4686_dev *dev, uint8_t channel, enum ltm4686_operation_type operation)
 Set channel operation. More...
 
int ltm4686_nvm_cmd (struct ltm4686_dev *dev, enum ltm4686_nvm_cmd_type cmd)
 Perform commands for non-volatile memory/EEPROM. More...
 
int ltm4686_software_reset (struct ltm4686_dev *dev)
 Perform a device software reset. More...
 

Variables

const struct ltm4686_chip_info ltm4686_info []
 

Detailed Description

Source code of the LTM4686 driver.

Author
Cedric Justine Encarnacion (cedri.nosp@m.cjus.nosp@m.tine..nosp@m.enca.nosp@m.rnaci.nosp@m.on@a.nosp@m.nalog.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

◆ ltm4686_init()

int ltm4686_init ( struct ltm4686_dev **  device,
struct ltm4686_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:

◆ ltm4686_nvm_cmd()

int ltm4686_nvm_cmd ( struct ltm4686_dev dev,
enum ltm4686_nvm_cmd_type  cmd 
)

Perform commands for non-volatile memory/EEPROM.

Parameters
dev- Device structure
cmd- NVM commands. Example: LTM4686_STORE_USER LTM4686_COMPARE_USER LTM4686_RESTORE_USER
Returns
0 in case of success, negative error code otherwise

◆ ltm4686_pwm_mode()

int ltm4686_pwm_mode ( struct ltm4686_dev dev,
uint8_t  channel,
enum ltm4686_pwm_mode  pwm_mode 
)

Sets the PWM mode for a specific channel of the LTM4686 device.

Parameters
devThe LTM4686 device structure.
channelThe channel number.
pwm_modeThe PWM mode to be set.
Returns
0 on success, negative error code on failure.

◆ ltm4686_read_block_data()

int ltm4686_read_block_data ( struct ltm4686_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

◆ ltm4686_read_byte()

int ltm4686_read_byte ( struct ltm4686_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:

◆ ltm4686_read_status()

int ltm4686_read_status ( struct ltm4686_dev dev,
uint8_t  channel,
enum ltm4686_status_type  status_type,
struct ltm4686_status status 
)

Read statuses.

Parameters
dev- Device structure
channel- Channel of the status to read
status_type- Status type. Example values: LTM4686_STATUS_BYTE_TYPE LTM4686_STATUS_VOUT_TYPE LTM4686_STATUS_IOUT_TYPE LTM4686_STATUS_INPUT_TYPE LTM4686_STATUS_CML_TYPE
status- Address of the status structure
Returns
0 in case of success, negative error code otherwise

◆ ltm4686_read_value()

int ltm4686_read_value ( struct ltm4686_dev dev,
uint8_t  channel,
enum ltm4686_value_type  value_type,
int *  value 
)

Read a value.

Parameters
dev- Device structure
channel- Channel selected
value_type- Value type. Example values: LTM4686_VIN LTM4686_VOUT LTM4686_IIN LTM4686_IOUT LTM4686_TEMP
value- Address of the read value
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ltm4686_read_word()

int ltm4686_read_word ( struct ltm4686_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:

◆ ltm4686_read_word_data()

int ltm4686_read_word_data ( struct ltm4686_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:

◆ ltm4686_remove()

int ltm4686_remove ( struct ltm4686_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:

◆ ltm4686_send_byte()

int ltm4686_send_byte ( struct ltm4686_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:

◆ ltm4686_set_operation()

int ltm4686_set_operation ( struct ltm4686_dev dev,
uint8_t  channel,
enum ltm4686_operation_type  operation 
)

Set channel operation.

Parameters
dev- Device structure
channel- Channel
operation- Operation. Accepted values are: LTM4686_OPERATION_OFF LTM4686_OPERATION_ON LTM4686_OPERATION_MARGIN_HIGH LTM4686_OPERATION_MARGIN_LOW LTM4686_OPERATION_SEQ_OFF
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ltm4686_set_page()

int ltm4686_set_page ( struct ltm4686_dev dev,
int  page 
)

Set page of the device. Page 0x0 - Channel 0 Page 0x1 - Channel 1 Page 0x2 - Channel 2 Page 0x3 - Channel 3 Page 0xff - All channels.

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

◆ ltm4686_set_timing()

int ltm4686_set_timing ( struct ltm4686_dev dev,
uint8_t  channel,
enum ltm4686_timing_type  timing_type,
int  time 
)

Set timing values.

Parameters
dev- Device structure
channel- Channel
timing_type- Timing value type. Example: LTM4686_TON_DELAY_TYPE LTM4686_TON_RISE_TYPE LTM4686_TOFF_DELAY_TYPE LTM4686_RETRY_DELAY_TYPE
time- Time value in microseconds
Returns
0 in case of success, negative error code otherwise

◆ ltm4686_set_vin()

int ltm4686_set_vin ( struct ltm4686_dev dev,
int  vin_on,
int  vin_off 
)

Set input voltage window at which power conversion will proceed.

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

◆ ltm4686_software_reset()

int ltm4686_software_reset ( struct ltm4686_dev dev)

Perform a device software reset.

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

◆ ltm4686_switch_freq()

int ltm4686_switch_freq ( struct ltm4686_dev dev,
enum ltm4686_freq  freq 
)

Set switching frequency.

Parameters
dev- Device structure
freq- Frequency to set.
Returns
0 in case of success, negative error code otherwise

◆ ltm4686_vout_margin()

int ltm4686_vout_margin ( struct ltm4686_dev dev,
uint8_t  channel,
int  margin_low,
int  margin_high 
)

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

◆ ltm4686_vout_tr()

int ltm4686_vout_tr ( struct ltm4686_dev dev,
uint8_t  channel,
int  tr 
)

Set output voltage transition rate.

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

◆ ltm4686_vout_value()

int ltm4686_vout_value ( struct ltm4686_dev dev,
uint8_t  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

◆ ltm4686_write_byte()

int ltm4686_write_byte ( struct ltm4686_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:

◆ ltm4686_write_word()

int ltm4686_write_word ( struct ltm4686_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:

◆ ltm4686_write_word_data()

int ltm4686_write_word_data ( struct ltm4686_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 ( ltm4686_crc_table  )

Variable Documentation

◆ ltm4686_info

const struct ltm4686_chip_info ltm4686_info[]
Initial value:
= {
[ID_LTM4686] = {
.num_channels = 2,
},
.num_channels = 2,
},
[ID_LTM4673] = {
.num_channels = 4,
},
}
ID_LTM4686B
@ ID_LTM4686B
Definition: ltm4686.h:235
ID_LTM4686
@ ID_LTM4686
Definition: ltm4686.h:234
ID_LTM4673
@ ID_LTM4673
Definition: ltm4686.h:236