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

Functions

static uint8_t hpm_smbus_pec_crc8 (uint8_t *data, uint32_t len)
 
hpm_stat_t hpm_smbus_master_write_byte (I2C_Type *ptr, uint8_t slave_address, uint8_t data)
 SMbus master write data. More...
 
hpm_stat_t hpm_smbus_master_read_byte (I2C_Type *ptr, uint8_t slave_address, uint8_t *data)
 SMbus master read byte from certain slave device. More...
 
hpm_stat_t hpm_smbus_master_write_byte_in_command (I2C_Type *ptr, uint8_t slave_address, uint8_t command, uint8_t data)
 SMbus master write byte from certain slave device in command code. More...
 
hpm_stat_t hpm_smbus_master_write_word_in_command (I2C_Type *ptr, uint8_t slave_address, uint8_t command, uint16_t data)
 SMbus master write word(16bits) from certain slave device in command code. More...
 
hpm_stat_t hpm_smbus_master_read_byte_in_command (I2C_Type *ptr, uint8_t slave_address, uint8_t command, uint8_t *data)
 SMbus master read byte from certain slave device in command code. More...
 
hpm_stat_t hpm_smbus_master_read_word_in_command (I2C_Type *ptr, uint8_t slave_address, uint8_t command, uint16_t *data)
 SMbus master read word(16bits) from certain slave device in command code. More...
 
hpm_stat_t hpm_smbus_master_write_block_in_command (I2C_Type *ptr, uint8_t slave_address, uint8_t command, uint8_t *data, uint32_t size)
 SMbus master block write from certain slave device in command code. More...
 
hpm_stat_t hpm_smbus_master_read_block_in_command (I2C_Type *ptr, uint8_t slave_address, uint8_t command, uint8_t *data, uint32_t size)
 SMbus master block read from certain slave device in command code. More...
 
hpm_stat_t hpm_smbus_master_write (I2C_Type *ptr, uint8_t slave_address, uint8_t *data, uint32_t size)
 SMbus master write data to certain slave device. More...
 
hpm_stat_t hpm_smbus_master_read (I2C_Type *ptr, uint8_t slave_address, uint8_t *data, uint32_t size)
 SMbus master read data from certain slave device. More...
 
hpm_stat_t hpm_smbus_slave_write (I2C_Type *ptr, uint8_t *data, uint32_t size)
 SMbus slave write data. More...
 
hpm_stat_t hpm_smbus_slave_read (I2C_Type *ptr, uint8_t *data, uint32_t size)
 SMbus slave read data. More...
 

Function Documentation

◆ hpm_smbus_master_read()

hpm_stat_t hpm_smbus_master_read ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t *  data,
uint32_t  size 
)

SMbus master read data from certain slave device.

Read data from SMbus device

Note
size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
Parameters
[in]ptrI2C base address
[in]device_addressSMbus slave address
[out]datapointer of the buffer to store data read from device
[in]sizesize of data to be read in bytes
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ hpm_smbus_master_read_block_in_command()

hpm_stat_t hpm_smbus_master_read_block_in_command ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t  command,
uint8_t *  data,
uint32_t  size 
)

SMbus master block read from certain slave device in command code.

block read from SMbus device in command code

Note
size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
Parameters
[in]ptrI2C base address
[in]device_addressSMbus slave address
[in]commandcommand code
[out]datapointer of the buffer to store data read from device
[in]sizesize of data to be read in bytes
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ hpm_smbus_master_read_byte()

hpm_stat_t hpm_smbus_master_read_byte ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t *  data 
)

SMbus master read byte from certain slave device.

Read byte from SMbus device

Parameters
[in]ptrI2C base address
[in]device_addressSMbus slave address
[out]datapointer of the byte read from device
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ hpm_smbus_master_read_byte_in_command()

hpm_stat_t hpm_smbus_master_read_byte_in_command ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t  command,
uint8_t *  data 
)

