AVRTools
A Library for the AVR ATmega328 and ATmega2560 Microcontrollers
Loading...
Searching...
No Matches
SystemClock.h
Go to the documentation of this file.
1/*
2 SystemClock.h - Functions to initialize and use a system clock
3 on AVR chips that is compatible with Arduino.
4 For AVR ATMega328p (Arduino Uno) and ATMega2560 (Arduino Mega).
5 This is part of the AVRTools library.
6 Copyright (c) 2014 Igor Mikolic-Torreira. All right reserved.
7 Functions delayMicroseconds() and delayMilliseconds() adapted from Arduino code that
8 is Copyright (c) 2005-2006 David A. Mellis and licensed under LGPL.
9
10 This program is free software: you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24
25
42#ifndef SystemClock_h
43#define SystemClock_h
44
45
46
47
48#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
49#define clockCyclesToMicroseconds( a ) ( (a) / clockCyclesPerMicrosecond() )
50#define microsecondsToClockCycles( a ) ( (a) * clockCyclesPerMicrosecond() )
51
52
65void initSystemClock();
66
67
77void delayMicroseconds( unsigned int us );
78
79
87void delayMilliseconds( unsigned long ms );
88
89
100inline void delay( unsigned long ms )
101{ delayMilliseconds( ms ); }
102
103
113unsigned long micros();
114
115
123unsigned long millis();
124
125
126
127#endif
void delayMicroseconds(unsigned int us)
Delay a certain number of microseconds.
Definition SystemClock.cpp:142
void delay(unsigned long ms)
Delay a certain number of milliseconds.
Definition SystemClock.h:100
unsigned long millis()
Return the number of elasped milliseconds since the system clock was turned on.
Definition SystemClock.cpp:84
void delayMilliseconds(unsigned long ms)
Delay a certain number of milliseconds.
Definition SystemClock.cpp:124
void initSystemClock()
This function initializes a system clock that tracks elapsed milliseconds.
Definition SystemClock.cpp:260
unsigned long micros()
Return the number of elasped microseconds since the system clock was turned on.
Definition SystemClock.cpp:101