1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

Merge remote-tracking branch 'remotes/ficeto/esp8266' into esp8266

This commit is contained in:
Markus Sattler
2015-05-19 16:48:47 +02:00
11 changed files with 74 additions and 48 deletions

View File

@ -112,8 +112,6 @@ void timer1_write(uint32_t ticks); //maximum ticks 8388607
#undef abs
#endif
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
@ -215,6 +213,9 @@ void loop(void);
#include "Esp.h"
#include "debug.h"
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
uint16_t makeWord(uint16_t w);
uint16_t makeWord(byte h, byte l);

View File

@ -158,6 +158,11 @@ uint32_t EspClass::getFlashChipId(void)
return spi_flash_get_id();
}
uint32_t EspClass::getFlashChipRealSize(void)
{
return (1 << ((spi_flash_get_id() >> 16) & 0xFF));
}
uint32_t EspClass::getFlashChipSize(void)
{
uint32_t data;
@ -175,6 +180,12 @@ uint32_t EspClass::getFlashChipSize(void)
return (2_MB);
case 0x4: // 32 MBit (4MB)
return (4_MB);
case 0x5: // 64 MBit (8MB)
return (8_MB);
case 0x6: // 128 MBit (16MB)
return (16_MB);
case 0x7: // 256 MBit (32MB)
return (32_MB);
default: // fail?
return 0;
}

View File

@ -90,6 +90,9 @@ class EspClass {
uint8_t getCpuFreqMHz(void);
uint32_t getFlashChipId(void);
//gets the actual chip size based on the flash id
uint32_t getFlashChipRealSize(void);
//gets the size of the flash as set by the compiler
uint32_t getFlashChipSize(void);
uint32_t getFlashChipSpeed(void);
FlashMode_t getFlashChipMode(void);

View File

@ -23,7 +23,7 @@
#include "spiffs/spiffs_esp8266.h"
#define LOGICAL_PAGE_SIZE 256
#define LOGICAL_BLOCK_SIZE 512
#define LOGICAL_BLOCK_SIZE (INTERNAL_FLASH_SECTOR_SIZE * 1)
// These addresses are defined in the linker script.
@ -64,7 +64,7 @@ int FSClass::_mountInternal(){
SPIFFS_API_DBG_V("FSClass::_mountInternal: start:%x, size:%d Kb\n", cfg.phys_addr, cfg.phys_size / 1024);
_work.reset(new uint8_t[LOGICAL_BLOCK_SIZE]);
_work.reset(new uint8_t[2*LOGICAL_PAGE_SIZE]);
_fdsSize = 32 * _maxOpenFiles;
_fds.reset(new uint8_t[_fdsSize]);
_cacheSize = (32 + LOGICAL_PAGE_SIZE) * _maxOpenFiles;

View File

@ -21,34 +21,13 @@
#include "wiring_private.h"
#include "pins_arduino.h"
extern uint16_t readvdd33(void);
void analogReference(uint8_t mode) {}
extern int __analogRead(uint8_t pin) {
if(pin == 17){
//return system_adc_read();
uint8_t i;
uint16_t data[8];
rom_i2c_writeReg_Mask(0x6C,2,0,5,5,1);
ESP8266_REG(0xD5C) |= (1 << 21);
while ((ESP8266_REG(0xD50) & (7 << 24)) > 0);
ESP8266_REG(0xD50) &= ~(1 << 1);
ESP8266_REG(0xD50) |= (1 << 1);
delayMicroseconds(2);
while ((ESP8266_REG(0xD50) & (7 << 24)) > 0);
read_sar_dout(data);
rom_i2c_writeReg_Mask(0x6C,2,0,5,5,1);
while ((ESP8266_REG(0xD50) & (7 << 24)) > 0);
ESP8266_REG(0xD5C) &= ~(1 << 21);
ESP8266_REG(0xD60) |= (1 << 0);
ESP8266_REG(0xD60) &= ~(1 << 0);
uint16_t tout = 0;
for (i = 0; i < 8; i++) tout += data[i];
return tout >> 4;//tout is 10 bits fraction
return readvdd33() >> 2; // readvdd33 is 12 bit
}
return digitalRead(pin) * 1023;
}