HPM SDK
HPMicro Software Development Kit
hpm_sccb.h File Reference
#include "hpm_common.h"
#include "hpm_soc_feature.h"
#include "hpm_i2c_drv.h"

Go to the source code of this file.

Typedefs

typedef I2C_Typesccb_type
 
typedef enum _sccb_xfer_flag sccb_xfer_flags_t
 
typedef struct _sccb_bus hpm_sccb_bus_t
 

Functions

hpm_stat_t sccb_master_init (sccb_type sccb)
 sccb master initialization More...
 
uint8_t sccb_master_scan (sccb_type sccb)
 sccb master scan slave addr More...
 
hpm_stat_t sccb_master_gencall (sccb_type sccb, uint8_t cmd)
 sccb master gen call slave More...
 
hpm_stat_t sccb_master_readb (sccb_type sccb, uint8_t slv_addr, uint8_t reg_addr, uint8_t *reg_data)
 sccb master read 8bit data of specify 8bit register from certain slave device More...
 
hpm_stat_t sccb_master_writeb (sccb_type sccb, uint8_t slv_addr, uint8_t reg_addr, uint8_t reg_data)
 sccb master write 8bit data of specify 8bit register from certain slave device More...
 
hpm_stat_t sccb_master_readb2 (sccb_type sccb, uint8_t slv_addr, uint16_t reg_addr, uint8_t *reg_data)
 sccb master read 8bit data of specify 16bit register from certain slave device More...
 
hpm_stat_t sccb_master_writeb2 (sccb_type sccb, uint8_t slv_addr, uint16_t reg_addr, uint8_t reg_data)
 sccb master write 8bit data of specify 16bit register from certain slave device More...
 
hpm_stat_t sccb_master_readw (sccb_type sccb, uint8_t slv_addr, uint8_t reg_addr, uint16_t *reg_data)
 sccb master read 16bit data of specify 8bit register from certain slave device More...
 
hpm_stat_t sccb_master_writew (sccb_type sccb, uint8_t slv_addr, uint8_t reg_addr, uint16_t reg_data)
 sccb master write 16bit data of specify 8bit register from certain slave device More...
 
hpm_stat_t sccb_master_readw2 (sccb_type sccb, uint8_t slv_addr, uint16_t reg_addr, uint16_t *reg_data)
 sccb master read 16bit data of specify 16it register from certain slave device More...
 
hpm_stat_t sccb_master_writew2 (sccb_type sccb, uint8_t slv_addr, uint16_t reg_addr, uint16_t reg_data)
 sccb master write 16bit data of specify 16bit register from certain slave device More...
 
hpm_stat_t sccb_master_read_bytes (sccb_type sccb, uint8_t slv_addr, uint8_t *buf, const uint32_t len, uint8_t flags)
 sccb master reads the specified number of bytes continuously at the specified flag More...
 
hpm_stat_t cambus_write_bytes (sccb_type sccb, uint8_t slv_addr, uint8_t *buf, const uint32_t len, uint8_t flags)
 sccb master weite the specified number of bytes continuously at the specified flag More...
 

Typedef Documentation

◆ hpm_sccb_bus_t

typedef struct _sccb_bus hpm_sccb_bus_t

◆ sccb_type

typedef I2C_Type* sccb_type

◆ sccb_xfer_flags_t

typedef enum _sccb_xfer_flag sccb_xfer_flags_t

Function Documentation

◆ cambus_write_bytes()

hpm_stat_t cambus_write_bytes ( sccb_type  sccb,
uint8_t  slv_addr,
uint8_t *  buf,
const uint32_t  len,
uint8_t  flags 
)

sccb master weite the specified number of bytes continuously at the specified flag

the size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX

Parameters
[in]sccbsccb base address
[in]slv_addrsccb slave address
[out]bufpoint of the buffer to store 8bit data from device
[out]lensize of data to be write in bytes
[in]flagssccb_xfer_flags_t enmu flags
Return values
hpm_stat_tstatus_success if writing is completed without any error

◆ sccb_master_gencall()

hpm_stat_t sccb_master_gencall ( sccb_type  sccb,
uint8_t  cmd 
)

sccb master gen call slave

the controller sends the command to determine whether the slave responds

Parameters
[in]sccbsccb base address
[in]cmdsccb master sends command
Return values
hpm_stat_tstatus_success if the slave responds

◆ sccb_master_init()

hpm_stat_t sccb_master_init ( sccb_type  sccb)

sccb master initialization

Initialized sccb working at master mode

Parameters
[in]sccbsccb base address
Return values
hpm_stat_tstatus_success if initialization is completed without any error

◆ sccb_master_read_bytes()

hpm_stat_t sccb_master_read_bytes ( sccb_type  sccb,
uint8_t  slv_addr,
uint8_t *  buf,
const uint32_t  len,
uint8_t  flags 
)

sccb master reads the specified number of bytes continuously at the specified flag

the size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX

Parameters
[in]sccbsccb base address
[in]slv_addrsccb slave address
[out]bufpoint of the buffer to store 8bit data from device
[out]lensize of data to be read in bytes
[in]flagssccb_xfer_flags_t enmu flags
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ sccb_master_readb()

