1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-23 19:21:59 +03:00

Add offset parameter to rtcUserMemoryRead/Write, expose RTC_USER_MEM in esp8266_peri.h

This commit is contained in:
Ivan Grokhotkov
2016-06-02 13:39:53 +08:00
parent 9e60d4d463
commit 4b43860276
4 changed files with 11 additions and 9 deletions

View File

@ -112,21 +112,21 @@ void EspClass::deepSleep(uint32_t time_us, WakeMode mode)
esp_yield(); esp_yield();
} }
bool EspClass::rtcUserMemoryRead(uint32_t *data, size_t size) bool EspClass::rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size)
{ {
if (size > 512) { if (size + offset > 512) {
return false; return false;
} else { } else {
return system_rtc_mem_read(64, data, size); return system_rtc_mem_read(64 + offset, data, size);
} }
} }
bool EspClass::rtcUserMemoryWrite(uint32_t *data, size_t size) bool EspClass::rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size)
{ {
if (size > 512) { if (size + offset > 512) {
return false; return false;
} else { } else {
return system_rtc_mem_write(64, data, size); return system_rtc_mem_write(64 + offset, data, size);
} }
} }

View File

@ -94,8 +94,8 @@ class EspClass {
void deepSleep(uint32_t time_us, RFMode mode = RF_DEFAULT); void deepSleep(uint32_t time_us, RFMode mode = RF_DEFAULT);
bool rtcUserMemoryRead(uint32_t *data, size_t size); bool rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size);
bool rtcUserMemoryWrite(uint32_t *data, size_t size); bool rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size);
void reset(); void reset();
void restart(); void restart();

View File

@ -169,6 +169,8 @@ extern uint8_t esp8266_gpioToFn[16];
#define RTCIC ESP8266_REG(0x724) //RTC INT Clear #define RTCIC ESP8266_REG(0x724) //RTC INT Clear
#define RTCIE ESP8266_REG(0x728) //RTC INT Enable #define RTCIE ESP8266_REG(0x728) //RTC INT Enable
#define RTC_USER_MEM ((volatile uint32_t*)0x60001200)
//IO SWAP Register //IO SWAP Register
#define IOSWAP ESP8266_DREG(0x28) #define IOSWAP ESP8266_DREG(0x28)
#define IOSWAPU 0 //Swaps UART #define IOSWAPU 0 //Swaps UART

View File

@ -83,7 +83,7 @@ APIs related to deep sleep and watchdog timer are available in the `ESP` object,
`ESP.deepSleep(microseconds, mode)` will put the chip into deep sleep. `mode` is one of `WAKE_RF_DEFAULT`, `WAKE_RFCAL`, `WAKE_NO_RFCAL`, `WAKE_RF_DISABLED`. (GPIO16 needs to be tied to RST to wake from deepSleep.) `ESP.deepSleep(microseconds, mode)` will put the chip into deep sleep. `mode` is one of `WAKE_RF_DEFAULT`, `WAKE_RFCAL`, `WAKE_NO_RFCAL`, `WAKE_RF_DISABLED`. (GPIO16 needs to be tied to RST to wake from deepSleep.)
`ESP.rtcUserMemoryWrite(&data, sizeof(data))` and `ESP.rtcUserMemoryRead(&data, sizeof(data))` allow struct data with the maximum size of 512 bytes to be stored and retrieved from the RTC user memory of the chip respectively. The stored data can be retained between deep sleep cycles. However, the data might be lost after power cycling the chip. `ESP.rtcUserMemoryWrite(offset, &data, sizeof(data))` and `ESP.rtcUserMemoryRead(offset, &data, sizeof(data))` allow data to be stored in and retrieved from the RTC user memory of the chip respectively. Total size of RTC user memory is 512 bytes, so offset + sizeof(data) shouldn't exceed 512. Data should be 4-byte aligned. The stored data can be retained between deep sleep cycles. However, the data might be lost after power cycling the chip.
`ESP.restart()` restarts the CPU. `ESP.restart()` restarts the CPU.