Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Toggle main menu visibility
Loading...
Searching...
No Matches
Non-Volatile Memory User Guide
What is NVM?
NVM provides persistent storage for configuration, state, diagnostics.
Caller manages address space and layout. Read/write with checksums.
Quick Start
* // Define NVM layout
* #define CONFIG_ADDR 0
* #define CONFIG_SIZE 256
*
* // Read configuration
* config_t cfg;
* sapi_nvm_read(CONFIG_ADDR, (uint8_t *)&cfg, sizeof(cfg));
*
* // Verify checksum
* uint32_t crc = compute_crc((uint8_t *)&cfg, sizeof(cfg) - 4);
* if (crc != cfg.checksum) {
* log_error("Config corrupted");
* use_default_config(&cfg);
* }
*
* // Save configuration
* cfg.checksum = compute_crc((uint8_t *)&cfg, sizeof(cfg) - 4);
* sapi_nvm_write(CONFIG_ADDR, (uint8_t *)&cfg, sizeof(cfg));
*
Best Practices
1. Always use checksums
2. Manage wear (limit writes)
3. Plan address layout
4. Version data for evolution
See Also
-
Non-Volatile Memory Architecture
for design
-
Checksum Module - User Guide
for CRC
*/
Generated by
1.18.0