mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Wiring time functions
This commit is contained in:
parent
5fccef713c
commit
168156d210
@ -23,46 +23,33 @@
|
||||
*/
|
||||
|
||||
#include "wiring_private.h"
|
||||
|
||||
// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
|
||||
// the overflow handler is called every 256 ticks.
|
||||
#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
|
||||
|
||||
// the whole number of milliseconds per timer0 overflow
|
||||
#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)
|
||||
|
||||
// the fractional number of milliseconds per timer0 overflow. we shift right
|
||||
// by three to fit these numbers into a byte. (for the clock speeds we care
|
||||
// about - 8 and 16 MHz - this doesn't lose precision.)
|
||||
#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
|
||||
#define FRACT_MAX (1000 >> 3)
|
||||
|
||||
volatile unsigned long timer0_overflow_count = 0;
|
||||
volatile unsigned long timer0_millis = 0;
|
||||
static unsigned char timer0_fract = 0;
|
||||
|
||||
#include "ets_sys.h"
|
||||
#include "osapi.h"
|
||||
#include "user_interface.h"
|
||||
|
||||
unsigned long millis()
|
||||
{
|
||||
unsigned long m = 0;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
unsigned long micros() {
|
||||
unsigned long m = 0;
|
||||
|
||||
unsigned long m = system_get_time() / 1000;
|
||||
return m;
|
||||
}
|
||||
|
||||
void delay(unsigned long ms)
|
||||
{
|
||||
os_delay_us(1000*ms);
|
||||
}
|
||||
|
||||
unsigned long micros()
|
||||
{
|
||||
unsigned long m = system_get_time();
|
||||
return m;
|
||||
}
|
||||
|
||||
void delayMicroseconds(unsigned int us)
|
||||
{
|
||||
os_delay_us(us);
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
system_timer_reinit();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user