OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_LM3S811_IAR/] [LuminaryCode/] [systick.c] - Blame information for rev 728

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 581 jeremybenn
//*****************************************************************************
2
//
3
// systick.c - Driver for the SysTick timer in NVIC.
4
//
5
// Copyright (c) 2005,2006 Luminary Micro, Inc.  All rights reserved.
6
//
7
// Software License Agreement
8
//
9
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
10
// exclusively on LMI's Stellaris Family of microcontroller products.
11
//
12
// The software is owned by LMI and/or its suppliers, and is protected under
13
// applicable copyright laws.  All rights are reserved.  Any use in violation
14
// of the foregoing restrictions may subject the user to criminal sanctions
15
// under applicable laws, as well as to civil liability for the breach of the
16
// terms and conditions of this license.
17
//
18
// THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
22
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23
//
24
// This is part of revision 991 of the Stellaris Driver Library.
25
//
26
//*****************************************************************************
27
 
28
//*****************************************************************************
29
//
30
//! \addtogroup systick_api
31
//! @{
32
//
33
//*****************************************************************************
34
 
35
#include "../hw_ints.h"
36
#include "../hw_nvic.h"
37
#include "../hw_types.h"
38
#include "debug.h"
39
#include "interrupt.h"
40
#include "systick.h"
41
 
42
//*****************************************************************************
43
//
44
//! Enables the SysTick counter.
45
//!
46
//! This will start the SysTick counter.  If an interrupt handler has been
47
//! registered, it will be called when the SysTick counter rolls over.
48
//!
49
//! \return None.
50
//
51
//*****************************************************************************
52
#if defined(GROUP_enable) || defined(BUILD_ALL) || defined(DOXYGEN)
53
void
54
SysTickEnable(void)
55
{
56
    //
57
    // Enable SysTick.
58
    //
59
    HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_CLK_SRC | NVIC_ST_CTRL_ENABLE;
60
}
61
#endif
62
 
63
//*****************************************************************************
64
//
65
//! Disables the SysTick counter.
66
//!
67
//! This will stop the SysTick counter.  If an interrupt handler has been
68
//! registered, it will no longer be called until SysTick is restarted.
69
//!
70
//! \return None.
71
//
72
//*****************************************************************************
73
#if defined(GROUP_disable) || defined(BUILD_ALL) || defined(DOXYGEN)
74
void
75
SysTickDisable(void)
76
{
77
    //
78
    // Disable SysTick.
79
    //
80
    HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_ENABLE);
81
}
82
#endif
83
 
84
//*****************************************************************************
85
//
86
//! Registers an interrupt handler for the SysTick interrupt.
87
//!
88
//! \param pfnHandler is a pointer to the function to be called when the
89
//! SysTick interrupt occurs.
90
//!
91
//! This sets the handler to be called when a SysTick interrupt occurs.
92
//!
93
//! \sa IntRegister() for important information about registering interrupt
94
//! handlers.
95
//!
96
//! \return None.
97
//
98
//*****************************************************************************
99
#if defined(GROUP_intregister) || defined(BUILD_ALL) || defined(DOXYGEN)
100
void
101
SysTickIntRegister(void (*pfnHandler)(void))
102
{
103
    //
104
    // Register the interrupt handler, returning an error if an error occurs.
105
    //
106
    IntRegister(FAULT_SYSTICK, pfnHandler);
107
 
108
    //
109
    // Enable the SysTick interrupt.
110
    //
111
    HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
112
}
113
#endif
114
 
115
//*****************************************************************************
116
//
117
//! Unregisters the interrupt handler for the SysTick interrupt.
118
//!
119
//! This function will clear the handler to be called when a SysTick interrupt
120
//! occurs.
121
//!
122
//! \sa IntRegister() for important information about registering interrupt
123
//! handlers.
124
//!
125
//! \return None.
126
//
127
//*****************************************************************************
128
#if defined(GROUP_intunregister) || defined(BUILD_ALL) || defined(DOXYGEN)
129
void
130
SysTickIntUnregister(void)
131
{
132
    //
133
    // Disable the SysTick interrupt.
134
    //
135
    HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
136
 
137
    //
138
    // Unregister the interrupt handler.
139
    //
140
    IntUnregister(FAULT_SYSTICK);
141
}
142
#endif
143
 
