SimpleFOClibrary
2.1
time_utils.cpp
Go to the documentation of this file.
1
#include "
time_utils.h
"
2
3
// function buffering delay()
4
// arduino uno function doesn't work well with interrupts
5
void
_delay
(
unsigned
long
ms){
6
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328PB__) || defined(__AVR_ATmega2560__)
7
// if arduino uno and other atmega328p chips
8
// use while instad of delay,
9
// due to wrong measurement based on changed timer0
10
unsigned
long
t =
_micros
() + ms*1000;
11
while
(
_micros
() < t ){};
12
#else
13
// regular micros
14
delay(ms);
15
#endif
16
}
17
18
19
// function buffering _micros()
20
// arduino function doesn't work well with interrupts
21
unsigned
long
_micros
(){
22
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328PB__) || defined(__AVR_ATmega2560__)
23
// if arduino uno and other atmega328p chips
24
//return the value based on the prescaler
25
if
((TCCR0B & 0b00000111) == 0x01)
return
(micros()/32);
26
else
return
(micros());
27
#else
28
// regular micros
29
return
micros();
30
#endif
31
}
_delay
void _delay(unsigned long ms)
Definition:
time_utils.cpp:5
time_utils.h
_micros
unsigned long _micros()
Definition:
time_utils.cpp:21
Arduino
libraries
Arduino-FOC
src
common
time_utils.cpp
Generated by
1.8.18