esp8266,esp32: Implement high-res timers using new tick_hz argument.

machine.Timer now takes a new argument in its constructor (or init method):
tick_hz which specified the units for the period argument.  The period of
the timer in seconds is: period/tick_hz.

For backwards compatibility tick_hz defaults to 1000.  If the user wants to
specify the period (numerator) in microseconds then tick_hz can be set to
1000000.  The user can also specify a period of an arbitrary number of
cycles of an arbitrary frequency using these two arguments.

An additional freq argument has been added to allow frequencies to be
specified directly in Hertz.  This supports floating point values when
available.
This commit is contained in:
Nicko van Someren
2018-06-26 15:03:51 -06:00
committed by Damien George
parent a3ba5f127e
commit c3c914f4dd
3 changed files with 90 additions and 11 deletions

View File

@@ -33,6 +33,10 @@
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/gc.h"
// This needs to be defined before any ESP SDK headers are included
#define USE_US_TIMER 1
#include "extmod/misc.h"
#include "lib/mp-readline/readline.h"
#include "lib/utils/pyexec.h"
@@ -126,6 +130,7 @@ soft_reset:
}
void user_init(void) {
system_timer_reinit();
system_init_done_cb(init_done);
}