SimpleFOClibrary
2.1
Main Page
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
y
z
~
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
u
~
Variables
a
b
c
d
e
f
g
h
i
l
m
o
p
q
s
t
u
v
w
y
z
Files
File List
File Members
All
_
a
c
d
e
f
i
m
n
o
p
q
s
t
u
v
Functions
_
p
Variables
Typedefs
Enumerations
Enumerator
Macros
_
c
d
n
s
•
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
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