Added eeprom emulation to store reset info
This commit is contained in:
parent
1f347582b0
commit
76d8416a41
3 changed files with 44 additions and 3 deletions
20
firmware/datastore.ino
Normal file
20
firmware/datastore.ino
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
#include <EEPROM.h>
|
||||||
|
|
||||||
|
#define EEPROM_SIZE 512
|
||||||
|
|
||||||
|
int eeprom_read(int addr) {
|
||||||
|
int ret = -255;
|
||||||
|
EEPROM.begin(EEPROM_SIZE);
|
||||||
|
EEPROM.get(addr, ret);
|
||||||
|
EEPROM.commit();
|
||||||
|
EEPROM.end();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void eeprom_write(int addr, int data) {
|
||||||
|
EEPROM.begin(EEPROM_SIZE);
|
||||||
|
EEPROM.put(addr, data);
|
||||||
|
EEPROM.commit();
|
||||||
|
EEPROM.end();
|
||||||
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
#include <ESP8266WiFiType.h>
|
#include <ESP8266WiFiType.h>
|
||||||
|
|
||||||
#include <esp.h>
|
#include <esp.h>
|
||||||
|
#include <user_interface.h>
|
||||||
#include <WiFiClient.h> // WiFiClient
|
#include <WiFiClient.h> // WiFiClient
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
|
@ -84,10 +84,14 @@ void setup() {
|
||||||
//wdt_disable();
|
//wdt_disable();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DEBUG) || defined(SERIAL_FEATURE)
|
#if defined(DEBUG) || defined(SERIAL_FEATURE) || defined(DEBUG_RESET_REASON)
|
||||||
Serial.begin(SERIAL_BAUD_RATE);
|
Serial.begin(SERIAL_BAUD_RATE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_RESET_REASON
|
||||||
|
debugResetReason();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Pin settings
|
// Pin settings
|
||||||
pinMode(BAT_CHARGED_PIN, INPUT);
|
pinMode(BAT_CHARGED_PIN, INPUT);
|
||||||
pinMode(BAT_CHARGING_PIN, INPUT);
|
pinMode(BAT_CHARGING_PIN, INPUT);
|
||||||
|
@ -783,3 +787,20 @@ void http_call_send_json_data()
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_RESET_REASON
|
||||||
|
void debugResetReason() {
|
||||||
|
|
||||||
|
rst_info *resetInfo;
|
||||||
|
|
||||||
|
// 1. read eeprom reset reason
|
||||||
|
//int eep_reset_reason = eeprom_read(0);
|
||||||
|
//debug("EEPROM reset reason " + String(eep_reset_reason));
|
||||||
|
|
||||||
|
// 2. read real reset reason
|
||||||
|
int reset_reason = resetInfo->reason;
|
||||||
|
|
||||||
|
debug("New reset reason " + String(reset_reason));
|
||||||
|
//eeprom_write(0, reset_reason);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue