EE445M RTOS
Taken at the University of Texas Spring 2015
systick.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // systick.c - Driver for the SysTick timer in NVIC.
4 //
5 // Copyright (c) 2005-2014 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the
18 // distribution.
19 //
20 // Neither the name of Texas Instruments Incorporated nor the names of
21 // its contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 //*****************************************************************************
41 //
44 //
45 //*****************************************************************************
46 
47 #include <stdbool.h>
48 #include <stdint.h>
49 #include "inc/hw_ints.h"
50 #include "inc/hw_nvic.h"
51 #include "inc/hw_types.h"
52 #include "driverlib/debug.h"
53 #include "driverlib/interrupt.h"
54 #include "driverlib/systick.h"
55 
56 //*****************************************************************************
57 //
72 //
73 //*****************************************************************************
74 void
76 {
77  //
78  // Enable SysTick.
79  //
81 }
82 
83 //*****************************************************************************
84 //
91 //
92 //*****************************************************************************
93 void
95 {
96  //
97  // Disable SysTick.
98  //
100 }
101 
102 //*****************************************************************************
103 //
116 //
117 //*****************************************************************************
118 void
119 SysTickIntRegister(void (*pfnHandler)(void))
120 {
121  //
122  // Register the interrupt handler, returning an error if an error occurs.
123  //
124  IntRegister(FAULT_SYSTICK, pfnHandler);
125 
126  //
127  // Enable the SysTick interrupt.
128  //
130 }
131 
132 //*****************************************************************************
133 //
143 //
144 //*****************************************************************************
145 void
147 {
148  //
149  // Disable the SysTick interrupt.
150  //
152 
153  //
154  // Unregister the interrupt handler.
155  //
157 }
158 
159 //*****************************************************************************
160 //
171 //
172 //*****************************************************************************
173 void
175 {
176  //
177  // Enable the SysTick interrupt.
178  //
180 }
181 
182 //*****************************************************************************
183 //
190 //
191 //*****************************************************************************
192 void
194 {
195  //
196  // Disable the SysTick interrupt.
197  //
199 }
200 
201 //*****************************************************************************
202 //
218 //
219 //*****************************************************************************
220 void
221 SysTickPeriodSet(uint32_t ui32Period)
222 {
223  //
224  // Check the arguments.
225  //
226  ASSERT((ui32Period > 0) && (ui32Period <= 16777216));
227 
228  //
229  // Set the period of the SysTick counter.
230  //
231  HWREG(NVIC_ST_RELOAD) = ui32Period - 1;
232 }
233 
234 //*****************************************************************************
235 //
242 //
243 //*****************************************************************************
244 uint32_t
246 {
247  //
248  // Return the period of the SysTick counter.
249  //
250  return(HWREG(NVIC_ST_RELOAD) + 1);
251 }
252 
253 //*****************************************************************************
254 //
261 //
262 //*****************************************************************************
263 uint32_t
265 {
266  //
267  // Return the current value of the SysTick counter.
268  //
269  return(HWREG(NVIC_ST_CURRENT));
270 }
271 
272 //*****************************************************************************
273 //
274 // Close the Doxygen group.
276 //
277 //*****************************************************************************
void SysTickDisable(void)
Definition: systick.c:94
#define HWREG(x)
Definition: hw_types.h:48
#define FAULT_SYSTICK
Definition: hw_ints.h:57
#define NVIC_ST_CTRL
Definition: hw_nvic.h:49
#define ASSERT(expr)
Definition: debug.h:67
void SysTickIntRegister(void(*pfnHandler)(void))
Definition: systick.c:119
#define NVIC_ST_CURRENT
Definition: hw_nvic.h:52
uint32_t SysTickPeriodGet(void)
Definition: systick.c:245
#define NVIC_ST_RELOAD
Definition: hw_nvic.h:51
uint32_t SysTickValueGet(void)
Definition: systick.c:264
#define NVIC_ST_CTRL_INTEN
Definition: hw_nvic.h:174
#define NVIC_ST_CTRL_CLK_SRC
Definition: hw_nvic.h:173
#define NVIC_ST_CTRL_ENABLE
Definition: hw_nvic.h:175
void SysTickIntEnable(void)
Definition: systick.c:174
void IntUnregister(uint32_t ui32Interrupt)
Definition: interrupt.c:381
void SysTickEnable(void)
Definition: systick.c:75
void SysTickIntUnregister(void)
Definition: systick.c:146
void SysTickIntDisable(void)
Definition: systick.c:193
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Definition: interrupt.c:309
void SysTickPeriodSet(uint32_t ui32Period)
Definition: systick.c:221