hpm_stat_t sccb_master_readb ( sccb_type  sccb,
uint8_t  slv_addr,
uint8_t  reg_addr,
uint8_t *  reg_data 
)

sccb master read 8bit data of specify 8bit register from certain slave device

the function used to access 8 bit register address,read 8bit data

Note
the register address must be 8bit
Parameters
[in]sccbsccb base address
[in]slv_addrsccb slave address
[out]reg_addr8bit register address of sccb slave device
[out]reg_datapoint of the buffer to store 8bit data from device the number of bytes is 1
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ sccb_master_readb2()

hpm_stat_t sccb_master_readb2 ( sccb_type  sccb,
uint8_t  slv_addr,
uint16_t  reg_addr,
uint8_t *  reg_data 
)

sccb master read 8bit data of specify 16bit register from certain slave device

the function used to access 16 bit register address,read 8bit data

Note
the register address must be 16bit
Parameters
[in]sccbsccb base address
[in]slv_addrsccb slave address
[out]reg_addr16bit register address of sccb slave device
[out]reg_datapoint of the buffer to store 8bit data from device the number of bytes is 1
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ sccb_master_readw()

hpm_stat_t sccb_master_readw ( sccb_type  sccb,
uint8_t  slv_addr,
uint8_t  reg_addr,
uint16_t *  reg_data 
)

sccb master read 16bit data of specify 8bit register from certain slave device

the function used to access 8 bit register address,read 16bit data

Note
the register address must be 8bit
Parameters
[in]sccbsccb base address
[in]slv_addrsccb slave address
[out]reg_addr8bit register address of sccb slave device
[out]reg_datapoint of the buffer to store 16bit data from device the number of bytes is 1
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ sccb_master_readw2()

hpm_stat_t sccb_master_readw2 ( sccb_type  sccb,
uint8_t  slv_addr,
uint16_t  reg_addr,
uint16_t *  reg_data 
)

sccb master read 16bit data of specify 16it register from certain slave device

the function used to access 16 bit register address,read 16bit data

Note
the register address must be 16bit
Parameters
[in]sccbsccb base address
[in]slv_addrsccb slave address
[out]reg_addr16bit register address of sccb slave device
[out]reg_datapoint of the buffer to store 16bit data from device the number of bytes is 1
Return values
hpm_stat_tstatus_success if reading is completed without any error

◆ sccb_master_scan()

uint8_t sccb_master_scan ( sccb_type  sccb)

sccb master scan slave addr

master scan the slave

Parameters
[in]sccbsccb base address
Return values
uint8_tthe slave address val is zero if scan slave fail

◆ sccb_master_writeb()

hpm_stat_t sccb_master_writeb ( sccb_type  sccb,
uint8_t  slv_addr,
uint8_t  reg_addr,
uint8_t  reg_data 
)

sccb master write 8bit data of specify 8bit register from certain slave device

the function used to access 8 bit register address,write 8bit data

Note
the register address must be 8bit
Parameters
[in]sccbsccb base address
[in]slv_addrsccb slave address
[out]reg_addr8bit register address of sccb slave device
[out]reg_datawrite 8bit data
Return values
hpm_stat_tstatus_success if writing is completed without any error

◆ sccb_master_writeb2()

hpm_stat_t sccb_master_writeb2 ( sccb_type  sccb,
uint8_t  slv_addr,
uint16_t  reg_addr,
uint8_t  reg_data 
)

sccb master write 8bit data of specify 16bit register from certain slave device

the function used to access 16 bit register address,write 8bit data

Note
the register address must be 8bit
Parameters
[in]sccbsccb base address
[in]slv_addrsccb slave address
[out]reg_addr16bit register address of sccb slave device
[out]reg_datawirite 8bit data
Return values
hpm_stat_tstatus_success if writing is completed without any error

◆ sccb_master_writew()

hpm_stat_t sccb_master_writew ( sccb_type  sccb,
uint8_t  slv_addr,
uint8_t  reg_addr,
uint16_t  reg_data 
)

sccb master write 16bit data of specify 8bit register from certain slave device

the function used to access 8 bit register address,write 16bit data

Note
the register address must be 8bit
Parameters
[in]sccbsccb base address
[in]slv_addrsccb slave address
[out]reg_addr8bit register address of sccb slave device
[out]reg_datawirite 16bit data
Return values
hpm_stat_tstatus_success if writing is completed without any error

◆ sccb_master_writew2()

hpm_stat_t sccb_master_writew2 ( sccb_type  sccb,
uint8_t  slv_addr,
uint16_t  reg_addr,
uint16_t  reg_data 
)

sccb master write 16bit data of specify 16bit register from certain slave device

the function used to access 16bit register address,write 16bit data

Note
the register address must be 16bit
Parameters
[in]sccbsccb base address
[in]slv_addrsccb slave address
[out]reg_addr16bit register address of sccb slave device
[out]reg_datawirite 16bit data
Return values
hpm_stat_tstatus_success if writing is completed without any error