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

Source file of the MAX17616 Driver. More...

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.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_crc8.h"
#include "max17616.h"
Include dependency graph for max17616.c:

Classes

struct  max17616_direct_coeffs
 

Macros

#define MAX17616_PMBUS_REVISION_VALUE   0x33 /* PMBus Part I and II Rev1.3 */
 
#define MAX17616_MFR_ID_STR   "MAXIM"
 
#define MAX17616_MFR_ID_SIZE   5
 
#define MAX17616_MFR_REV_SIZE   2
 

Functions

int max17616_send_byte (struct max17616_dev *dev, uint8_t cmd)
 Send a PMBus command to the device.
 
int max17616_read_byte (struct max17616_dev *dev, uint8_t cmd, uint8_t *data)
 Perform a raw PMBus read byte operation.
 
int max17616_read_word (struct max17616_dev *dev, uint8_t cmd, uint16_t *word)
 Perform a raw PMBus read word operation.
 
int max17616_read_block_data (struct max17616_dev *dev, uint8_t cmd, uint8_t *data, size_t nbytes)
 Perform a PMBus read block operation.
 
int max17616_write_byte (struct max17616_dev *dev, uint8_t cmd, uint8_t value)
 Perform a raw PMBus write byte operation.
 
int max17616_read_status_byte (struct max17616_dev *dev, uint8_t *status_byte)
 Read STATUS_BYTE register.
 
int max17616_read_status_vout (struct max17616_dev *dev, uint8_t *status_vout)
 Read STATUS_VOUT register.
 
int max17616_read_status_iout (struct max17616_dev *dev, uint8_t *status_iout)
 Read STATUS_IOUT register.
 
int max17616_read_status_input (struct max17616_dev *dev, uint8_t *status_input)
 Read STATUS_INPUT register.
 
int max17616_read_status_temperature (struct max17616_dev *dev, uint8_t *status_temperature)
 Read STATUS_TEMPERATURE register.
 
int max17616_read_status_cml (struct max17616_dev *dev, uint8_t *status_cml)
 Read STATUS_CML register.
 
int max17616_read_status_mfr_specific (struct max17616_dev *dev, uint8_t *status_mfr)
 Read STATUS_MFR_SPECIFIC register.
 
int max17616_read_capability (struct max17616_dev *dev, uint8_t *capability)
 Read device capability register.
 
int max17616_verify_manufacturer_id (struct max17616_dev *dev)
 Read and verify manufacturer ID.
 
int max17616_identify_chip_variant (struct max17616_dev *dev)
 Read device ID and identify chip variant.
 
int max17616_verify_pmbus_revision (struct max17616_dev *dev)
 Verify PMBus revision.
 
int max17616_clear_faults (struct max17616_dev *dev)
 Clear all asserted faults.
 
int max17616_set_mfg_specific_config (struct max17616_dev *dev)
 Set manufacturer-specific configuration.
 
int max17616_read_value (struct max17616_dev *dev, enum max17616_value_type value_type, int32_t *value_milliunit)
 Read a specific value with automatic data conversion.
 
int max17616_set_operation_state (struct max17616_dev *dev, bool enable)
 Set device operation state.
 
int max17616_get_operation_state (struct max17616_dev *dev, bool *enabled)
 Get device operation state.
 
int max17616_get_current_limit_mode (struct max17616_dev *dev, enum max17616_current_limit_mode *clmode)
 Get current limit mode.
 
int max17616_set_current_limit_mode (struct max17616_dev *dev, enum max17616_current_limit_mode clmode)
 Set current limit mode.
 
int max17616_get_istart_ratio (struct max17616_dev *dev, enum max17616_istart_ratio *istart_ratio)
 Get current start ratio.
 
int max17616_set_istart_ratio (struct max17616_dev *dev, enum max17616_istart_ratio istart_ratio)
 Set current start ratio.
 
int max17616_get_overcurrent_timeout (struct max17616_dev *dev, enum max17616_overcurrent_timeout *timeout)
 Get short-term overcurrent duration.
 
int max17616_set_overcurrent_timeout (struct max17616_dev *dev, enum max17616_overcurrent_timeout timeout)
 Set short-term overcurrent duration.
 
int max17616_get_overcurrent_limit (struct max17616_dev *dev, enum max17616_overcurrent_limit *istlim)
 Get the short-term overcurrent limit ratio.
 
int max17616_set_overcurrent_limit (struct max17616_dev *dev, enum max17616_overcurrent_limit istlimit)
 Set the short-term overcurrent limit ratio.
 
int max17616_set_vout_uv_fault_limit_config (struct max17616_dev *dev, enum max17616_nominal_voltage voltage, enum max17616_pgood_threshold threshold)
 Set VOUT UV fault limit configuration using enums.
 
