HPM SDK
HPMicro Software Development Kit
hpm_pmbus.c File Reference
#include "hpm_pmbus.h"
#include "hpm_pmbus_private.h"
#include "hpm_smbus.h"

Data Structures

struct  hpm_pmbus_cfg_t
 

Functions

static hpm_pmbus_cfg_thpm_pmbus_get_cfg_obj (I2C_Type *ptr)
 
static uint8_t hpm_smbus_pec_crc8_in_command (uint8_t slave_addr, uint8_t command, uint8_t *data, uint32_t len, bool read, bool block)
 
void hpm_pmbus_isr_handler (I2C_Type *ptr)
 Handles the HPM PMBUS interrupt service request. More...
 
hpm_stat_t hpm_pmbus_slave_init (I2C_Type *ptr, uint8_t slave_addr)
 PMBus Slave Initialization. More...
 
hpm_stat_t hpm_pmbus_master_read (I2C_Type *ptr, uint8_t slave_address, uint8_t command, uint8_t *data, uint32_t *len)
 Reads data from a PMBus slave device. More...
 
hpm_stat_t hpm_pmbus_master_write (I2C_Type *ptr, uint8_t slave_address, uint8_t command, uint8_t *data, uint32_t len)
 Writes data to a PMBus slave device. More...
 
hpm_stat_t hpm_pmbus_slave_command_transaction_install (I2C_Type *ptr, uint8_t command, uint8_t *wdata, uint8_t *rdata, uint32_t len, hpm_pmbus_complete_cb_t callback)
 Installs a PMBus Slave Command Transaction. More...
 
hpm_stat_t hpm_pmbus_slave_command_transaction_uninstall (I2C_Type *ptr, uint8_t command)
 Uninstalls a specified PMBus slave command transaction. More...
 

Variables

const hpm_pmbus_cmd_param_t pmbus_cmd_param_table []
 
static hpm_pmbus_cfg_t hpm_pmbus_cfg_table []
 

Function Documentation

◆ hpm_pmbus_get_cfg_obj()

static hpm_pmbus_cfg_t* hpm_pmbus_get_cfg_obj ( I2C_Type ptr)
static

◆ hpm_pmbus_isr_handler()

void hpm_pmbus_isr_handler ( I2C_Type ptr)

Handles the HPM PMBUS interrupt service request.

This function serves as an interrupt service routine (ISR) handler for communication with PMBUS devices over I2C.

Parameters
ptrA pointer to the I2C

◆ hpm_pmbus_master_read()

hpm_stat_t hpm_pmbus_master_read ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t  command,
uint8_t *  data,
uint32_t *  len 
)

Reads data from a PMBus slave device.

This function reads data from a specified PMBus slave device over the I2C bus. It first sends a command and then reads the response data. Primarily used for communication with PMBus-compatible power management devices to retrieve device status or measurement data.

Parameters
ptrPointer to the base address of the I2C controller
slave_addressThe 7-bit PMBus address of the slave device, used to select the correct slave device
commandThe PMBus command sent to the slave device, specifying the type of data or register to read
dataPointer to store the data returned from the slave device; this function will store the read data into the buffer pointed to by this pointer
lenPointer to a variable that specifies the maximum read length; this function will write the actual read length into this variable
Returns
hpm_stat_t Returns the status of the read operation, indicating success or various error states

◆ hpm_pmbus_master_write()

hpm_stat_t hpm_pmbus_master_write ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t  command,
uint8_t *  data,
uint32_t  len 
)

Writes data to a PMBus slave device.

function is used to send commands and data to a slave device over the I2C interface. It is primarily intended for communication with PMBus-compatible devices, allowing the host to send instructions and data to PMBus-compatible devices.

Parameters
ptrPointer to the base address of the I2C controller
slave_addressThe 7-bit address of the slave device, used to address the slave device on the I2C bus
commandThe command or register address to be sent to the slave device
dataPointer to the data to be written to the slave device; the data will be written in order
lenThe length of the data to be written, in bytes
Returns
Returns the result of the write operation: HPM_STAT_SUCCESS indicates success, other values indicate different error states

Note: Before using this function, ensure that the I2C controller has been properly initialized, and the clock and interrupts (if needed) have also been configured.

◆ hpm_pmbus_slave_command_transaction_install()

hpm_stat_t hpm_pmbus_slave_command_transaction_install ( I2C_Type ptr,
uint8_t  command,
uint8_t *  wdata,
uint8_t *  rdata,
uint32_t  len,
hpm_pmbus_complete_cb_t  callback 
)

Installs a PMBus Slave Command Transaction.

This function installs a PMBus slave command transaction for writing and reading data. The command is for the master, such as the read command, which is read for the master and write for the slave

Parameters
ptrPointer to the base address of the I2C
commandPMBus command byte specifying the PMBus command to be sen
wdataPointer to the data to be written, containing the data to write to the slave
rdataPointer to the buffer where the data read from the slave will be stored
lenLength of the data to be transferred, in bytes
callbackPointer to the completion callback function that will be called when the transaction completes
Returns
hpm_stat_t Returns the installation status of the transaction, indicating success or the reason for failure

◆ hpm_pmbus_slave_command_transaction_uninstall()

hpm_stat_t hpm_pmbus_slave_command_transaction_uninstall ( I2C_Type ptr,
uint8_t  command 
)

Uninstalls a specified PMBus slave command transaction.

This function is used to uninstall a PMBus slave command transaction to reduce unnecessary resource usage. In certain cases, if a specific slave command transaction is no longer needed, it can be uninstalled using this function to free up related resources.

Parameters
ptrPointer to the I2C
commandThe PMBus command to uninstall. This parameter specifies the exact command to be uninstalled.
Returns
hpm_stat_t Returns the operation status, indicating whether the uninstallation was successful.

◆ hpm_pmbus_slave_init()

hpm_stat_t hpm_pmbus_slave_init ( I2C_Type ptr,
uint8_t  slave_addr 
)

PMBus Slave Initialization.

This function initializes an I2C slave device to respond to a specific slave address and communicate according to the PMBus protocol.

Parameters
ptrPointer to the base address of the I2C, pointing to the I2C slave device to be initialized
slave_addrAddress of the slave device, used to identify the specific slave on the I2C bus
Returns
hpm_stat_t Returns the status of the initialization operation, indicating success or failure reasons

◆ hpm_smbus_pec_crc8_in_command()

static uint8_t hpm_smbus_pec_crc8_in_command ( uint8_t  slave_addr,
uint8_t  command,
uint8_t *  data,
uint32_t  len,
bool  read,
bool  block 
)
static

Variable Documentation

◆ hpm_pmbus_cfg_table

hpm_pmbus_cfg_t hpm_pmbus_cfg_table[]
static
Initial value:
= {
}

◆ pmbus_cmd_param_table

const hpm_pmbus_cmd_param_t pmbus_cmd_param_table[]
extern