forked from Grapsus/cc254x_sdcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.h
55 lines (47 loc) · 1.93 KB
/
time.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*! \file time.h
* This module helps you keep track of time in milliseconds.
* Calling timeInit() sets up a timer (Timer 4) to overflow every millisecond
* (approximately).
* You can read the time at any time by calling getMs().
* For the interrupt to work, you must write
* <pre>include <time.h></pre>
* or
* <pre>include <wixel.h></pre>
* in the source file that contains your main() function.
* Also, you must call boardClockInit() or else the timing will
* be wrong.
*
* Both boardClockInit() and timeInit() are called from systemInit(), so you
* can simply call systemInit() to initialize everything.
*/
#ifndef _WIXEL_TIME_H
#define _WIXEL_TIME_H
#include "cc254x_map.h"
#include "cc254x_types.h"
/*! Initializes the library. This sets up Timer 4 to tick (approximately)
* every millisecond and enables the Timer 4 interrupt. Note that you
* will also have to call boardClockInit() or systemInit(), to get the system clock running
* at the right speed, otherwise the millisecond timing will be off by a
* large factor.
*
* This function is called by systemInit(). */
void timeInit();
/*! Returns the number of milliseconds that have elapsed since timeInit()
* was called. */
uint32 getMs();
/*! This interrupt fires once per millisecond (approximately) and
* increments timeMs. */
ISR(T4, 0);
/*! \param microseconds The number of microseconds delay; any value between 0 and 255.
*
* This function delays for the specified number of microseconds using
* a simple loop. If an interrupt occurs during this function, the delay
* will be longer than specified. */
void delay_us(uint8 microseconds);
/*! \param milliseconds The number of milliseconds delay; any value between 0 and 65535.
*
* This function delays for the specified number of milliseconds using
* a simple loop. If an interrupt occurs during this function, the delay
* will be slightly longer than specified. */
void delayMs(uint16 milliseconds);
#endif