CC26xx Driver Library |

- Main Page
- Related Pages
- CC26xx APIs
- Register Descriptions
- Online Resources

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
systick.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: systick.h
3 * Revised: 2015-01-14 12:12:44 +0100 (on, 14 jan 2015)
4 * Revision: 42373
5 *
6 * Description: Prototypes for the SysTick driver.
7 *
8 * Copyright (c) 2015, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38
39 //*****************************************************************************
40 //
43 //
44 //*****************************************************************************
45
46 #ifndef __SYSTICK_H__
47 #define __SYSTICK_H__
48
49 //*****************************************************************************
50 //
51 // If building with a C++ compiler, make all of the definitions in this header
52 // have a C binding.
53 //
54 //*****************************************************************************
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59
60 #include <stdbool.h>
61 #include <stdint.h>
62 #include <inc/hw_ints.h>
63 #include <inc/hw_nvic.h>
64 #include <inc/hw_types.h>
65 #include <driverlib/debug.h>
66 #include <driverlib/interrupt.h>
67
68 //*****************************************************************************
69 //
70 // API Functions and Prototypes
71 //
72 //*****************************************************************************
73
74 //*****************************************************************************
75 //
90 //
91 //*****************************************************************************
92 __STATIC_INLINE void
93 SysTickEnable(void)
94 {
95 //
96 // Enable SysTick.
97 //
98 HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_CLK_SRC | NVIC_ST_CTRL_ENABLE;
99 }
100
101 //*****************************************************************************
102 //
109 //
110 //*****************************************************************************
111 __STATIC_INLINE void
112 SysTickDisable(void)
113 {
114 //
115 // Disable SysTick.
116 //
117 HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_ENABLE);
118 }
119
120 //*****************************************************************************
121 //
133 //
134 //*****************************************************************************
135 __STATIC_INLINE void
136 SysTickIntRegister(void (*pfnHandler)(void))
137 {
138 //
139 // Register the interrupt handler, returning an error if an error occurs.
140 //
141 IntRegister(FAULT_SYSTICK, pfnHandler);
142
143 //
144 // Enable the SysTick interrupt.
145 //
146 HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
147 }
148
149 //*****************************************************************************
150 //
160 //
161 //*****************************************************************************
162 __STATIC_INLINE void
163 SysTickIntUnregister(void)
164 {
165 //
166 // Disable the SysTick interrupt.
167 //
168 HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
169
170 //
171 // Unregister the interrupt handler.
172 //
173 IntUnregister(FAULT_SYSTICK);
174 }
175
176 //*****************************************************************************
177 //
188 //
189 //*****************************************************************************
190 __STATIC_INLINE void
191 SysTickIntEnable(void)
192 {
193 //
194 // Enable the SysTick interrupt.
195 //
196 HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
197 }
198
199 //*****************************************************************************
200 //
207 //
208 //*****************************************************************************
209 __STATIC_INLINE void
210 SysTickIntDisable(void)
211 {
212 //
213 // Disable the SysTick interrupt.
214 //
215 HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
216 }
217
218 //*****************************************************************************
219 //
235 //
236 //*****************************************************************************
237 __STATIC_INLINE void
238 SysTickPeriodSet(uint32_t ui32Period)
239 {
240 //
241 // Check the arguments.
242 //
243 ASSERT((ui32Period > 0) && (ui32Period <= 16777216));
244
245 //
246 // Set the period of the SysTick counter.
247 //
248 HWREG(NVIC_ST_RELOAD) = ui32Period - 1;
249 }
250
251 //*****************************************************************************
252 //
259 //
260 //*****************************************************************************
261 __STATIC_INLINE uint32_t
262 SysTickPeriodGet(void)
263 {
264 //
265 // Return the period of the SysTick counter.
266 //
267 return(HWREG(NVIC_ST_RELOAD) + 1);
268 }
269
270 //*****************************************************************************
271 //
278 //
279 //*****************************************************************************
280 __STATIC_INLINE uint32_t
281 SysTickValueGet(void)
282 {
283 //
284 // Return the current value of the SysTick counter.
285 //
286 return(HWREG(NVIC_ST_CURRENT));
287 }
288
289 //*****************************************************************************
290 //
291 // Mark the end of the C bindings section for C++ compilers.
292 //
293 //*****************************************************************************
294 #ifdef __cplusplus
295 }
296 #endif
297
298 #endif // __SYSTICK_H__
299
300 //*****************************************************************************
301 //
304 //
305 //*****************************************************************************
debug.h
ASSERT
#define ASSERT(expr)
Definition: debug.h:65
SysTickDisable
__STATIC_INLINE void SysTickDisable(void)
Disables the SysTick counter.
Definition: systick.h:112
SysTickIntUnregister
__STATIC_INLINE void SysTickIntUnregister(void)
Unregisters the interrupt handler for the SysTick interrupt.
Definition: systick.h:163
SysTickValueGet
__STATIC_INLINE uint32_t SysTickValueGet(void)
Gets the current value of the SysTick counter.
Definition: systick.h:281
SysTickPeriodGet
__STATIC_INLINE uint32_t SysTickPeriodGet(void)
Gets the period of the SysTick counter.
Definition: systick.h:262
SysTickPeriodSet
__STATIC_INLINE void SysTickPeriodSet(uint32_t ui32Period)
Sets the period of the SysTick counter.
Definition: systick.h:238
SysTickIntDisable
__STATIC_INLINE void SysTickIntDisable(void)
Disables the SysTick interrupt.
Definition: systick.h:210
SysTickEnable
__STATIC_INLINE void SysTickEnable(void)
Enables the SysTick counter.
Definition: systick.h:93
interrupt.h
IntUnregister
void IntUnregister(uint32_t ui32Interrupt)
Unregisters the function to be called when an interrupt occurs.
Definition: interrupt.c:205
SysTickIntRegister
__STATIC_INLINE void SysTickIntRegister(void(*pfnHandler)(void))
Registers an interrupt handler for the SysTick interrupt.
Definition: systick.h:136
SysTickIntEnable
__STATIC_INLINE void SysTickIntEnable(void)
Enables the SysTick interrupt.
Definition: systick.h:191
IntRegister
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Registers a function to be called when an interrupt occurs.
Definition: interrupt.c:157