Skip to content

Commit b7f8ae5

Browse files
Merge branch 'master' of https://github.com/esp8266/Arduino
2 parents bf69b19 + bcbd596 commit b7f8ae5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+488
-331
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ python get.py
5151

5252
### Using PlatformIO
5353

54-
[PlatformIO](http://platformio.org) is an open source ecosystem for IoT
54+
[PlatformIO](http://platformio.org?utm_source=github&utm_medium=arduino-esp8266) is an open source ecosystem for IoT
5555
development with cross platform build system, library manager and full support
5656
for Espressif (ESP8266) development. It works on the popular host OS: macOS, Windows,
5757
Linux 32/64, Linux ARM (like Raspberry Pi, BeagleBone, CubieBoard).
5858

59-
- [What is PlatformIO?](http://docs.platformio.org/page/what-is-platformio.html)
60-
- [PlatformIO IDE](http://platformio.org/platformio-ide)
61-
- Quick Start with [PlatformIO IDE](http://docs.platformio.org/page/ide/atom.html#quick-start) or [PlatformIO Core](http://docs.platformio.org/page/core.html)
62-
- [Advanced usage](http://docs.platformio.org/page/platforms/espressif.html) -
63-
custom settings, uploading to SPIFFS, Over-the-Air (OTA) or using stage version
64-
- [Integration with Cloud and Standalone IDEs](http://docs.platformio.org/page/ide.html) -
65-
Cloud9, Codeanywhere, Eclipse Che (Codenvy), Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM and Visual Studio
66-
- [Project Examples](http://docs.platformio.org/page/platforms/espressif.html#examples)
59+
- [What is PlatformIO?](http://docs.platformio.org/en/latest/what-is-platformio.html?utm_source=github&utm_medium=arduino-esp8266)
60+
- [PlatformIO IDE](http://platformio.org/platformio-ide?utm_source=github&utm_medium=arduino-esp8266)
61+
- [PlatformIO Core](http://docs.platformio.org/en/latest/core.html?utm_source=github&utm_medium=arduino-esp8266) (command line tool)
62+
- [Advanced usage](http://docs.platformio.org/en/latest/platforms/espressif8266.html?utm_source=github&utm_medium=arduino-esp8266) -
63+
custom settings, uploading to SPIFFS, Over-the-Air (OTA), staging version
64+
- [Integration with Cloud and Standalone IDEs](http://docs.platformio.org/en/latest/ide.html?utm_source=github&utm_medium=arduino-esp8266) -
65+
Cloud9, Codeanywhere, Eclipse Che (Codenvy), Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM, Visual Studio, and VSCode
66+
- [Project Examples](http://docs.platformio.org/en/latest/platforms/espressif8266.html?utm_source=github&utm_medium=arduino-esp8266#examples)
6767

6868
### Building with make
6969

boards.txt

Lines changed: 104 additions & 96 deletions
Large diffs are not rendered by default.

cores/esp8266/Esp.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,22 @@ void EspClass::wdtFeed(void)
107107

108108
extern "C" void esp_yield();
109109

110-
void EspClass::deepSleep(uint32_t time_us, WakeMode mode)
110+
void EspClass::deepSleep(uint64_t time_us, WakeMode mode)
111111
{
112112
system_deep_sleep_set_option(static_cast<int>(mode));
113113
system_deep_sleep(time_us);
114114
esp_yield();
115115
}
116116

117+
//this calculation was taken verbatim from the SDK api reference for SDK 2.1.0.
118+
//Note: system_rtc_clock_cali_proc() returns a uint32_t, even though system_deep_sleep() takes a uint64_t.
119+
uint64_t EspClass::deepSleepMax()
120+
{
121+
//cali*(2^31-1)/(2^12)
122+
return (uint64_t)system_rtc_clock_cali_proc()*(0x80000000-1)/(0x1000);
123+
124+
}
125+
117126
bool EspClass::rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size)
118127
{
119128
if (size + offset > 512) {

cores/esp8266/Esp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ class EspClass {
9292
void wdtDisable();
9393
void wdtFeed();
9494

95-
void deepSleep(uint32_t time_us, RFMode mode = RF_DEFAULT);
95+
void deepSleep(uint64_t time_us, RFMode mode = RF_DEFAULT);
96+
uint64_t deepSleepMax();
9697

9798
bool rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size);
9899
bool rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size);

cores/esp8266/core_esp8266_i2s.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,43 @@ static uint32_t _i2s_sample_rate;
212212
void ICACHE_FLASH_ATTR i2s_set_rate(uint32_t rate){ //Rate in HZ
213213
if(rate == _i2s_sample_rate) return;
214214
_i2s_sample_rate = rate;
215-
uint32_t i2s_clock_div = (I2SBASEFREQ/(_i2s_sample_rate*32)) & I2SCDM;
216-
uint8_t i2s_bck_div = (I2SBASEFREQ/(_i2s_sample_rate*i2s_clock_div*2)) & I2SBDM;
215+
216+
uint32_t scaled_base_freq = I2SBASEFREQ/32;
217+
float delta_best = scaled_base_freq;
218+
219+
uint8_t sbd_div_best=1;
220+
uint8_t scd_div_best=1;
221+
for (uint8_t i=1; i<64; i++){
222+
for (uint8_t j=i; j<64; j++){
223+
float new_delta = fabs(((float)scaled_base_freq/i/j) - rate);
224+
if (new_delta < delta_best){
225+
delta_best = new_delta;
226+
sbd_div_best = i;
227+
scd_div_best = j;
228+
}
229+
}
230+
}
231+
217232
//os_printf("Rate %u Div %u Bck %u Frq %u\n", _i2s_sample_rate, i2s_clock_div, i2s_bck_div, I2SBASEFREQ/(i2s_clock_div*i2s_bck_div*2));
218233

219234
//!trans master, !bits mod, rece slave mod, rece msb shift, right first, msb right
220235
I2SC &= ~(I2STSM | (I2SBMM << I2SBM) | (I2SBDM << I2SBD) | (I2SCDM << I2SCD));
221-
I2SC |= I2SRF | I2SMR | I2SRSM | I2SRMS | ((i2s_bck_div-1) << I2SBD) | ((i2s_clock_div-1) << I2SCD);
236+
I2SC |= I2SRF | I2SMR | I2SRSM | I2SRMS | ((sbd_div_best) << I2SBD) | ((scd_div_best) << I2SCD);
237+
}
238+
239+
void ICACHE_FLASH_ATTR i2s_set_dividers(uint8_t div1, uint8_t div2){
240+
div1 &= I2SBDM;
241+
div2 &= I2SCDM;
242+
243+
I2SC &= ~(I2STSM | (I2SBMM << I2SBM) | (I2SBDM << I2SBD) | (I2SCDM << I2SCD));
244+
I2SC |= I2SRF | I2SMR | I2SRSM | I2SRMS | (div1 << I2SBD) | (div2 << I2SCD);
222245
}
223246

247+
float ICACHE_FLASH_ATTR i2s_get_real_rate(){
248+
return (float)I2SBASEFREQ/32/((I2SC>>I2SBD) & I2SBDM)/((I2SC >> I2SCD) & I2SCDM);
249+
}
250+
251+
224252
void ICACHE_FLASH_ATTR i2s_begin(){
225253
_i2s_sample_rate = 0;
226254
i2s_slc_begin();

cores/esp8266/esp8266_peri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ extern uint8_t esp8266_gpioToFn[16];
754754
#define i2c_bbpll_en_audio_clock_out_msb 7
755755
#define i2c_bbpll_en_audio_clock_out_lsb 7
756756
#define I2S_CLK_ENABLE() i2c_writeReg_Mask_def(i2c_bbpll, i2c_bbpll_en_audio_clock_out, 1)
757-
#define I2SBASEFREQ (12000000L)
757+
#define I2SBASEFREQ (160000000L)
758758

759759
#define I2STXF ESP8266_REG(0xe00) //I2STXFIFO (32bit)
760760
#define I2SRXF ESP8266_REG(0xe04) //I2SRXFIFO (32bit)

cores/esp8266/i2s.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ extern "C" {
4343
void i2s_begin();
4444
void i2s_end();
4545
void i2s_set_rate(uint32_t rate);//Sample Rate in Hz (ex 44100, 48000)
46+
void i2s_set_dividers(uint8_t div1, uint8_t div2);//Direct control over output rate
47+
float i2s_get_real_rate();//The actual Sample Rate on output
4648
bool i2s_write_sample(uint32_t sample);//32bit sample with channels being upper and lower 16 bits (blocking when DMA is full)
4749
bool i2s_write_sample_nb(uint32_t sample);//same as above but does not block when DMA is full and returns false instead
4850
bool i2s_write_lr(int16_t left, int16_t right);//combines both channels and calls i2s_write_sample with the result
@@ -54,4 +56,4 @@ int16_t i2s_available();// returns the number of samples than can be written bef
5456
}
5557
#endif
5658

57-
#endif
59+
#endif

cores/esp8266/spiffs_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ class SPIFFSFileImpl : public FileImpl
329329
if (mode == SeekEnd) {
330330
offset = -offset;
331331
}
332-
auto rc = SPIFFS_lseek(_fs->getFs(), _fd, pos, (int) mode);
332+
auto rc = SPIFFS_lseek(_fs->getFs(), _fd, offset, (int) mode);
333333
if (rc < 0) {
334334
DEBUGV("SPIFFS_lseek rc=%d\r\n", rc);
335335
return false;

cores/esp8266/umm_malloc/umm_malloc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,9 @@ void *umm_calloc( size_t num, size_t item_size ) {
16851685

16861686
size += POISON_SIZE(size);
16871687
ret = _umm_malloc(size);
1688-
memset(ret, 0x00, size);
1688+
if (ret) {
1689+
memset(ret, 0x00, size);
1690+
}
16891691

16901692
ret = GET_POISONED(ret, size);
16911693

doc/esp8266wifi/client-class.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ Other Function Calls
5959
Documentation for the above functions is not yet prepared.
6060

6161
For code samples please refer to separate section with `examples
62-
:arrow\_right: <client-examples.md>`__ dedicated specifically to the Client Class.
62+
:arrow\_right: <client-examples.rst>`__ dedicated specifically to the Client Class.

0 commit comments

Comments
 (0)