Commit Graph

16 Commits

Author SHA1 Message Date
Philip Gladstone 995114b736
Add support to set the clock rate and have sntp use it. (#3236) 2020-08-08 13:32:14 +02:00
Johny Mattsson f7a545b951
Evict c_types.h, tidy up a other c_prefixes. (#2841) 2019-07-23 14:22:38 +10:00
sergio d77666c0e8 trailing spaces cleanup (#2659) 2019-02-17 18:26:29 +00:00
dnc40085 96e5c026a8 Refactor timer suspend portion of node.sleep (pmsleep) (#2287)
* pmsleep refactor
* Shortened swtmr disabled message 
* Added swtimer debug module option to user_modules.h.
* Added comments to user_config.h.
* Fixed error in documentation for node.sleep()
* remove blank sntp.c that got added in during rebase onto dev(6218b92)
* Added #ifdefs around SWTIMER_REG_CB to prevent inclusion of disabled
code
2018-04-13 21:41:14 +02:00
Philip Gladstone 97e34ce520 Fix a number of issues with the gpio.pulse family of functions (#2260)
* Fix some subtle timing issues with gpio.pulse
* Add the pulse:update method
* Allow getstate to work on stopped pulsers
* Make gpio.mode(, gpio.OUTPUT) actually set the output mode
* Added some more documentation
2018-02-23 23:12:23 +01:00
Philip Gladstone 5ece2fda20 Another dsleep fix (or rather a not-deep-sleep case) (#2155)
* Make the rtc variables not be cleared by the .bss initialization
* Move the save to the right place
* Make sure that we reset the rtctime to 0 if we didn't sleep properly.
* Setting the seconds to zero doesn't update the dsleep calibration
2017-11-03 17:50:10 +01:00
Philip Gladstone 1a6e83d088 Fixes problems with time not preserved through dsleep (#2148)
* Make the rtc variables not be cleared by the .bss initialization
* Move the save to the right place
2017-10-28 22:16:09 +02:00
Philip Gladstone d93465cd86 Add tracking and control of the rate error in the clock crystal. (#1697)
* Improve RTC timekeeping -- includes clock rate tracking
* Improved division by 1M
* Fix crash in sntp
* Disable RTC debug
* Get the offset correct
* Add comments on where the mysterious numbers came from
* Fix a crash with auto repeat mode and errors on repeat
2017-07-18 22:51:20 +02:00
Johny Mattsson c5c0143b2f rtctime.dsleep() current draw improvements (#1659)
* Switch off interrupts before rtctime dsleep.

* Deal with the fact that MCU keeps running after being told to enter deep sleep
(It can keep running for quite a few instructions at times (and none at
all at others), and it appears that trying to cache additional code from
SPI flash while trying to go to sleep fails miserably at both....)

* Ensure flash is not active when going into deep sleep.
2016-12-14 12:39:31 +01:00
Arnim Läuger 56839fb20b Add rtctime.epoch2cal() (#1386) 2016-07-19 22:01:26 +02:00
Johny Mattsson 182d45f928 Enable -std=gnu11 for modules dir.
Plus boat-load of fixes to actually make that build.
2016-01-20 19:40:47 +11:00
Johny Mattsson cc220d9201 Moved TEXT_SECTION_ATTR macro to its own header. 2015-10-12 13:26:04 +11:00
Johny Mattsson dd38a0a0e6 Imported reworked rtctime support. 2015-07-10 16:16:25 +10:00
Johny Mattsson 67e72c45df Imported RTC FIFO component + added Lua interface.
The rtcfifo module uses RTC memory to store sensor samples across deep-sleeps,
making it possible to batch up samples for less frequent uploads. This
component uses 9 RTC memory slots for control, and a variable number of
slots for sample storage (see rtcfifo.prepare() on how to control the
size/location of the latter).

When used together with the rtctime module, it also exposes the convenience
function rtcfifo.dsleep_until_sample() which can be used to easily take
readings on a regular basis without having to manually take into account
time spent awake to get an accurate sleep time.

The format used for storing samples is quite dense, and allows for 16 bits
of data in a fixed point format (per sample).
2015-07-10 15:12:31 +10:00
Johny Mattsson 2187424928 Imported RTC+sleep timekeeping from an internal DiUS project.
Added Lua module rtctime to interface with it.

This keeps as accurate time as is possible on the ESP8266, including across
deep sleeps (provided rtctime.dsleep() is used rather than node.dsleep()).
Intended to be used together with NTP for high accuracy time keeping. The
API is via rtctime.{get,set}timeofday(), working from Unix epoch.

Note that 160MHz CPU clock is not currently supported by the rtctime code,
as it is only aware of the 52MHz boot clock and the regular 80Mhz default
clock.

See rtctime.h for detailed info on how this all works.
2015-07-10 15:12:31 +10:00
Johny Mattsson 1a613effeb Imported RTC access from a DiUS internal project.
Added Lua access module named "rtcmem" for read/write of RTC user module.
2015-07-10 15:10:15 +10:00