STC15W408AS library 0.13.0
Loading...
Searching...
No Matches
Macros | Enumerations
EEPROM

Macros

#define OP_TRIGGER_SEQ_FIRST_BYTE   0x5A
 Read operation trigger sequence first byte.
 
#define OP_TRIGGER_SEQ_SECOND_BYTE   0xA5
 Read operation trigger sequence second byte.
 
#define CMD_FAIL_BIT   4
 Command fail error code.
 
#define ERROR_VALUE   0xFF
 Error value.
 
#define eeprom_disable_iap()
 Disables IAP.
 
#define get_eeprom_last_operation_result()   (get_bit(IAP_CONTR, CMD_FAIL_BIT) ? CMD_FAIL_ERROR : CMD_SUCCESS)
 get last operation result
 
#define eeprom_read_byte(addr_high, addr_low, value_ptr, error_ptr)
 Reads single byte from the EEPROM at the given address.
 
#define eeprom_erase_page(sector_start_addr, error_ptr)
 Erases a sector in the EEPROM starting from a specified address.
 
#define eeprom_write_byte(addr_high, addr_low, value, error_ptr)
 Writes a single byte to the EEPROM at the specified address.
 

Enumerations

enum  eeprom_operation_t { READ_OP = 0x01 , WRITE_OP = 0x02 , ERASE_OP = 0x03 }
 EEPROM operation types. More...
 
enum  eeprom_operation_status_t { CMD_SUCCESS = 0 , CMD_FAIL_ERROR = 1 , LOW_VOLTAGE_ERROR = 2 }
 EEPROM operation status. More...
 

Detailed Description

Functions and data structures related to EEPROM

Author
Michael Golovanov

Macro Definition Documentation

◆ eeprom_disable_iap

#define eeprom_disable_iap ( )
Value:
do { \
/* Disable IAP */ \
bit_clr(IAP_CONTR, CBIT7); \
IAP_CMD = 0x00; \
IAP_TRIG = 0x00; \
IAP_ADDRH = 0xFF; \
IAP_ADDRL = 0xFF; \
} while(0)

Disables IAP.

This function disables EEPROM operation via IAP registers and clear it.

◆ eeprom_erase_page

#define eeprom_erase_page (   sector_start_addr,
  error_ptr 
)

Erases a sector in the EEPROM starting from a specified address.

This function performs an erase operation on a 512 bytes sector of the EEPROM memory. The sector is identified by its starting address. The function updates the error status via the provided error pointer.

Parameters
sector_start_addruint8_t The starting address of the EEPROM sector to be erased. Must be a valid sector start address.
error_ptrPointer to a uint8_t variable where the error status will be stored. Must not be NULL. 0 - no error, otherwise - error code. Error codes:
  • CMD_FAIL_ERROR - read operation failed,
  • LOW_VOLTAGE_ERROR - low voltage error
Warning
This function modifies EEPROM contents; ensure data integrity requirements are met before calling it.
This function does not perform address bounds checking. It is the caller's responsibility to ensure valid EEPROM addresses.

◆ eeprom_read_byte

#define eeprom_read_byte (   addr_high,
  addr_low,
  value_ptr,
  error_ptr 
)

Reads single byte from the EEPROM at the given address.

This function performs a read operation from the EEPROM using the provided high and low bytes of the address. The data read from the EEPROM is stored in the location pointed to by 'value_ptr'. For reading from the EEPROM IAP registers are used.

Parameters
addr_highuint8_t High byte of the EEPROM address to read from.
addr_lowuint8_t Low byte of the EEPROM address to read from.
value_ptrPointer to a uint8_t variable where the read value will be stored. Must not be NULL. If read operation fails, the value is set to ERROR_VALUE.
error_ptrPointer to a uint8_t variable where the error status will be stored. Must not be NULL. 0 - no error, otherwise - error code. Error codes:
  • CMD_FAIL_ERROR - read operation failed,
  • LOW_VOLTAGE_ERROR - low voltage error
Warning
This function does not perform address bounds checking. It is the caller's responsibility to ensure valid EEPROM addresses.

◆ eeprom_write_byte

#define eeprom_write_byte (   addr_high,
  addr_low,
  value,
  error_ptr 
)

Writes a single byte to the EEPROM at the specified address.

This function performs a byte write operation to the EEPROM memory using the given high and low bytes of the address. The value to be written is passed as an argument, and any error condition encountered during the operation is reported via the error pointer.

Parameters
addr_highuint8_t High byte of the EEPROM address (bits 15-8).
addr_lowuint8_t Low byte of the EEPROM address (bits 7-0).
valueuint8_t The byte value to be written to EEPROM.
error_ptruint8_t* Pointer to a uint8_t variable where the error status will be stored: Must not be NULL. 0 - no error, otherwise - error code. Error codes:
  • CMD_FAIL_ERROR - read operation failed,
  • LOW_VOLTAGE_ERROR - low voltage error
Note
This is an inline function, intended for fast, low-level EEPROM access. Ensure that the EEPROM is ready for writing prior to calling this function. Improper use may result in data corruption or missed writes.
Warning
Before write byte EEPORM page must be erased.
This function does not perform address bounds checking. It is the caller's responsibility to ensure valid EEPROM addresses.

◆ get_eeprom_last_operation_result

#define get_eeprom_last_operation_result ( )    (get_bit(IAP_CONTR, CMD_FAIL_BIT) ? CMD_FAIL_ERROR : CMD_SUCCESS)

get last operation result

Last operation result is stored in IAP_CONTR register and dont changed on low voltage error

Enumeration Type Documentation

◆ eeprom_operation_status_t

EEPROM operation status.

Enumerator
CMD_SUCCESS 

Operation success.

CMD_FAIL_ERROR 

Operation fail.

LOW_VOLTAGE_ERROR 

Low voltage error.

◆ eeprom_operation_t

EEPROM operation types.

Enumerator
READ_OP 

Read operation.

WRITE_OP 

Write operation.

ERASE_OP 

Erase operation.