int max17616_get_vout_uv_fault_limit_config (struct max17616_dev *dev, enum max17616_nominal_voltage *voltage, enum max17616_pgood_threshold *threshold)
 Get VOUT UV fault limit configuration using enums.
 
int max17616_read_status (struct max17616_dev *dev, struct max17616_status *status)
 Read MAX17616 device status.
 
int max17616_read_telemetry_all (struct max17616_dev *dev, struct max17616_telemetry *telemetry)
 Read comprehensive telemetry data.
 
int max17616_init (struct max17616_dev **device, struct max17616_init_param *init_param)
 Initialize the device structure.
 
int max17616_remove (struct max17616_dev *dev)
 Free or remove device instance.
 
const char * max17616_get_fault_description (uint16_t group, uint8_t bit)
 Get human-readable description for a specific fault.
 

Detailed Description

Source file of the MAX17616 Driver.

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

Copyright 2025(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.

Macro Definition Documentation

◆ MAX17616_MFR_ID_SIZE

#define MAX17616_MFR_ID_SIZE   5

◆ MAX17616_MFR_ID_STR

#define MAX17616_MFR_ID_STR   "MAXIM"

◆ MAX17616_MFR_REV_SIZE

#define MAX17616_MFR_REV_SIZE   2

◆ MAX17616_PMBUS_REVISION_VALUE

#define MAX17616_PMBUS_REVISION_VALUE   0x33 /* PMBus Part I and II Rev1.3 */

Function Documentation

◆ max17616_clear_faults()

int max17616_clear_faults ( struct max17616_dev * dev)

Clear all asserted faults.

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

◆ max17616_get_current_limit_mode()

int max17616_get_current_limit_mode ( struct max17616_dev * dev,
enum max17616_current_limit_mode * clmode )

Get current limit mode.

Parameters
dev- Device structure
clmode- Pointer to the current limit mode setting
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_get_fault_description()

const char * max17616_get_fault_description ( uint16_t group,
uint8_t bit )

Get human-readable description for a specific fault.

Parameters
group- Fault group identifier
bit- Fault bit position
Returns
Pointer to fault description string or NULL if not found

◆ max17616_get_istart_ratio()

int max17616_get_istart_ratio ( struct max17616_dev * dev,
enum max17616_istart_ratio * istart_ratio )

Get current start ratio.

Parameters
dev- Device structure
istart_ratio- Pointer to the current start ratio setting
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_get_operation_state()

int max17616_get_operation_state ( struct max17616_dev * dev,
bool * enabled )

Get device operation state.

Parameters
dev- Device structure
enabled- Pointer to store operation state
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_get_overcurrent_limit()

int max17616_get_overcurrent_limit ( struct max17616_dev * dev,
enum max17616_overcurrent_limit * istlim )

Get the short-term overcurrent limit ratio.

Parameters
dev- Device structure
istlim- Pointer to store ISTLIM setting
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_get_overcurrent_timeout()

int max17616_get_overcurrent_timeout ( struct max17616_dev * dev,
enum max17616_overcurrent_timeout * timeout )

Get short-term overcurrent duration.

Parameters
dev- Device structure
timeout- Pointer to store short-term overcurrent duration setting
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_get_vout_uv_fault_limit_config()

int max17616_get_vout_uv_fault_limit_config ( struct max17616_dev * dev,
enum max17616_nominal_voltage * voltage,
enum max17616_pgood_threshold * threshold )

Get VOUT UV fault limit configuration using enums.

Parameters
dev- Device structure
voltage- Pointer to store nominal voltage selection
threshold- Pointer to store PGOOD rising threshold
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_identify_chip_variant()

int max17616_identify_chip_variant ( struct max17616_dev * dev)

Read device ID and identify chip variant.

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

◆ max17616_init()

int max17616_init ( struct max17616_dev ** device,
struct max17616_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:

◆ max17616_read_block_data()

int max17616_read_block_data ( struct max17616_dev * dev,
uint8_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- Expected size of the block in bytes (excluding byte count)
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_byte()

int max17616_read_byte ( struct max17616_dev * dev,
uint8_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:

◆ max17616_read_capability()

int max17616_read_capability ( struct max17616_dev * dev,
uint8_t * capability )

Read device capability register.

Parameters
dev- Device structure
capability- Pointer to store capability byte
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_status()

int max17616_read_status ( struct max17616_dev * dev,
struct max17616_status * status )

Read MAX17616 device status.

Parameters
dev- Device structure
status- Pointer to store status
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_status_byte()

int max17616_read_status_byte ( struct max17616_dev * dev,
uint8_t * status_byte )

Read STATUS_BYTE register.

Parameters
dev- Device structure
status_byte- Pointer to store status byte
Returns
0 on success, negative error code otherwise

◆ max17616_read_status_cml()

int max17616_read_status_cml ( struct max17616_dev * dev,
uint8_t * status_cml )

Read STATUS_CML register.

Parameters
dev- Device structure
status_cml- Pointer to store status CML byte
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_status_input()

int max17616_read_status_input ( struct max17616_dev * dev,
uint8_t * status_input )

Read STATUS_INPUT register.

Parameters
dev- Device structure
status_input- Pointer to store status INPUT byte
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_status_iout()

int max17616_read_status_iout ( struct max17616_dev * dev,
uint8_t * status_iout )

Read STATUS_IOUT register.

Parameters
dev- Device structure
status_iout- Pointer to store status IOUT byte
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_status_mfr_specific()

int max17616_read_status_mfr_specific ( struct max17616_dev * dev,
uint8_t * status_mfr )

Read STATUS_MFR_SPECIFIC register.

Parameters
dev- Device structure
status_mfr- Pointer to store status MFR SPECIFIC byte
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_status_temperature()

int max17616_read_status_temperature ( struct max17616_dev * dev,
uint8_t * status_temperature )

Read STATUS_TEMPERATURE register.

Parameters
dev- Device structure
status_temperature- Pointer to store status TEMPERATURE byte
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_status_vout()

int max17616_read_status_vout ( struct max17616_dev * dev,
uint8_t * status_vout )

Read STATUS_VOUT register.

Parameters
dev- Device structure
status_vout- Pointer to store status VOUT byte
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_telemetry_all()

int max17616_read_telemetry_all ( struct max17616_dev * dev,
struct max17616_telemetry * telemetry )

Read comprehensive telemetry data.

Parameters
dev- Device structure
telemetry- Telemetry structure to populate
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_value()

int max17616_read_value ( struct max17616_dev * dev,
enum max17616_value_type value_type,
int32_t * value_milliunit )

Read a specific value with automatic data conversion.

Parameters
dev- Device structure
value_type- Type of value to read
value_milliunit- Pointer to store the converted value (mV/mA/mW/mC)
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_read_word()

int max17616_read_word ( struct max17616_dev * dev,
uint8_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:

◆ max17616_remove()

int max17616_remove ( struct max17616_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:

◆ max17616_send_byte()

int max17616_send_byte ( struct max17616_dev * dev,
uint8_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:

◆ max17616_set_current_limit_mode()

int max17616_set_current_limit_mode ( struct max17616_dev * dev,
enum max17616_current_limit_mode clmode )

Set current limit mode.

Parameters
dev- Device structure
clmode- Current limit mode setting
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_set_istart_ratio()

int max17616_set_istart_ratio ( struct max17616_dev * dev,
enum max17616_istart_ratio istart_ratio )

Set current start ratio.

Parameters
dev- Device structure
istart_ratio- Current start ratio setting
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_set_mfg_specific_config()

int max17616_set_mfg_specific_config ( struct max17616_dev * dev)

Set manufacturer-specific configuration.

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

◆ max17616_set_operation_state()

int max17616_set_operation_state ( struct max17616_dev * dev,
bool enable )

Set device operation state.

Parameters
dev- Device structure
enable- true to enable, false to disable
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_set_overcurrent_limit()

int max17616_set_overcurrent_limit ( struct max17616_dev * dev,
enum max17616_overcurrent_limit istlimit )

Set the short-term overcurrent limit ratio.

Parameters
dev- Device structure
istlimit- Short-term overcurrent limit ratio setting
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_set_overcurrent_timeout()

int max17616_set_overcurrent_timeout ( struct max17616_dev * dev,
enum max17616_overcurrent_timeout timeout )

Set short-term overcurrent duration.

Parameters
dev- Device structure
timeout- Short-term overcurrent duration setting
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_set_vout_uv_fault_limit_config()

int max17616_set_vout_uv_fault_limit_config ( struct max17616_dev * dev,
enum max17616_nominal_voltage voltage,
enum max17616_pgood_threshold threshold )

Set VOUT UV fault limit configuration using enums.

Parameters
dev- Device structure
voltage- Nominal voltage selection (bits 4:2)
threshold- PGOOD rising threshold (bits 1:0)
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ max17616_verify_manufacturer_id()

int max17616_verify_manufacturer_id ( struct max17616_dev * dev)

Read and verify manufacturer ID.

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

◆ max17616_verify_pmbus_revision()

int max17616_verify_pmbus_revision ( struct max17616_dev * dev)

Verify PMBus revision.

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

◆ max17616_write_byte()

int max17616_write_byte ( struct max17616_dev * dev,
uint8_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: