mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Merge branch 'esp8266' of https://github.com/Links2004/Arduino into Links2004-esp8266
This commit is contained in:
commit
38c74232c9
@ -30,12 +30,12 @@
|
|||||||
#include "spi_flash.h"
|
#include "spi_flash.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CONFIG_START_SECTOR 0x3C
|
#define CONFIG_START_SECTOR 0x7b
|
||||||
#define CONFIG_SECTOR (CONFIG_START_SECTOR + 0)
|
#define CONFIG_SECTOR (CONFIG_START_SECTOR + 0)
|
||||||
#define CONFIG_ADDR (SPI_FLASH_SEC_SIZE * CONFIG_SECTOR)
|
#define CONFIG_ADDR (SPI_FLASH_SEC_SIZE * CONFIG_SECTOR)
|
||||||
|
|
||||||
EEPROMClass::EEPROMClass()
|
EEPROMClass::EEPROMClass()
|
||||||
: _data(0), _size(0)
|
: _data(0), _size(0), _dirty(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ void EEPROMClass::end()
|
|||||||
|
|
||||||
uint8_t EEPROMClass::read(int address)
|
uint8_t EEPROMClass::read(int address)
|
||||||
{
|
{
|
||||||
if (address < 0 || address >= _size)
|
if (address < 0 || (size_t)address >= _size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return _data[address];
|
return _data[address];
|
||||||
@ -75,23 +75,35 @@ uint8_t EEPROMClass::read(int address)
|
|||||||
|
|
||||||
void EEPROMClass::write(int address, uint8_t value)
|
void EEPROMClass::write(int address, uint8_t value)
|
||||||
{
|
{
|
||||||
if (address < 0 || address >= _size)
|
if (address < 0 || (size_t)address >= _size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_data[address] = value;
|
_data[address] = value;
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EEPROMClass::commit()
|
bool EEPROMClass::commit()
|
||||||
{
|
{
|
||||||
if (!_size || !_dirty)
|
bool ret = false;
|
||||||
return;
|
if (!_size)
|
||||||
|
return false;
|
||||||
|
if(!_dirty)
|
||||||
|
return true;
|
||||||
|
|
||||||
ETS_UART_INTR_DISABLE();
|
ETS_UART_INTR_DISABLE();
|
||||||
spi_flash_erase_sector(CONFIG_SECTOR);
|
if(spi_flash_erase_sector(CONFIG_SECTOR) == SPI_FLASH_RESULT_OK) {
|
||||||
spi_flash_write(CONFIG_ADDR, reinterpret_cast<uint32_t*>(_data), _size);
|
if(spi_flash_write(CONFIG_ADDR, reinterpret_cast<uint32_t*>(_data), _size) == SPI_FLASH_RESULT_OK) {
|
||||||
|
_dirty = false;
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
ETS_UART_INTR_ENABLE();
|
ETS_UART_INTR_ENABLE();
|
||||||
_dirty = false;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t * EEPROMClass::getDataPtr()
|
||||||
|
{
|
||||||
|
return &_data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,9 +33,11 @@ class EEPROMClass
|
|||||||
void begin(size_t size);
|
void begin(size_t size);
|
||||||
uint8_t read(int address);
|
uint8_t read(int address);
|
||||||
void write(int address, uint8_t val);
|
void write(int address, uint8_t val);
|
||||||
void commit();
|
bool commit();
|
||||||
void end();
|
void end();
|
||||||
|
|
||||||
|
uint8_t * getDataPtr();
|
||||||
|
|
||||||
template<typename T> T &get(int address, T &t)
|
template<typename T> T &get(int address, T &t)
|
||||||
{
|
{
|
||||||
if (address < 0 || address + sizeof(T) > _size)
|
if (address < 0 || address + sizeof(T) > _size)
|
||||||
|
@ -74,7 +74,7 @@ recipe.objcopy.eep.pattern=
|
|||||||
## Create hex
|
## Create hex
|
||||||
#recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
|
#recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
|
||||||
|
|
||||||
recipe.objcopy.hex.pattern="{compiler.tools.path}{compiler.esptool.cmd}" -eo "{build.path}/{build.project_name}.elf" -bo "{build.path}/{build.project_name}_00000.bin" -bm {build.flash_mode} -bf {build.flash_freq} -bz {build.flash_size} -bs .text -bs .data -bs .rodata -bc -ec -eo "{build.path}/{build.project_name}.elf" -es .irom0.text "{build.path}/{build.project_name}_40000.bin" -ec
|
recipe.objcopy.hex.pattern="{compiler.tools.path}{compiler.esptool.cmd}" -eo "{build.path}/{build.project_name}.elf" -bo "{build.path}/{build.project_name}_00000.bin" -bm {build.flash_mode} -bf {build.flash_freq} -bz {build.flash_size} -bs .text -bs .data -bs .rodata -bc -ec -eo "{build.path}/{build.project_name}.elf" -es .irom0.text "{build.path}/{build.project_name}_10000.bin" -ec
|
||||||
|
|
||||||
## Compute size
|
## Compute size
|
||||||
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
||||||
@ -91,4 +91,4 @@ tools.esptool.path={runtime.ide.path}/hardware/tools/esp8266
|
|||||||
tools.esptool.upload.protocol=esp
|
tools.esptool.upload.protocol=esp
|
||||||
tools.esptool.upload.params.verbose=-vv
|
tools.esptool.upload.params.verbose=-vv
|
||||||
tools.esptool.upload.params.quiet=
|
tools.esptool.upload.params.quiet=
|
||||||
tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}_00000.bin" -ca 0x40000 -cf "{build.path}/{build.project_name}_40000.bin"
|
tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}_00000.bin" -ca 0x10000 -cf "{build.path}/{build.project_name}_10000.bin"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user