mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
commit
24ce4518d7
21
changes.md
Normal file
21
changes.md
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
|
||||
# Current version
|
||||
|
||||
- Add 32-bit Linux toolchain
|
||||
- Better connection handling in ESP8266WebServer.
|
||||
The server now sends Content-Length and Connection: close headers,
|
||||
then waits for the client to disconnect. By not closing the connection
|
||||
actively, server avoids TIME_WAIT TCP state, and the TCP stack is able to
|
||||
release the memory immediately, without waiting for 2xMSL period.
|
||||
If the client doesn't disconnect in 2000ms, the server closes the connection
|
||||
actively.
|
||||
- Add Hash library, which has a function to calculate SHA1 hash.
|
||||
|
||||
---
|
||||
|
||||
# 1.6.4-g545ffde
|
||||
19 May, 2015
|
||||
|
||||
- Initial release of board manager package
|
||||
|
@ -28,35 +28,35 @@
|
||||
#include "os_type.h"
|
||||
#include "osapi.h"
|
||||
#include "spi_flash.h"
|
||||
extern uint32_t _SPIFFS_end;
|
||||
}
|
||||
|
||||
#define CONFIG_START_SECTOR (((uint32_t)_SPIFFS_end - 0x40200000) / 4096)
|
||||
#define CONFIG_SECTOR (CONFIG_START_SECTOR + 0)
|
||||
#define CONFIG_ADDR (SPI_FLASH_SEC_SIZE * CONFIG_SECTOR)
|
||||
|
||||
EEPROMClass::EEPROMClass()
|
||||
: _data(0), _size(0), _dirty(false)
|
||||
EEPROMClass::EEPROMClass(uint32_t sector)
|
||||
: _sector(sector)
|
||||
, _data(0)
|
||||
, _size(0)
|
||||
, _dirty(false)
|
||||
{
|
||||
}
|
||||
|
||||
void EEPROMClass::begin(size_t size)
|
||||
{
|
||||
void EEPROMClass::begin(size_t size) {
|
||||
if (size <= 0)
|
||||
return;
|
||||
if (size > SPI_FLASH_SEC_SIZE)
|
||||
size = SPI_FLASH_SEC_SIZE;
|
||||
|
||||
if (_data) {
|
||||
delete[] _data;
|
||||
}
|
||||
|
||||
_data = new uint8_t[size];
|
||||
_size = size;
|
||||
|
||||
noInterrupts();
|
||||
spi_flash_read(CONFIG_ADDR, reinterpret_cast<uint32_t*>(_data), _size);
|
||||
spi_flash_read(_sector * SPI_FLASH_SEC_SIZE, reinterpret_cast<uint32_t*>(_data), _size);
|
||||
interrupts();
|
||||
}
|
||||
|
||||
void EEPROMClass::end()
|
||||
{
|
||||
void EEPROMClass::end() {
|
||||
if (!_size)
|
||||
return;
|
||||
|
||||
@ -69,8 +69,7 @@ void EEPROMClass::end()
|
||||
}
|
||||
|
||||
|
||||
uint8_t EEPROMClass::read(int address)
|
||||
{
|
||||
uint8_t EEPROMClass::read(int address) {
|
||||
if (address < 0 || (size_t)address >= _size)
|
||||
return 0;
|
||||
if(!_data)
|
||||
@ -79,8 +78,7 @@ uint8_t EEPROMClass::read(int address)
|
||||
return _data[address];
|
||||
}
|
||||
|
||||
void EEPROMClass::write(int address, uint8_t value)
|
||||
{
|
||||
void EEPROMClass::write(int address, uint8_t value) {
|
||||
if (address < 0 || (size_t)address >= _size)
|
||||
return;
|
||||
if(!_data)
|
||||
@ -90,8 +88,7 @@ void EEPROMClass::write(int address, uint8_t value)
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
bool EEPROMClass::commit()
|
||||
{
|
||||
bool EEPROMClass::commit() {
|
||||
bool ret = false;
|
||||
if (!_size)
|
||||
return false;
|
||||
@ -101,8 +98,8 @@ bool EEPROMClass::commit()
|
||||
return false;
|
||||
|
||||
noInterrupts();
|
||||
if(spi_flash_erase_sector(CONFIG_SECTOR) == SPI_FLASH_RESULT_OK) {
|
||||
if(spi_flash_write(CONFIG_ADDR, reinterpret_cast<uint32_t*>(_data), _size) == SPI_FLASH_RESULT_OK) {
|
||||
if(spi_flash_erase_sector(_sector) == SPI_FLASH_RESULT_OK) {
|
||||
if(spi_flash_write(_sector * SPI_FLASH_SEC_SIZE, reinterpret_cast<uint32_t*>(_data), _size) == SPI_FLASH_RESULT_OK) {
|
||||
_dirty = false;
|
||||
ret = true;
|
||||
}
|
||||
@ -112,11 +109,10 @@ bool EEPROMClass::commit()
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t * EEPROMClass::getDataPtr()
|
||||
{
|
||||
uint8_t * EEPROMClass::getDataPtr() {
|
||||
_dirty = true;
|
||||
return &_data[0];
|
||||
}
|
||||
|
||||
|
||||
EEPROMClass EEPROM;
|
||||
extern "C" uint32_t _SPIFFS_end;
|
||||
EEPROMClass EEPROM((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE));
|
||||
|
@ -26,10 +26,10 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
class EEPROMClass
|
||||
{
|
||||
class EEPROMClass {
|
||||
public:
|
||||
EEPROMClass();
|
||||
EEPROMClass(uint32_t sector);
|
||||
|
||||
void begin(size_t size);
|
||||
uint8_t read(int address);
|
||||
void write(int address, uint8_t val);
|
||||
@ -38,28 +38,27 @@ class EEPROMClass
|
||||
|
||||
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)
|
||||
return t;
|
||||
|
||||
uint8_t *ptr = (uint8_t*) &t;
|
||||
memcpy(ptr, _data + address, sizeof(T));
|
||||
memcpy((uint8_t*) &t, _data + address, sizeof(T));
|
||||
return t;
|
||||
}
|
||||
|
||||
template<typename T> const T &put(int address, const T &t)
|
||||
{
|
||||
template<typename T>
|
||||
const T &put(int address, const T &t) {
|
||||
if (address < 0 || address + sizeof(T) > _size)
|
||||
return t;
|
||||
|
||||
const uint8_t *ptr = (const uint8_t*) &t;
|
||||
memcpy(_data + address, ptr, sizeof(T));
|
||||
memcpy(_data + address, (const uint8_t*) &t, sizeof(T));
|
||||
_dirty = true;
|
||||
return t;
|
||||
}
|
||||
|
||||
protected:
|
||||
uint32_t _sector;
|
||||
uint8_t* _data;
|
||||
size_t _size;
|
||||
bool _dirty;
|
||||
|
@ -22,7 +22,7 @@ void loop()
|
||||
// need to divide by 4 because analog inputs range from
|
||||
// 0 to 1023 and each byte of the EEPROM can only hold a
|
||||
// value from 0 to 255.
|
||||
int val = analogRead(0) / 4;
|
||||
int val = analogRead(A0) / 4;
|
||||
|
||||
// write the value to the appropriate byte of the EEPROM.
|
||||
// these values will remain there when the board is
|
||||
|
Loading…
x
Reference in New Issue
Block a user