Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/eePublic

EEPROM emulation for stm32.

License

NotificationsYou must be signed in to change notification settings

nimaltd/ee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple and reliableEEPROM emulation library written in C for STM32 (HAL-based).

This library allows you tostore and retrieve non-volatile data using the STM32's internal Flash memory — ideal for devices that do not include dedicated EEPROM.

It provides a lightweight API forinitialization, read, write, format, andcapacity management, making it easy to integrate into any STM32 project.

It supports all STM32 series.


✨ Features

  • 🧩 Fullyblocking, synchronous operation
  • 💾 Usesinternal Flash for data storage
  • 🧱 Configurablepage/sector size and memory layout (Auto and Manual)
  • 🧠 Supportsdata structure mapping for easy use
  • ⚙️ Works with bothsingle-bank and dual-bank Flash configurations
  • 🔐 Safe write mechanism to protect existing data
  • 📂 Clean, modular, and portable API

⚙️ Installation

You can add the library to your STM32 project in two ways:

1. Copy files directly

Add these files to your project:

  • ee.h
  • ee.c
  • ee_config.h

Include them in your application source files and compile.

2. STM32Cube Pack Installer (optional)

Future support will be available via the official STM32 pack repository.


🔧 Configuration (ee_config.h)

Defines page/sector sizes and optional manual Flash configuration or Use Auto Selection (define EE_MANUAL_CONFIG = 0).

/* USER CODE BEGIN EE_CONFIGURATION */#defineEE_MANUAL_CONFIG                  0#if (EE_MANUAL_CONFIG==1)#defineEE_SELECTED_PAGE_SECTOR_NUMBER    16#defineEE_SELECTED_PAGE_SECTOR_SIZE      EE_PAGE_SECTOR_SIZE_1K#defineEE_SELECTED_BANK                  FLASH_BANK_1#defineEE_SELECTED_ADDRESS               0x08000000#endif/* USER CODE END EE_CONFIGURATION */

🧰 API Overview

FunctionDescription
ee_init()Initialize EEPROM emulation module with a data buffer
ee_capacity()Get total emulated EEPROM capacity (in bytes)
ee_format()Erase and format the EEPROM area in Flash memory
ee_read()Load data from Flash into RAM buffer
ee_write()Save (write) the RAM buffer back to Flash memory

🚀 Quick Start

Use your data structure like this:

#include"ee.h"typedefstruct{uint32_tval1;int16_tval2;int8_tval3;floatval4;}stotrage_t;stotrage_tee_data;intmain(void){// HAL / system init ...// ...ee_init(&ee_data,sizeof(stotrage_t));ee_read();ee_data.val1=10000;ee_data.val2=-202;ee_data.val3=-3;ee_data.val4=4.5f;ee_write();while (1)  {// main loop...  }}

💡 Notes

  • Flash erase/write cycles arelimited — avoid frequent writes.
  • For some series should enable 'EE_MANUAL_CONFIG'.

Watch the Video ( Previous version ):

Video

💖 Support

If this project helped you, please⭐ star the repo and consider supporting:

  • GitHub
  • YouTube
  • Instagram
  • LinkedIn
  • Email
  • Ko-fi

📜 License

Licensed under the terms in theLICENSE.


[8]ページ先頭

©2009-2025 Movatter.jp