EEPROM Platform Interface
EEPROM Platform Interface
EEPROM Overview
EEPROM (Electrically Erasable Programmable Read-Only Memory) is a type of non-volatile memory used in embedded systems and electronic devices to store small amounts of data that must be preserved even after power is removed. It allows data to be electrically written, erased, and reprogrammed multiple times.
Supported Communication Modes
The following modes of EEPROM communication are supported:
Blocking - Here the read/write function waits(blocked) till the operation is performed or time out
Non-Blocking - The read/write function returns immediately and the registered callback is invoked after the completion of operation or time out
EEPROM BUS Interface
The EEPROM bus interface defines how the EEPROM is connected to the system, enabling communication with the device:
EEPROM Interface Internal : EEPROM is integrated within the device’s internal memory space.
EEPROM Interface I2C : EEPROM is connected via the I2C (Inter-Integrated Circuit) protocol.
EEPROM Interface SPI : EEPROM is connected via the SPI (Serial Peripheral Interface) protocol.
These interfaces provide flexibility in integrating EEPROM with various system architectures.
The middleware part will be responsible for managing read/write/erase/write protect operations along with some convenience functions to read/write memory.
Application Interface
The below table captures the functions that are to be called from the application layer.
Function |
Description |
---|---|
rs_eeprom_open |
To open the EEPROM interface. |
rs_eeprom_set_config |
To configure the EEPROM interface. |
rs_eeprom_enable_write |
To enables write access for the EEPROM |
rs_eeprom_disable_write |
To disables write access in the EEPROM |
rs_eeprom_erase |
To erases the given page in the EEPROM |
rs_eeprom_write |
To writes the given data in the eeprom |
rs_eeprom_read |
To reads the data from the EEPROM |
rs_eeprom_register_completion_callback |
To registers the given callback function for EEPROM operation |
rs_eeprom_close |
To close the EEPROM interface. |
Error Code
Every API’s for the EEPROM returns some success or failure values. Please refer below section,
Implementation Guide
This section explains how to implement the EEPROM interface using the RAPIDSEA stack, the steps to be followed are
Configure the preferred method of RX or TX communication(Blocking / Non-Blocking).
Configure the EEPROM interface.
Then call the open call of the EEPROM interface.
Perform the read and write operations as required and handle the error codes.
Close the EEPROM interface.
Documentation from the relevant header as follows:
EEPROM Specific APIs.
Defines macros and functions specific to EEPROM functionality
- Author
Embien RAPIDSEA Team
- Copyright
Embien Technologies India Pvt. Ltd.
Defines
-
RS_EEPROM_INTERFACE_INTERNAL
EEPROM Bus Interface Internal device memory
-
RS_EEPROM_INTERFACE_I2C
Connected over I2C.
-
RS_EEPROM_INTERFACE_SPI
Connected over SPI.
-
RS_EEPROM_STATUS_WRITE_PROTECTED
Device is currently write-protected.
-
RS_EEPROM_STATUS_WRITE_ENABLED
Device is currently write-enabled.
-
RS_EEPROM_BLOCKING
Blocking Mode operation.
-
RS_EEPROM_NON_BLOCKING
Non-Blocking Mode operation
Typedefs
-
typedef void (*rs_eeprom_callback)(rs_handle_t handle, rs_ret_val_t reason, void *ptr_args)
EEPROM callback function.
-
typedef struct tag_rs_eeprom_config rs_eeprom_config_t
Structure for setting up EEPROM configuration.
-
typedef struct tag_rs_eeprom_instance rs_eeprom_instance_t
Structure for the EEPROM instance information.
-
typedef void (*rs_eeprom_callback_completion)(rs_handle_t handle, rs_ret_val_t result)
Callback function format.
This callback function is called on completion of given activity
- Param handle:
[in] - Handle to the EEPROM interface
- Param result:
[in] - Result of the last operation requested in non-blocking mode
- Return:
None
Functions
-
rs_handle_t rs_eeprom_open(rs_eeprom_instance_t *ptr_instance, rs_eeprom_config_t *ptr_config)
Configures the EEPROM device for further operations.
This function configures/re-configures EEPROM as per given configuration
- Parameters:
ptr_instance – [in] - Pointer to the EEPROM instance
ptr_config – [in] - Pointer to the configuration structure
- Returns:
handle to EEPROM on success or error code on failure
-
rs_ret_val_t rs_eeprom_set_config(rs_eeprom_config_t *ptr_config, uint8_t u8_interface, uint32_t u32_interface_handle, uint16_t u16_slave_address, uint32_t u32_max_size, uint16_t u16_page_count, uint16_t u16_page_size, uint8_t u8_write_protect_port, uint16_t u16_write_protect_pin)
-
rs_ret_val_t rs_eeprom_is_write_enabled(rs_handle_t handle)
Returns the write protected status of EEPROM.
This function queries the current status of EEPROM and returns based on its write-protected state
- Parameters:
handle – [in] - Handle to EEPROM device
- Returns:
1 if write enabled or 0 if write protested
-
rs_ret_val_t rs_eeprom_enable_write(rs_handle_t handle)
Enables write access for the EEPROM.
This function executes EEPROM Write enable sequence and drives WP pin suitably, if needed
- Parameters:
handle – [in] - Handle to EEPROM device
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rs_eeprom_disable_write(rs_handle_t handle)
Disables write access in the EEPROM.
This function executes EEPROM Write disable sequence and drives WP pin suitably, if needed
- Parameters:
handle – [in] - Handle to EEPROM device
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rs_eeprom_erase(rs_handle_t handle, uint32_t u32_addr)
Erases the given page in the EEPROM.
This function erases the page/sector at the given address
- Parameters:
handle – [in] - Handle to EEPROM device
u32_addr – [in] - Address to erase
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rs_eeprom_write(rs_handle_t handle, uint32_t u32_addr, void *ptr_write_data, uint32_t u32_write_len, uint32_t u32_time_out)
-
rs_ret_val_t rs_eeprom_read(rs_handle_t handle, uint32_t u32_addr, void *ptr_read_data, uint32_t u32_read_len, uint32_t u32_time_out)
-
rs_ret_val_t rs_eeprom_register_completion_callback(rs_handle_t handle, rs_eeprom_callback_completion ptr_func)
Registers the given callback function for completion of EEPROM operation.
This function registers the given callback function for completion of transfer operation
- Parameters:
handle – [in] - Handle to the EEPROM device
ptr_func – [in] - Callback function to call to
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rs_eeprom_close(rs_handle_t handle)
Un-initializes the EEPROM.
This function un-initializes the EEPROM and releases the underlying resources
- Parameters:
handle – [in] - Handle to EEPROM device
- Returns:
0 on success or error code on failure
-
struct tag_rs_eeprom_config
- #include <rs_eeprom.h>
Structure for setting up EEPROM configuration.
Public Members
-
uint8_t interface
Underlying interface - I2C/SPI etc.
-
uint32_t interface_handle
Interface handle.
-
uint16_t eeprom_slave_address
EEPROM slave address.
-
uint32_t eeprom_max_size
EEPROM maximum size.
-
uint16_t eeprom_max_page_count
EEPROM maximum page count.
-
uint16_t eeprom_page_size
EEPROM page size.
-
uint8_t write_protect_port
EEPROM write protect port.
-
uint16_t write_protect_pin
EEPROM write protect pin.
-
uint8_t interface
-
struct tag_rs_eeprom_instance
- #include <rs_eeprom.h>
Structure for the EEPROM instance information.
Public Members
-
rs_eeprom_config_t *ptr_config
Pointer to the configuration structure.
-
rs_eeprom_callback ptr_cb
Pointer to the callback function.
-
void *ptr_arg
Pointer to the callback function argument.
-
rs_eeprom_config_t *ptr_config