mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
allows global object instances be switch off with defines (#2344)
This commit is contained in:
committed by
Ivan Grokhotkov
parent
bd01e44c76
commit
18297458be
@ -22,7 +22,7 @@
|
||||
#include "Arduino.h"
|
||||
#include "EEPROM.h"
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#include "c_types.h"
|
||||
#include "ets_sys.h"
|
||||
#include "os_type.h"
|
||||
@ -30,6 +30,8 @@
|
||||
#include "spi_flash.h"
|
||||
}
|
||||
|
||||
extern "C" uint32_t _SPIFFS_end;
|
||||
|
||||
EEPROMClass::EEPROMClass(uint32_t sector)
|
||||
: _sector(sector)
|
||||
, _data(0)
|
||||
@ -38,6 +40,14 @@ EEPROMClass::EEPROMClass(uint32_t sector)
|
||||
{
|
||||
}
|
||||
|
||||
EEPROMClass::EEPROMClass(void)
|
||||
: _sector((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE))
|
||||
, _data(0)
|
||||
, _size(0)
|
||||
, _dirty(false)
|
||||
{
|
||||
}
|
||||
|
||||
void EEPROMClass::begin(size_t size) {
|
||||
if (size <= 0)
|
||||
return;
|
||||
@ -121,5 +131,6 @@ uint8_t * EEPROMClass::getDataPtr() {
|
||||
return &_data[0];
|
||||
}
|
||||
|
||||
extern "C" uint32_t _SPIFFS_end;
|
||||
EEPROMClass EEPROM((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE));
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
|
||||
EEPROMClass EEPROM;
|
||||
#endif
|
||||
|
@ -29,6 +29,7 @@
|
||||
class EEPROMClass {
|
||||
public:
|
||||
EEPROMClass(uint32_t sector);
|
||||
EEPROMClass(void);
|
||||
|
||||
void begin(size_t size);
|
||||
uint8_t read(int address);
|
||||
@ -64,7 +65,9 @@ protected:
|
||||
bool _dirty;
|
||||
};
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
|
||||
extern EEPROMClass EEPROM;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user