HPM SDK
HPMicro Software Development Kit
e2p_device_spi.h File Reference
#include "board.h"
#include "hpm_spi_drv.h"
#include "eeprom_device.h"

Go to the source code of this file.

Data Structures

struct  e2p_device_spi_host_config_t
 eeprom spi device board configuration structure More...
 
struct  e2p_device_spi_attribute_t
 eeprom spi device attribute structure More...
 

Macros

#define E2P_SPI_INSTRUCTION_WREN   0x06
 eeprom spi device support register instruction More...
 
#define E2P_SPI_INSTRUCTION_RDSR   0x05
 
#define E2P_SPI_INSTRUCTION_WRDI   0x04
 
#define E2P_SPI_INSTRUCTION_READ   0x03
 
#define E2P_SPI_INSTRUCTION_WRITE   0x02
 
#define E2P_SPI_INSTRUCTION_WRSR   0x01
 
#define E2P_SPI_INSTRUCTION_STATUS_WIP_MASK   0x01
 eeprom spi device status register bit mask More...
 
#define E2P_SPI_INSTRUCTION_STATUS_WEL_MASK   0x02
 

Functions

hpm_stat_t e2p_device_spi_register_param (hpm_eeprom_device_t *device, void *host_info, uint32_t dev_id)
 Register eeprom spi device parameter to device structure. More...
 
e2p_device_spi_attribute_te2p_device_spi_get_attribute (hpm_eeprom_device_t *device)
 Get eeprom spi device attribute. More...
 
hpm_stat_t e2p_device_spi_init (hpm_eeprom_device_t *device)
 Initialize eeprom spi device, hw init(clock and pin) and spi master init. More...
 
hpm_stat_t e2p_device_spi_deinit (hpm_eeprom_device_t *device)
 De-initialize eeprom spi device. More...
 
hpm_stat_t e2p_device_spi_read (hpm_eeprom_device_t *device, uint32_t data_addr, uint32_t len, uint8_t *data)
 Read data from eeprom spi device. More...
 
hpm_stat_t e2p_device_spi_write (hpm_eeprom_device_t *device, uint32_t data_addr, uint32_t len, uint8_t *data)
 Write data to eeprom spi device. More...
 

Macro Definition Documentation

◆ E2P_SPI_INSTRUCTION_RDSR

#define E2P_SPI_INSTRUCTION_RDSR   0x05

◆ E2P_SPI_INSTRUCTION_READ

#define E2P_SPI_INSTRUCTION_READ   0x03

◆ E2P_SPI_INSTRUCTION_STATUS_WEL_MASK

#define E2P_SPI_INSTRUCTION_STATUS_WEL_MASK   0x02

◆ E2P_SPI_INSTRUCTION_STATUS_WIP_MASK

#define E2P_SPI_INSTRUCTION_STATUS_WIP_MASK   0x01

eeprom spi device status register bit mask

◆ E2P_SPI_INSTRUCTION_WRDI

#define E2P_SPI_INSTRUCTION_WRDI   0x04

◆ E2P_SPI_INSTRUCTION_WREN

#define E2P_SPI_INSTRUCTION_WREN   0x06

eeprom spi device support register instruction

◆ E2P_SPI_INSTRUCTION_WRITE

#define E2P_SPI_INSTRUCTION_WRITE   0x02

◆ E2P_SPI_INSTRUCTION_WRSR

#define E2P_SPI_INSTRUCTION_WRSR   0x01

Function Documentation

◆ e2p_device_spi_deinit()

hpm_stat_t e2p_device_spi_deinit ( hpm_eeprom_device_t device)

De-initialize eeprom spi device.

Parameters
[in]devicePointer to eeprom device structure
Return values
status_success

◆ e2p_device_spi_get_attribute()

e2p_device_spi_attribute_t* e2p_device_spi_get_attribute ( hpm_eeprom_device_t device)

Get eeprom spi device attribute.

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

◆ e2p_device_spi_init()

hpm_stat_t e2p_device_spi_init ( hpm_eeprom_device_t device)

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

Parameters
[in]devicePointer to eeprom device structure
Return values
status_successor status_fail if initialization fails or status_invalid_argument if configuration is invalid

◆ e2p_device_spi_read()

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

Read data from eeprom spi device.

Parameters
[in]devicePointer to eeprom device structure
[in]data_addrData address to read from
[in]lenLength of data to read
[in]dataPointer to buffer to store read data
Return values
status_successor status_fail if read operation fails or status_invalid_argument if configuration is invalid or status_spi_master_busy if spi bus is busy or status_timeout if spi transfer timeout

◆ e2p_device_spi_register_param()

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

Register eeprom spi device parameter to device structure.

Parameters
[in]devicePointer to eeprom device structure
[in]host_infoPointer to eeprom spi host configuration structure
[in]dev_idEeprom device id
Return values
status_successor status_fail if dev_id is invalid

◆ e2p_device_spi_write()

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

Write data to eeprom spi 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 read operation fails or status_invalid_argument if configuration is invalid or status_spi_master_busy if spi bus is busy or status_timeout if spi transfer timeout
Note
This function will handle page splitting and borrow bits internally, and call e2p_device_spi_page_write; so the user does not need to worry about these details.