HPM SDK
HPMicro Software Development Kit
e2p_device_i2c.h File Reference
#include "board.h"
#include "hpm_i2c_drv.h"
#include "eeprom_device.h"

Go to the source code of this file.

Data Structures

struct  e2p_device_i2c_host_config_t
 eeprom i2c device board configuration structure More...
 
struct  e2p_device_i2c_attribute_t
 eeprom i2c device configuration structure More...
 

Macros

#define HPM_E2P_I2C_DEV_ADDR(family_id, custom_id)   ((uint8_t)(family_id) | (uint8_t)(custom_id))
 eeprom i2c device address definition macro More...
 
#define HPM_E2P_I2C_ADD_CUSTOM_ID_TO_DEV_ID(dev_id, custom_id)   ((((uint32_t)(custom_id)) << 16) | ((uint32_t)(dev_id)))
 

Functions

hpm_stat_t e2p_device_i2c_register_param (hpm_eeprom_device_t *device, void *host_info, uint32_t dev_id)
 Register eeprom i2c device parameter to device structure. More...
 
e2p_device_i2c_attribute_te2p_device_i2c_get_attribute (hpm_eeprom_device_t *device)
 Get eeprom i2c device attribute. More...
 
hpm_stat_t e2p_device_i2c_init (hpm_eeprom_device_t *device)
 Initialize eeprom i2c device, hw init(clock and pin) and i2c master init. More...
 
hpm_stat_t e2p_device_i2c_deinit (hpm_eeprom_device_t *device)
 De-initialize eeprom i2c device. More...
 
hpm_stat_t e2p_device_i2c_read (hpm_eeprom_device_t *device, uint32_t data_addr, uint32_t len, uint8_t *data)
 Read data from eeprom i2c device. More...
 
hpm_stat_t e2p_device_i2c_write (hpm_eeprom_device_t *device, uint32_t data_addr, uint32_t len, uint8_t *data)
 Write data to eeprom i2c device. More...
 

Macro Definition Documentation

◆ HPM_E2P_I2C_ADD_CUSTOM_ID_TO_DEV_ID

#define HPM_E2P_I2C_ADD_CUSTOM_ID_TO_DEV_ID (   dev_id,
  custom_id 
)    ((((uint32_t)(custom_id)) << 16) | ((uint32_t)(dev_id)))

◆ HPM_E2P_I2C_DEV_ADDR

#define HPM_E2P_I2C_DEV_ADDR (   family_id,
  custom_id 
)    ((uint8_t)(family_id) | (uint8_t)(custom_id))

eeprom i2c device address definition macro

Function Documentation

◆ e2p_device_i2c_deinit()

hpm_stat_t e2p_device_i2c_deinit ( hpm_eeprom_device_t device)

De-initialize eeprom i2c device.

Parameters
[in]devicePointer to eeprom device structure
Return values
status_successDe-initialize eeprom i2c device.

◆ e2p_device_i2c_get_attribute()

e2p_device_i2c_attribute_t* e2p_device_i2c_get_attribute ( hpm_eeprom_device_t device)

Get eeprom i2c device attribute.

Parameters
[in]devicePointer to eeprom device structure
Return values
Pointerto eeprom i2c device attribute structure

◆ e2p_device_i2c_init()

hpm_stat_t e2p_device_i2c_init ( hpm_eeprom_device_t device)

Initialize eeprom i2c device, hw init(clock and pin) and i2c master init.

Parameters
[in]devicePointer to eeprom device structure
Return values
status_success,orstatus_fail if initialization fails

◆ e2p_device_i2c_read()

hpm_stat_t e2p_device_i2c_read ( hpm_eeprom_device_t device,
uint32_t  data_addr,
uint32_t  len,
uint8_t *  data 
)

Read data from eeprom i2c device.

Parameters
[in]devicePointer to eeprom device structure
[in]data_addrData address to read from
[in]lenLength of data to read
[out]dataPointer to buffer to store read data
Return values
status_successor status_fail if reading fails or status_invalid_argument if invalid argument is detected or status_timeout if timeout occurs during reading or status_i2c_no_addr_hit if no acknowledge from slave device
Note
This function will handle page splitting and borrow bits internally, and call e2p_device_i2c_page_read; so the user does not need to worry about these details.

◆ e2p_device_i2c_register_param()

hpm_stat_t e2p_device_i2c_register_param ( hpm_eeprom_device_t device,
void *  host_info,
uint32_t  dev_id 
)

Register eeprom i2c device parameter to device structure.

Parameters
[in]devicePointer to eeprom device structure
[in]host_infoPointer to eeprom i2c host configuration structure
[in]dev_idEeprom device id
Return values
status_success,orstatus_fail if dev_id is invalid

◆ e2p_device_i2c_write()

hpm_stat_t e2p_device_i2c_write ( hpm_eeprom_device_t device,
uint32_t  data_addr,
uint32_t  len,
uint8_t *  data 
)

Write data to eeprom i2c device.

Parameters
[in]devicePointer to eeprom device structure
[in]data_addrData address to write to
[in]lenLength of data to write
[in]dataPointer to buffer containing data to write
Return values
status_successor status_fail if writing fails or status_timeout if timeout occurs during writing or status_i2c_no_addr_hit if no acknowledge from slave device or status_invalid_argument if invalid argument is detected
Note
This function will handle page splitting and borrow bits internally, and call e2p_device_i2c_page_write; so the user does not need to worry about these details.