STM32 core 3.0.1-dev
Arduino core for STM32 based boards: API reference
← STM32duino documentation
Loading...
Searching...
No Matches
stm32_eeprom.h File Reference

Header for eeprom module. More...

#include "stm32_def.h"

Macros

#define FLASH_FLAG_ALL_ERRORS
 Mask of all the flash error flags to clear before programming.
 
#define FLASH_PAGE_SIZE   ((uint32_t)(8*1024)) /* 8kB page */
 Size of the flash area used for the EEPROM emulation.
 
#define E2END   (FLASH_PAGE_SIZE - 1)
 Last EEPROM address (EEPROM size - 1).
 

Functions

uint8_t eeprom_read_byte (const uint32_t pos)
 Read a byte from the emulated EEPROM (flash).
 
void eeprom_write_byte (uint32_t pos, uint8_t value)
 Write a byte to the emulated EEPROM (flash).
 
void eeprom_buffer_fill ()
 Copy the data from flash into the EEPROM buffer.
 
void eeprom_buffer_flush ()
 Write the EEPROM buffer content into flash.
 
uint8_t eeprom_buffered_read_byte (const uint32_t pos)
 Read a byte from the EEPROM buffer, flash is not read.
 
void eeprom_buffered_write_byte (uint32_t pos, uint8_t value)
 Write a byte to the EEPROM buffer, flash is not updated.
 

Detailed Description

Header for eeprom module.

Attention

Copyright (c) 2016-2021, STMicroelectronics All rights reserved.

This software component is licensed by ST under BSD 3-Clause license, the "License"; You may not use this file except in compliance with the License. You may obtain a copy of the License at: opensource.org/licenses/BSD-3-Clause

Macro Definition Documentation

◆ FLASH_FLAG_ALL_ERRORS

#define FLASH_FLAG_ALL_ERRORS
Value:
(FLASH_FLAG_OPERR | FLASH_FLAG_PROGERR | FLASH_FLAG_WRPERR | \
FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR | FLASH_FLAG_PGSERR | \
FLASH_FLAG_MISERR | FLASH_FLAG_FASTERR | \
FLASH_FLAG_OPTVERR | FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)

Mask of all the flash error flags to clear before programming.

◆ FLASH_PAGE_SIZE

#define FLASH_PAGE_SIZE   ((uint32_t)(8*1024)) /* 8kB page */

Size of the flash area used for the EEPROM emulation.

FLASH_PAGE_SIZE is not defined for STM32F2xx, STM32F4xx and STM32F7xx Could be redefined in variant.h or using build_opt.h

Warning
This is not the sector size, only the size used for EEPROM emulation. Anyway, all the sector size will be erased. So pay attention to not use this sector for other stuff.

Function Documentation

◆ eeprom_buffer_fill()

void eeprom_buffer_fill ( )

Copy the data from flash into the EEPROM buffer.

Note
Any pending change in the buffer which was not flushed is overwritten.

◆ eeprom_buffer_flush()

void eeprom_buffer_flush ( )

Write the EEPROM buffer content into flash.

Note
Use it after eeprom_buffered_write_byte() to make the changes persistent.

◆ eeprom_buffered_read_byte()

uint8_t eeprom_buffered_read_byte ( const uint32_t  pos)

Read a byte from the EEPROM buffer, flash is not read.

Parameters
posAddress to read.
Returns
Data read from the EEPROM buffer.

◆ eeprom_buffered_write_byte()

void eeprom_buffered_write_byte ( uint32_t  pos,
uint8_t  value 
)

Write a byte to the EEPROM buffer, flash is not updated.

Parameters
posAddress to write.
valueValue to write.

◆ eeprom_read_byte()

uint8_t eeprom_read_byte ( const uint32_t  pos)

Read a byte from the emulated EEPROM (flash).

With a real data EEPROM, pos is a relative address and 0 is returned if it is out of range. Otherwise the flash content is first copied into the EEPROM buffer.

Parameters
posAddress to read.
Returns
Data read from EEPROM.

◆ eeprom_write_byte()

void eeprom_write_byte ( uint32_t  pos,
uint8_t  value 
)

Write a byte to the emulated EEPROM (flash).

With a real data EEPROM, pos is a relative address and the write is ignored if it is out of range. Otherwise the byte is written to the EEPROM buffer, then the whole buffer is written into flash.

Parameters
posAddress to write.
valueValue to write.