CC35xxDriverLibrary
systick.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Filename: systick.h
3  *
4  * Description: Prototypes for the SysTick driver.
5  *
6  * Copyright (c) 2024 Texas Instruments Incorporated
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1) Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * 2) Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3) Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ******************************************************************************/
35 
36 #ifndef __SYSTICK_H__
37 #define __SYSTICK_H__
38 
39 //*****************************************************************************
40 //
45 //
46 //*****************************************************************************
47 
48 //*****************************************************************************
49 //
50 // If building with a C++ compiler, make all of the definitions in this header
51 // have a C binding.
52 //
53 //*****************************************************************************
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 #include <stdbool.h>
59 #include <stdint.h>
60 #include "../inc/hw_types.h"
61 #include "../inc/hw_ints.h"
62 #include "../cmsis/cc35xx.h"
63 #include "../cmsis/core/core_cm33.h"
64 #include "debug.h"
65 #include "interrupt.h"
66 
67 //*****************************************************************************
68 //
69 // API Functions and Prototypes
70 //
71 //*****************************************************************************
72 
73 //*****************************************************************************
74 //
89 //
90 //*****************************************************************************
92 {
93  // Enable SysTick.
95 }
96 
97 //*****************************************************************************
98 //
105 //
106 //*****************************************************************************
108 {
109  // Disable SysTick.
110  SysTick->CTRL &= ~(SysTick_CTRL_ENABLE_Msk);
111 }
112 
113 //*****************************************************************************
114 //
125 //
126 //*****************************************************************************
128 {
129  // Enable the SysTick interrupt.
131 }
132 
133 //*****************************************************************************
134 //
141 //
142 //*****************************************************************************
144 {
145  // Disable the SysTick interrupt.
146  SysTick->CTRL &= ~(SysTick_CTRL_TICKINT_Msk);
147 }
148 
149 //*****************************************************************************
150 //
168 //
169 //*****************************************************************************
170 __STATIC_INLINE void SysTickRegisterInt(void (*pfnHandler)(void))
171 {
172  // Register the interrupt handler, returning an error if an error occurs.
173  IntRegister(INT_SYSTICK, pfnHandler);
174 
175  // Enable the SysTick interrupt.
177 }
178 
179 //*****************************************************************************
180 //
190 //
191 //*****************************************************************************
193 {
194  // Disable the SysTick interrupt.
196 
197  // Unregister the interrupt handler.
199 }
200 
201 //*****************************************************************************
202 //
218 //
219 //*****************************************************************************
220 __STATIC_INLINE void SysTickSetPeriod(uint32_t period)
221 {
222  // Check the arguments.
223  ASSERT((period > 0) && (period <= 16777216));
224 
225  // Set the period of the SysTick counter.
226  SysTick->LOAD = period - 1;
227 }
228 
229 //*****************************************************************************
230 //
237 //
238 //*****************************************************************************
240 {
241  // Return the period of the SysTick counter.
242  return (SysTick->LOAD + 1);
243 }
244 
245 //*****************************************************************************
246 //
253 //
254 //*****************************************************************************
256 {
257  // Return the current value of the SysTick counter.
258  return (SysTick->VAL);
259 }
260 
261 //*****************************************************************************
262 //
263 // Mark the end of the C bindings section for C++ compilers.
264 //
265 //*****************************************************************************
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 //*****************************************************************************
271 //
275 //
276 //*****************************************************************************
277 
278 #endif // __SYSTICK_H__
__STATIC_INLINE uint32_t SysTickGetPeriod(void)
Gets the period of the SysTick counter.
Definition: systick.h:239
__STATIC_INLINE void SysTickDisableInt(void)
Disables the SysTick interrupt.
Definition: systick.h:143
#define __STATIC_INLINE
Definition: hw_types.h:57
#define SysTick
Definition: core_armv81mml.h:3105
__STATIC_INLINE void SysTickUnregisterInt(void)
Unregisters the interrupt handler for the SysTick interrupt in the dynamic interrupt table...
Definition: systick.h:192
__STATIC_INLINE void SysTickDisable(void)
Disables the SysTick counter.
Definition: systick.h:107
__STATIC_INLINE void SysTickEnableInt(void)
Enables the SysTick interrupt.
Definition: systick.h:127
#define INT_SYSTICK
Definition: hw_ints.h:50
#define ASSERT(expr)
Definition: debug.h:81
__STATIC_INLINE uint32_t SysTickGetValue(void)
Gets the current value of the SysTick counter.
Definition: systick.h:255
__STATIC_INLINE void SysTickEnable(void)
Enables the SysTick counter.
Definition: systick.h:91
void IntUnregister(uint32_t intNum)
Unregisters an interrupt handler in the dynamic vector table.
Definition: interrupt.c:142
void IntRegister(uint32_t intNum, void(*handler)(void))
Global pointer to the (dynamic) interrupt vector table when placed in CRAM.
Definition: interrupt.c:107
__STATIC_INLINE void SysTickSetPeriod(uint32_t period)
Sets the period of the SysTick counter.
Definition: systick.h:220
#define SysTick_CTRL_CLKSOURCE_Msk
Definition: core_armv81mml.h:1036
#define SysTick_CTRL_ENABLE_Msk
Definition: core_armv81mml.h:1042
__STATIC_INLINE void SysTickRegisterInt(void(*pfnHandler)(void))
Registers an interrupt handler for the SysTick interrupt in the dynamic interrupt table...
Definition: systick.h:170
#define SysTick_CTRL_TICKINT_Msk
Definition: core_armv81mml.h:1039