EE445M RTOS
Taken at the University of Texas Spring 2015
sysexc.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // sysexc.c - Routines for the System Exception Module.
4 //
5 // Copyright (c) 2011-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_sysctl.h"
51 #include "inc/hw_sysexc.h"
52 #include "inc/hw_types.h"
53 #include "driverlib/debug.h"
54 #include "driverlib/interrupt.h"
55 
56 //*****************************************************************************
57 //
63 //
64 //*****************************************************************************
65 static uint32_t
67 {
68  uint32_t ui32Int;
69 
70  //
71  // Get the interrupt number based on the class.
72  //
74  {
75  ui32Int = INT_SYSEXC_TM4C123;
76  }
77  else if(CLASS_IS_TM4C129)
78  {
79  ui32Int = INT_SYSEXC_TM4C129;
80  }
81  else
82  {
83  ui32Int = 0;
84  }
85  return(ui32Int);
86 }
87 
88 //*****************************************************************************
89 //
105 //
106 //*****************************************************************************
107 void
108 SysExcIntRegister(void (*pfnHandler)(void))
109 {
110  uint32_t ui32Int;
111 
112  //
113  // Get the system exception interrupt number.
114  //
115  ui32Int = _SysExcIntNumberGet();
116 
117  ASSERT(ui32Int != 0);
118 
119  //
120  // Register the interrupt handler.
121  //
122  IntRegister(ui32Int, pfnHandler);
123 
124  //
125  // Enable the system exception interrupt.
126  //
127  IntEnable(ui32Int);
128 }
129 
130 //*****************************************************************************
131 //
143 //
144 //*****************************************************************************
145 void
147 {
148  uint32_t ui32Int;
149 
150  //
151  // Get the system exception interrupt number.
152  //
153  ui32Int = _SysExcIntNumberGet();
154 
155  ASSERT(ui32Int != 0);
156 
157  //
158  // Disable the system exception interrupt.
159  //
160  IntDisable(ui32Int);
161 
162  //
163  // Unregister the system exception interrupt handler.
164  //
165  IntUnregister(ui32Int);
166 }
167 
168 //*****************************************************************************
169 //
188 //
189 //*****************************************************************************
190 void
191 SysExcIntEnable(uint32_t ui32IntFlags)
192 {
193  //
194  // Enable the specified interrupts.
195  //
196  HWREG(SYSEXC_IM) |= ui32IntFlags;
197 }
198 
199 //*****************************************************************************
200 //
220 //
221 //*****************************************************************************
222 void
223 SysExcIntDisable(uint32_t ui32IntFlags)
224 {
225  //
226  // Disable the specified interrupts.
227  //
228  HWREG(SYSEXC_IM) &= ~(ui32IntFlags);
229 }
230 
231 //*****************************************************************************
232 //
246 //
247 //*****************************************************************************
248 uint32_t
249 SysExcIntStatus(bool bMasked)
250 {
251  //
252  // Return either the interrupt status or the raw interrupt status as
253  // requested.
254  //
255  if(bMasked)
256  {
257  return(HWREG(SYSEXC_MIS));
258  }
259  else
260  {
261  return(HWREG(SYSEXC_RIS));
262  }
263 }
264 
265 //*****************************************************************************
266 //
295 //
296 //*****************************************************************************
297 void
298 SysExcIntClear(uint32_t ui32IntFlags)
299 {
300  //
301  // Clear the requested interrupt sources.
302  //
303  HWREG(SYSEXC_IC) = ui32IntFlags;
304 }
305 
306 //*****************************************************************************
307 //
308 // Close the Doxygen group.
310 //
311 //*****************************************************************************
#define INT_SYSEXC_TM4C129
Definition: hw_ints.h:243
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
void SysExcIntEnable(uint32_t ui32IntFlags)
Definition: sysexc.c:191
static uint32_t _SysExcIntNumberGet(void)
Definition: sysexc.c:66
#define SYSEXC_MIS
Definition: hw_sysexc.h:52
void SysExcIntDisable(uint32_t ui32IntFlags)
Definition: sysexc.c:223
#define SYSEXC_IC
Definition: hw_sysexc.h:54
uint32_t SysExcIntStatus(bool bMasked)
Definition: sysexc.c:249
#define CLASS_IS_TM4C123
Definition: hw_types.h:93
#define INT_SYSEXC_TM4C123
Definition: hw_ints.h:143
void IntUnregister(uint32_t ui32Interrupt)
Definition: interrupt.c:381
#define SYSEXC_RIS
Definition: hw_sysexc.h:49
void SysExcIntRegister(void(*pfnHandler)(void))
Definition: sysexc.c:108
void SysExcIntUnregister(void)
Definition: sysexc.c:146
#define CLASS_IS_TM4C129
Definition: hw_types.h:99
#define SYSEXC_IM
Definition: hw_sysexc.h:51
void IntDisable(uint32_t ui32Interrupt)
Definition: interrupt.c:684
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Definition: interrupt.c:309
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610
void SysExcIntClear(uint32_t ui32IntFlags)
Definition: sysexc.c:298