-
Notifications
You must be signed in to change notification settings - Fork 0
/
coretime.h
132 lines (112 loc) · 5.29 KB
/
coretime.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
////////////////////////////////////////////////////////////////////////////////
/// @file
/// @brief Core Time Management.
////////////////////////////////////////////////////////////////////////////////
#ifndef CORETIME_H_
#define CORETIME_H_
// *****************************************************************************
// ************************** System Include Files *****************************
// *****************************************************************************
#include <xc.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// *****************************************************************************
// ************************** User Include Files *******************************
// *****************************************************************************
// *****************************************************************************
// ************************** Macros *******************************************
// *****************************************************************************
#define CORETIME_TICKS_PER_SECOND 40000000UL
// *****************************************************************************
// ************************** Defines ******************************************
// *****************************************************************************
// *****************************************************************************
// ************************** Declarations *************************************
// *****************************************************************************
// *****************************************************************************
// ************************** Function Prototypes ******************************
// *****************************************************************************
////////////////////////////////////////////////////////////////////////////////
/// @brief Get number of processor ticks.
///
/// @return Number of processor ticks since reset.
///
/// Returns the number of unitless 64-bit core timer tick counts.
////////////////////////////////////////////////////////////////////////////////
uint64_t CoreTimeTicksGet();
////////////////////////////////////////////////////////////////////////////////
/// @brief Get number of seconds.
///
/// @return Number of seconds since reset.
///
/// Returns the number of seconds (64-bit rollover).
////////////////////////////////////////////////////////////////////////////////
uint64_t CoreTime64sGet();
////////////////////////////////////////////////////////////////////////////////
/// @brief Get number of milliseconds.
///
/// @return Number of milliseconds since reset.
///
/// Returns the number of milliseconds (64-bit rollover).
////////////////////////////////////////////////////////////////////////////////
uint64_t CoreTime64msGet();
////////////////////////////////////////////////////////////////////////////////
/// @brief Get number of microseconds.
///
/// @return Number of microseconds since reset.
///
/// Returns the number of microseconds (64-bit rollover).
////////////////////////////////////////////////////////////////////////////////
uint64_t CoreTime64usGet();
////////////////////////////////////////////////////////////////////////////////
/// @brief Get number of seconds.
///
/// @return Number of seconds since reset.
///
/// Returns the number of seconds (32-bit rollover).
////////////////////////////////////////////////////////////////////////////////
uint32_t CoreTime32sGet();
////////////////////////////////////////////////////////////////////////////////
/// @brief Get number of milliseconds.
///
/// @return Number of milliseconds since reset.
///
/// Returns the number of milliseconds (32-bit rollover).
////////////////////////////////////////////////////////////////////////////////
uint32_t CoreTime32msGet();
////////////////////////////////////////////////////////////////////////////////
/// @brief Get number of microseconds.
///
/// @return Number of microseconds since reset.
///
/// Returns the number of microseconds (32-bit rollover).
////////////////////////////////////////////////////////////////////////////////
uint32_t CoreTime32usGet();
////////////////////////////////////////////////////////////////////////////////
/// @brief Delay a number of microseconds.
///
/// @param us
/// Number of microseconds to delay.
///
/// @note The exact time elapsed will be between 0-1us less that the value
/// supplied. Therefore, if \p us is '5', the total delay time will
/// be in the range 4-5us.
///
/// This function used the supplied \p us to delay software processing.
////////////////////////////////////////////////////////////////////////////////
void CoreTimeDelayUs(uint32_t us);
////////////////////////////////////////////////////////////////////////////////
/// @brief Delay a number of milliseconds.
///
/// @param ms
/// Number of milliseconds to delay.
///
/// @note The exact time elapsed will be between 0-1ms less that the value
/// supplied. Therefore, if \p ms is '5', the total delay time will
/// be in the range 4-5ms.
///
/// This function used the supplied \p us to delay software processing.
////////////////////////////////////////////////////////////////////////////////
void CoreTimeDelayMs(uint32_t ms);
#endif // CORETIME_H_