SMbus master read byte from certain slave device in command code.

read byte from SMbus device in command code

Parameters
[in]ptrI2C base address
[in]device_addressSMbus slave address
[in]commandcommand code
[in]databyte to be read
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ hpm_smbus_master_read_word_in_command()

hpm_stat_t hpm_smbus_master_read_word_in_command ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t  command,
uint16_t *  data 
)

SMbus master read word(16bits) from certain slave device in command code.

read word from SMbus device in command code

Parameters
[in]ptrI2C base address
[in]device_addressSMbus slave address
[in]commandcommand code
[in]dataword to be read
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ hpm_smbus_master_write()

hpm_stat_t hpm_smbus_master_write ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t *  data,
uint32_t  size 
)

SMbus master write data to certain slave device.

Write data to SMbus device

Note
size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
Parameters
[in]ptrI2C base address
[in]device_addressSMbus slave address
[in]datapointer of the data to be sent
[in]sizesize of data to be sent in bytes
Return values
hpm_stat_tstatus_success if writing is completed without any error

◆ hpm_smbus_master_write_block_in_command()

hpm_stat_t hpm_smbus_master_write_block_in_command ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t  command,
uint8_t *  data,
uint32_t  size 
)

SMbus master block write from certain slave device in command code.

block write from SMbus device in command code

Note
size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
Parameters
[in]ptrI2C base address
[in]device_addressSMbus slave address
[in]commandcommand code
[in]datapointer of the buffer to store data read from device
[in]sizesize of data to be read in bytes
Return values
hpm_stat_tstatus_success if writing is completed without any error

◆ hpm_smbus_master_write_byte()

hpm_stat_t hpm_smbus_master_write_byte ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t  data 
)

SMbus master write data.

write data at slave mode

Parameters
[in]ptrI2C base address
[in]device_addressSMbus slave address
[in]databyte to be writed
Return values
hpm_stat_tstatus_success if writing is completed without any error

◆ hpm_smbus_master_write_byte_in_command()

hpm_stat_t hpm_smbus_master_write_byte_in_command ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t  command,
uint8_t  data 
)

SMbus master write byte from certain slave device in command code.

write byte from SMbus device in command code

Parameters
[in]ptrI2C base address
[in]device_addressSMbus slave address
[in]commandcommand code
[in]databyte to be writed
Return values
hpm_stat_tstatus_success if writing is completed without any error

◆ hpm_smbus_master_write_word_in_command()

hpm_stat_t hpm_smbus_master_write_word_in_command ( I2C_Type ptr,
uint8_t  slave_address,
uint8_t  command,
uint16_t  data 
)

SMbus master write word(16bits) from certain slave device in command code.

write word(16bits) from SMbus device in command code

Parameters
[in]ptrI2C base address
[in]device_addressSMbus slave address
[in]commandcommand code
[in]dataword to be writed
Return values
hpm_stat_tstatus_success if writing is completed without any error

◆ hpm_smbus_pec_crc8()

static uint8_t hpm_smbus_pec_crc8 ( uint8_t *  data,
uint32_t  len 
)
static

◆ hpm_smbus_slave_read()

hpm_stat_t hpm_smbus_slave_read ( I2C_Type ptr,
uint8_t *  data,
uint32_t  size 
)

SMbus slave read data.

Read data at SMbus slave mode

Note
size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
Parameters
[in]ptrI2C base address
[in]bufpointer of the buffer to store data read from device
[in]sizesize of data to be read in bytes
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ hpm_smbus_slave_write()

hpm_stat_t hpm_smbus_slave_write ( I2C_Type ptr,
uint8_t *  data,
uint32_t  size 
)

SMbus slave write data.

Write data at SMbus slave mode.

Note
size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
Parameters
[in]ptrI2C base address
[in]bufpointer of the buffer to store data sent from device
[in]sizesize of data to be sent in bytes
Return values
hpm_stat_tstatus_success if writing is completed without any error