144
//*****************************************************************************
145
//
146
//! Enables the SysTick interrupt.
147
//!
148
//! This function will enable the SysTick interrupt, allowing it to be
149
//! reflected to the processor.
150
//!
151
//! \return None.
152
//
153
//*****************************************************************************
154
#if defined(GROUP_intenable) || defined(BUILD_ALL) || defined(DOXYGEN)
155
void
156
SysTickIntEnable(void)
157
{
158
    //
159
    // Enable the SysTick interrupt.
160
    //
161
    HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
162
}
163
#endif
164
 
165
//*****************************************************************************
166
//
167
//! Disables the SysTick interrupt.
168
//!
169
//! This function will disable the SysTick interrupt, preventing it from being
170
//! reflected to the processor.
171
//!
172
//! \return None.
173
//
174
//*****************************************************************************
175
#if defined(GROUP_intdisable) || defined(BUILD_ALL) || defined(DOXYGEN)
176
void
177
SysTickIntDisable(void)
178
{
179
    //
180
    // Disable the SysTick interrupt.
181
    //
182
    HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
183
}
184
#endif
185
 
186
//*****************************************************************************
187
//
188
//! Sets the period of the SysTick counter.
189
//!
190
//! \param ulPeriod is the number of clock ticks in each period of the SysTick
191
//! counter; must be between 1 and 16,777,216, inclusive.
192
//!
193
//! This function sets the rate at which the SysTick counter wraps; this
194
//! equates to the number of processor clocks between interrupts.
195
//!
196
//! \return None.
197
//
198
//*****************************************************************************
199
#if defined(GROUP_periodset) || defined(BUILD_ALL) || defined(DOXYGEN)
200
void
201
SysTickPeriodSet(unsigned long ulPeriod)
202
{
203
    //
204
    // Check the arguments.
205
    //
206
    ASSERT((ulPeriod > 0) && (ulPeriod <= 16777216));
207
 
208
    //
209
    // Set the period of the SysTick counter.
210
    //
211
    HWREG(NVIC_ST_RELOAD) = ulPeriod - 1;
212
}
213
#endif
214
 
215
//*****************************************************************************
216
//
217
//! Gets the period of the SysTick counter.
218
//!
219
//! This function returns the rate at which the SysTick counter wraps; this
220
//! equates to the number of processor clocks between interrupts.
221
//!
222
//! \return Returns the period of the SysTick counter.
223
//
224
//*****************************************************************************
225
#if defined(GROUP_periodget) || defined(BUILD_ALL) || defined(DOXYGEN)
226
unsigned long
227
SysTickPeriodGet(void)
228
{
229
    //
230
    // Return the period of the SysTick counter.
231
    //
232
    return(HWREG(NVIC_ST_RELOAD) + 1);
233
}
234
#endif
235
 
236
//*****************************************************************************
237
//
238
//! Gets the current value of the SysTick counter.
239
//!
240
//! This function returns the current value of the SysTick counter; this will
241
//! be a value between the period - 1 and zero, inclusive.
242
//!
243
//! \return Returns the current value of the SysTick counter.
244
//
245
//*****************************************************************************
246
#if defined(GROUP_valueget) || defined(BUILD_ALL) || defined(DOXYGEN)
247
unsigned long
248
SysTickValueGet(void)
249
{
250
    //
251
    // Return the current value of the SysTick counter.
252
    //
253
    return(HWREG(NVIC_ST_CURRENT));
254
}
255
#endif
256
 
257
//*****************************************************************************
258
//
259
// Close the Doxygen group.
260
//! @}
261
//
262
//*****************************************************************************

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.