-
Notifications
You must be signed in to change notification settings - Fork 0
DS_CAP_SYS_RTCMEM
Denis Stepanov edited this page May 14, 2021
·
6 revisions
This capability adds support for reading and writing RTC memory (a small memory region of 512 bytes surviving deep sleep). The following methods are available:
// Read 'num' 4 bytes slots from RTC memory offset 'idx' into 'result'
bool System::getRTCMem(uint32_t* result, const uint8_t idx = 0, const uint8_t num = 1);
// Store 'num' 4 bytes slots into RTC memory offset 'idx' from 'source'
bool System::setRTCMem(const uint32_t* source, const uint8_t idx = 0, const uint8_t num = 1);
The API is inspired by NodeMCU Lua 'rtcmem' module. The memory is divided in "slots" of four bytes each, addressable with the index idx
, starting from 0. The number of slots to read or write is given by the num
argument. Operations return true
on success. The functions are just thin interface to built-in ESP.rtcUserMemoryRead()
/ ESP.rtcUserMemoryWrite()
functions.
- ESP8266 Arduino Core — RTC memory implementation
None.
None.
MySystem.h
:
#define DS_CAP_SYS_RTCMEM // Enable RTC memory
#include "System.h" // System global definitions
sketch.ino
:
#include "MySystem.h"
using namespace ds;
void setup() {
// Send one number (four bytes) into RTC memory
uint32_t number_to_write = 3;
auto ret = System::setRTCMem(&number_to_write);
// Fetch stored number from RTC memory
uint32_t restored_number;
ret = System::getRTCMem(&restored_number);
// Example of storing an array with an offset of 10 slots (i.e., starting from 40th byte of RTC)
uint32_t data_to_write[3] = {3, 14, 159};
ret = System::setRTCMem(data_to_write, 10, 3);
uint32_t restored_data[3];
ret = System::getRTCMem(restored_data, 10, 3);
}
void loop() {
}
System::begin() |
Not required |
System::update() |
Not required |
- This API is not very convenient to store strings. This may be added in future (issue #8)
Version 1.0 or later.
None.
- DS_CAP_APP_ID
- DS_CAP_APP_LOG
- DS_CAP_BUTTON
- DS_CAP_MDNS
- DS_CAP_SYS_FS
- DS_CAP_SYS_LED
- DS_CAP_SYS_LOG
- DS_CAP_SYS_LOG_HW
- DS_CAP_SYS_NETWORK
- DS_CAP_SYS_RESET
- DS_CAP_SYS_RTCMEM
- DS_CAP_SYS_TIME
- DS_CAP_SYS_UPTIME
- DS_CAP_TIMERS
- DS_CAP_TIMERS_ABS
- DS_CAP_TIMERS_COUNT_ABS
- DS_CAP_TIMERS_COUNT_TICK
- DS_CAP_TIMERS_SOLAR
- DS_CAP_WEB_TIMERS
- DS_CAP_WEBSERVER
- DS_CAP_WIFIMANAGER