-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESP8266
No-WiFi
library updates (#2347)
* Add `os_get_random()` implementation for no_wifi library * Filesystem fixes for `esp_no_wifi` library Require `system_rtc_clock_cali_proc` to use filesystem as SPIFFS uses time functions Call to `Storage::initialize()` required in `user_init()` KNOWN ISSUE: Call to `spi_flash_get_id()` hangs in application code. * Use flash cache control register definitions from RTOS SDK * Expand SPI ext0-2 struct definitions (likely related to flash) * Fix unused static variables in esp-lwip mem_manager.h * Add Platform/Timers.h to SmingCore.h * Update README
- Loading branch information
Showing
12 changed files
with
228 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,8 @@ extern "C" void user_init(void) | |
|
||
gdb_init(); | ||
|
||
Storage::initialize(); | ||
|
||
init(); // User code init | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,66 @@ | ||
#include <stdint.h> | ||
#include <espinc/gpio_register.h> | ||
#include <espinc/i2c_bbpll.h> | ||
|
||
void ets_delay_us(uint32_t); | ||
|
||
// Crystal frequency: 0=40, 1=26, 2=24 | ||
extern uint8_t chip6_phy_init_ctrl; | ||
|
||
void uart_tx_flush(void) | ||
{ | ||
} | ||
|
||
/* | ||
* Returns a calibration factor giving the ratio of system clock ticks to RTC time. | ||
* NB. The calibration code is from `pm_rtc_clock_cali` in the `phy_sleep` module. | ||
* To keep things simple we're just rolling it up into one function here. | ||
*/ | ||
uint32_t pm_rtc_clock_cali_proc(void) | ||
{ | ||
static uint32_t calibration_value; | ||
|
||
rom_i2c_writeReg(106, 2, 8, 0); | ||
|
||
uint32_t value; | ||
do { | ||
value = GPIO_REG_READ(GPIO_RTC_CALIB_VALUE_ADDRESS); | ||
} while((value & RTC_CALIB_RDY) == 0); | ||
|
||
const uint32_t rtcCalibValue = 0x0101; | ||
GPIO_REG_WRITE(GPIO_RTC_CALIB_SYNC_ADDRESS, rtcCalibValue); | ||
GPIO_REG_WRITE(GPIO_RTC_CALIB_SYNC_ADDRESS, rtcCalibValue | RTC_CALIB_START); | ||
ets_delay_us(10); | ||
|
||
do { | ||
value = GPIO_REG_READ(GPIO_RTC_CALIB_VALUE_ADDRESS); | ||
} while((value & RTC_CALIB_RDY) == 0); | ||
value &= RTC_CALIB_VALUE; | ||
|
||
uint32_t xtal_freq; | ||
switch(chip6_phy_init_ctrl) { | ||
case 0: | ||
case 1: | ||
xtal_freq = 26; | ||
break; | ||
case 2: | ||
xtal_freq = 24; | ||
break; | ||
default: | ||
xtal_freq = 40; | ||
break; | ||
} | ||
|
||
value = value * 16 / xtal_freq; | ||
if(value < 512) { | ||
return value; | ||
} | ||
|
||
if(calibration_value == 0) { | ||
calibration_value = value; | ||
return value; | ||
} | ||
|
||
calibration_value = ((calibration_value * 3) + (value * 5)) / 8; | ||
return calibration_value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
uint32_t os_random(); | ||
|
||
int os_get_random(unsigned char* buf, size_t len) | ||
{ | ||
uint32_t rnd = 0; | ||
for(size_t i = 0; i < len; ++i) { | ||
if(rnd == 0) { | ||
rnd = os_random(); | ||
} | ||
*buf++ = rnd & 0xff; | ||
rnd >>= 8; | ||
} | ||
|
||
return len; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters