interrupt.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. //*****************************************************************************
  2. //
  3. // interrupt.c - Driver for the NVIC Interrupt Controller.
  4. //
  5. // Copyright (c) 2005-2010 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 6459 of the Stellaris Peripheral Driver Library.
  22. //
  23. //*****************************************************************************
  24. //*****************************************************************************
  25. //
  26. //! \addtogroup interrupt_api
  27. //! @{
  28. //
  29. //*****************************************************************************
  30. #include "inc/hw_ints.h"
  31. #include "inc/hw_nvic.h"
  32. #include "inc/hw_types.h"
  33. #include "driverlib/cpu.h"
  34. #include "driverlib/debug.h"
  35. #include "driverlib/interrupt.h"
  36. //*****************************************************************************
  37. //
  38. // This is a mapping between priority grouping encodings and the number of
  39. // preemption priority bits.
  40. //
  41. //*****************************************************************************
  42. static const unsigned long g_pulPriority[] =
  43. {
  44. NVIC_APINT_PRIGROUP_0_8, NVIC_APINT_PRIGROUP_1_7, NVIC_APINT_PRIGROUP_2_6,
  45. NVIC_APINT_PRIGROUP_3_5, NVIC_APINT_PRIGROUP_4_4, NVIC_APINT_PRIGROUP_5_3,
  46. NVIC_APINT_PRIGROUP_6_2, NVIC_APINT_PRIGROUP_7_1
  47. };
  48. //*****************************************************************************
  49. //
  50. // This is a mapping between interrupt number and the register that contains
  51. // the priority encoding for that interrupt.
  52. //
  53. //*****************************************************************************
  54. static const unsigned long g_pulRegs[] =
  55. {
  56. 0, NVIC_SYS_PRI1, NVIC_SYS_PRI2, NVIC_SYS_PRI3, NVIC_PRI0, NVIC_PRI1,
  57. NVIC_PRI2, NVIC_PRI3, NVIC_PRI4, NVIC_PRI5, NVIC_PRI6, NVIC_PRI7,
  58. NVIC_PRI8, NVIC_PRI9, NVIC_PRI10, NVIC_PRI11, NVIC_PRI12, NVIC_PRI13
  59. };
  60. //*****************************************************************************
  61. //
  62. //! \internal
  63. //! The default interrupt handler.
  64. //!
  65. //! This is the default interrupt handler for all interrupts. It simply loops
  66. //! forever so that the system state is preserved for observation by a
  67. //! debugger. Since interrupts should be disabled before unregistering the
  68. //! corresponding handler, this should never be called.
  69. //!
  70. //! \return None.
  71. //
  72. //*****************************************************************************
  73. static void
  74. IntDefaultHandler(void)
  75. {
  76. //
  77. // Go into an infinite loop.
  78. //
  79. while(1)
  80. {
  81. }
  82. }
  83. //*****************************************************************************
  84. //
  85. // The processor vector table.
  86. //
  87. // This contains a list of the handlers for the various interrupt sources in
  88. // the system. The layout of this list is defined by the hardware; assertion
  89. // of an interrupt causes the processor to start executing directly at the
  90. // address given in the corresponding location in this list.
  91. //
  92. //*****************************************************************************
  93. #if defined(ewarm)
  94. static __no_init void (*g_pfnRAMVectors[NUM_INTERRUPTS])(void) @ "VTABLE";
  95. #elif defined(sourcerygxx)
  96. static __attribute__((section(".cs3.region-head.ram")))
  97. void (*g_pfnRAMVectors[NUM_INTERRUPTS])(void);
  98. #elif defined(ccs)
  99. #pragma DATA_SECTION(g_pfnRAMVectors, ".vtable")
  100. void (*g_pfnRAMVectors[NUM_INTERRUPTS])(void);
  101. #else
  102. static __attribute__((section("vtable")))
  103. void (*g_pfnRAMVectors[NUM_INTERRUPTS])(void);
  104. #endif
  105. //*****************************************************************************
  106. //
  107. //! Enables the processor interrupt.
  108. //!
  109. //! Allows the processor to respond to interrupts. This does not affect the
  110. //! set of interrupts enabled in the interrupt controller; it just gates the
  111. //! single interrupt from the controller to the processor.
  112. //!
  113. //! \note Previously, this function had no return value. As such, it was
  114. //! possible to include <tt>interrupt.h</tt> and call this function without
  115. //! having included <tt>hw_types.h</tt>. Now that the return is a
  116. //! <tt>tBoolean</tt>, a compiler error will occur in this case. The solution
  117. //! is to include <tt>hw_types.h</tt> before including <tt>interrupt.h</tt>.
  118. //!
  119. //! \return Returns \b true if interrupts were disabled when the function was
  120. //! called or \b false if they were initially enabled.
  121. //
  122. //*****************************************************************************
  123. tBoolean
  124. IntMasterEnable(void)
  125. {
  126. //
  127. // Enable processor interrupts.
  128. //
  129. return(CPUcpsie());
  130. }
  131. //*****************************************************************************
  132. //
  133. //! Disables the processor interrupt.
  134. //!
  135. //! Prevents the processor from receiving interrupts. This does not affect the
  136. //! set of interrupts enabled in the interrupt controller; it just gates the
  137. //! single interrupt from the controller to the processor.
  138. //!
  139. //! \note Previously, this function had no return value. As such, it was
  140. //! possible to include <tt>interrupt.h</tt> and call this function without
  141. //! having included <tt>hw_types.h</tt>. Now that the return is a
  142. //! <tt>tBoolean</tt>, a compiler error will occur in this case. The solution
  143. //! is to include <tt>hw_types.h</tt> before including <tt>interrupt.h</tt>.
  144. //!
  145. //! \return Returns \b true if interrupts were already disabled when the
  146. //! function was called or \b false if they were initially enabled.
  147. //
  148. //*****************************************************************************
  149. tBoolean
  150. IntMasterDisable(void)
  151. {
  152. //
  153. // Disable processor interrupts.
  154. //
  155. return(CPUcpsid());
  156. }
  157. //*****************************************************************************
  158. //
  159. //! Registers a function to be called when an interrupt occurs.
  160. //!
  161. //! \param ulInterrupt specifies the interrupt in question.
  162. //! \param pfnHandler is a pointer to the function to be called.
  163. //!
  164. //! This function is used to specify the handler function to be called when the
  165. //! given interrupt is asserted to the processor. When the interrupt occurs,
  166. //! if it is enabled (via IntEnable()), the handler function will be called in
  167. //! interrupt context. Since the handler function can preempt other code, care
  168. //! must be taken to protect memory or peripherals that are accessed by the
  169. //! handler and other non-handler code.
  170. //!
  171. //! \note The use of this function (directly or indirectly via a peripheral
  172. //! driver interrupt register function) moves the interrupt vector table from
  173. //! flash to SRAM. Therefore, care must be taken when linking the application
  174. //! to ensure that the SRAM vector table is located at the beginning of SRAM;
  175. //! otherwise NVIC will not look in the correct portion of memory for the
  176. //! vector table (it requires the vector table be on a 1 kB memory alignment).
  177. //! Normally, the SRAM vector table is so placed via the use of linker scripts;
  178. //! some tool chains, such as the evaluation version of RV-MDK, do not support
  179. //! linker scripts and therefore will not produce a valid executable. See the
  180. //! discussion of compile-time versus run-time interrupt handler registration
  181. //! in the introduction to this chapter.
  182. //!
  183. //! \return None.
  184. //
  185. //*****************************************************************************
  186. void
  187. IntRegister(unsigned long ulInterrupt, void (*pfnHandler)(void))
  188. {
  189. unsigned long ulIdx, ulValue;
  190. //
  191. // Check the arguments.
  192. //
  193. ASSERT(ulInterrupt < NUM_INTERRUPTS);
  194. //
  195. // Make sure that the RAM vector table is correctly aligned.
  196. //
  197. ASSERT(((unsigned long)g_pfnRAMVectors & 0x000003ff) == 0);
  198. //
  199. // See if the RAM vector table has been initialized.
  200. //
  201. if(HWREG(NVIC_VTABLE) != (unsigned long)g_pfnRAMVectors)
  202. {
  203. //
  204. // Copy the vector table from the beginning of FLASH to the RAM vector
  205. // table.
  206. //
  207. ulValue = HWREG(NVIC_VTABLE);
  208. for(ulIdx = 0; ulIdx < NUM_INTERRUPTS; ulIdx++)
  209. {
  210. g_pfnRAMVectors[ulIdx] = (void (*)(void))HWREG((ulIdx * 4) +
  211. ulValue);
  212. }
  213. //
  214. // Point NVIC at the RAM vector table.
  215. //
  216. HWREG(NVIC_VTABLE) = (unsigned long)g_pfnRAMVectors;
  217. }
  218. //
  219. // Save the interrupt handler.
  220. //
  221. g_pfnRAMVectors[ulInterrupt] = pfnHandler;
  222. }
  223. //*****************************************************************************
  224. //
  225. //! Unregisters the function to be called when an interrupt occurs.
  226. //!
  227. //! \param ulInterrupt specifies the interrupt in question.
  228. //!
  229. //! This function is used to indicate that no handler should be called when the
  230. //! given interrupt is asserted to the processor. The interrupt source will be
  231. //! automatically disabled (via IntDisable()) if necessary.
  232. //!
  233. //! \sa IntRegister() for important information about registering interrupt
  234. //! handlers.
  235. //!
  236. //! \return None.
  237. //
  238. //*****************************************************************************
  239. void
  240. IntUnregister(unsigned long ulInterrupt)
  241. {
  242. //
  243. // Check the arguments.
  244. //
  245. ASSERT(ulInterrupt < NUM_INTERRUPTS);
  246. //
  247. // Reset the interrupt handler.
  248. //
  249. g_pfnRAMVectors[ulInterrupt] = IntDefaultHandler;
  250. }
  251. //*****************************************************************************
  252. //
  253. //! Sets the priority grouping of the interrupt controller.
  254. //!
  255. //! \param ulBits specifies the number of bits of preemptable priority.
  256. //!
  257. //! This function specifies the split between preemptable priority levels and
  258. //! subpriority levels in the interrupt priority specification. The range of
  259. //! the grouping values are dependent upon the hardware implementation; on
  260. //! the Stellaris family, three bits are available for hardware interrupt
  261. //! prioritization and therefore priority grouping values of three through
  262. //! seven have the same effect.
  263. //!
  264. //! \return None.
  265. //
  266. //*****************************************************************************
  267. void
  268. IntPriorityGroupingSet(unsigned long ulBits)
  269. {
  270. //
  271. // Check the arguments.
  272. //
  273. ASSERT(ulBits < NUM_PRIORITY);
  274. //
  275. // Set the priority grouping.
  276. //
  277. HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | g_pulPriority[ulBits];
  278. }
  279. //*****************************************************************************
  280. //
  281. //! Gets the priority grouping of the interrupt controller.
  282. //!
  283. //! This function returns the split between preemptable priority levels and
  284. //! subpriority levels in the interrupt priority specification.
  285. //!
  286. //! \return The number of bits of preemptable priority.
  287. //
  288. //*****************************************************************************
  289. unsigned long
  290. IntPriorityGroupingGet(void)
  291. {
  292. unsigned long ulLoop, ulValue;
  293. //
  294. // Read the priority grouping.
  295. //
  296. ulValue = HWREG(NVIC_APINT) & NVIC_APINT_PRIGROUP_M;
  297. //
  298. // Loop through the priority grouping values.
  299. //
  300. for(ulLoop = 0; ulLoop < NUM_PRIORITY; ulLoop++)
  301. {
  302. //
  303. // Stop looping if this value matches.
  304. //
  305. if(ulValue == g_pulPriority[ulLoop])
  306. {
  307. break;
  308. }
  309. }
  310. //
  311. // Return the number of priority bits.
  312. //
  313. return(ulLoop);
  314. }
  315. //*****************************************************************************
  316. //
  317. //! Sets the priority of an interrupt.
  318. //!
  319. //! \param ulInterrupt specifies the interrupt in question.
  320. //! \param ucPriority specifies the priority of the interrupt.
  321. //!
  322. //! This function is used to set the priority of an interrupt. When multiple
  323. //! interrupts are asserted simultaneously, the ones with the highest priority
  324. //! are processed before the lower priority interrupts. Smaller numbers
  325. //! correspond to higher interrupt priorities; priority 0 is the highest
  326. //! interrupt priority.
  327. //!
  328. //! The hardware priority mechanism will only look at the upper N bits of the
  329. //! priority level (where N is 3 for the Stellaris family), so any
  330. //! prioritization must be performed in those bits. The remaining bits can be
  331. //! used to sub-prioritize the interrupt sources, and may be used by the
  332. //! hardware priority mechanism on a future part. This arrangement allows
  333. //! priorities to migrate to different NVIC implementations without changing
  334. //! the gross prioritization of the interrupts.
  335. //!
  336. //! \return None.
  337. //
  338. //*****************************************************************************
  339. void
  340. IntPrioritySet(unsigned long ulInterrupt, unsigned char ucPriority)
  341. {
  342. unsigned long ulTemp;
  343. //
  344. // Check the arguments.
  345. //
  346. ASSERT((ulInterrupt >= 4) && (ulInterrupt < NUM_INTERRUPTS));
  347. //
  348. // Set the interrupt priority.
  349. //
  350. ulTemp = HWREG(g_pulRegs[ulInterrupt >> 2]);
  351. ulTemp &= ~(0xFF << (8 * (ulInterrupt & 3)));
  352. ulTemp |= ucPriority << (8 * (ulInterrupt & 3));
  353. HWREG(g_pulRegs[ulInterrupt >> 2]) = ulTemp;
  354. }
  355. //*****************************************************************************
  356. //
  357. //! Gets the priority of an interrupt.
  358. //!
  359. //! \param ulInterrupt specifies the interrupt in question.
  360. //!
  361. //! This function gets the priority of an interrupt. See IntPrioritySet() for
  362. //! a definition of the priority value.
  363. //!
  364. //! \return Returns the interrupt priority, or -1 if an invalid interrupt was
  365. //! specified.
  366. //
  367. //*****************************************************************************
  368. long
  369. IntPriorityGet(unsigned long ulInterrupt)
  370. {
  371. //
  372. // Check the arguments.
  373. //
  374. ASSERT((ulInterrupt >= 4) && (ulInterrupt < NUM_INTERRUPTS));
  375. //
  376. // Return the interrupt priority.
  377. //
  378. return((HWREG(g_pulRegs[ulInterrupt >> 2]) >> (8 * (ulInterrupt & 3))) &
  379. 0xFF);
  380. }
  381. //*****************************************************************************
  382. //
  383. //! Enables an interrupt.
  384. //!
  385. //! \param ulInterrupt specifies the interrupt to be enabled.
  386. //!
  387. //! The specified interrupt is enabled in the interrupt controller. Other
  388. //! enables for the interrupt (such as at the peripheral level) are unaffected
  389. //! by this function.
  390. //!
  391. //! \return None.
  392. //
  393. //*****************************************************************************
  394. void
  395. IntEnable(unsigned long ulInterrupt)
  396. {
  397. //
  398. // Check the arguments.
  399. //
  400. ASSERT(ulInterrupt < NUM_INTERRUPTS);
  401. //
  402. // Determine the interrupt to enable.
  403. //
  404. if(ulInterrupt == FAULT_MPU)
  405. {
  406. //
  407. // Enable the MemManage interrupt.
  408. //
  409. HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_MEM;
  410. }
  411. else if(ulInterrupt == FAULT_BUS)
  412. {
  413. //
  414. // Enable the bus fault interrupt.
  415. //
  416. HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_BUS;
  417. }
  418. else if(ulInterrupt == FAULT_USAGE)
  419. {
  420. //
  421. // Enable the usage fault interrupt.
  422. //
  423. HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_USAGE;
  424. }
  425. else if(ulInterrupt == FAULT_SYSTICK)
  426. {
  427. //
  428. // Enable the System Tick interrupt.
  429. //
  430. HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
  431. }
  432. else if((ulInterrupt >= 16) && (ulInterrupt <= 47))
  433. {
  434. //
  435. // Enable the general interrupt.
  436. //
  437. HWREG(NVIC_EN0) = 1 << (ulInterrupt - 16);
  438. }
  439. else if(ulInterrupt >= 48)
  440. {
  441. //
  442. // Enable the general interrupt.
  443. //
  444. HWREG(NVIC_EN1) = 1 << (ulInterrupt - 48);
  445. }
  446. }
  447. //*****************************************************************************
  448. //
  449. //! Disables an interrupt.
  450. //!
  451. //! \param ulInterrupt specifies the interrupt to be disabled.
  452. //!
  453. //! The specified interrupt is disabled in the interrupt controller. Other
  454. //! enables for the interrupt (such as at the peripheral level) are unaffected
  455. //! by this function.
  456. //!
  457. //! \return None.
  458. //
  459. //*****************************************************************************
  460. void
  461. IntDisable(unsigned long ulInterrupt)
  462. {
  463. //
  464. // Check the arguments.
  465. //
  466. ASSERT(ulInterrupt < NUM_INTERRUPTS);
  467. //
  468. // Determine the interrupt to disable.
  469. //
  470. if(ulInterrupt == FAULT_MPU)
  471. {
  472. //
  473. // Disable the MemManage interrupt.
  474. //
  475. HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_MEM);
  476. }
  477. else if(ulInterrupt == FAULT_BUS)
  478. {
  479. //
  480. // Disable the bus fault interrupt.
  481. //
  482. HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_BUS);
  483. }
  484. else if(ulInterrupt == FAULT_USAGE)
  485. {
  486. //
  487. // Disable the usage fault interrupt.
  488. //
  489. HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_USAGE);
  490. }
  491. else if(ulInterrupt == FAULT_SYSTICK)
  492. {
  493. //
  494. // Disable the System Tick interrupt.
  495. //
  496. HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
  497. }
  498. else if((ulInterrupt >= 16) && (ulInterrupt <= 47))
  499. {
  500. //
  501. // Disable the general interrupt.
  502. //
  503. HWREG(NVIC_DIS0) = 1 << (ulInterrupt - 16);
  504. }
  505. else if(ulInterrupt >= 48)
  506. {
  507. //
  508. // Disable the general interrupt.
  509. //
  510. HWREG(NVIC_DIS1) = 1 << (ulInterrupt - 48);
  511. }
  512. }
  513. //*****************************************************************************
  514. //
  515. //! Pends an interrupt.
  516. //!
  517. //! \param ulInterrupt specifies the interrupt to be pended.
  518. //!
  519. //! The specified interrupt is pended in the interrupt controller. This will
  520. //! cause the interrupt controller to execute the corresponding interrupt
  521. //! handler at the next available time, based on the current interrupt state
  522. //! priorities. For example, if called by a higher priority interrupt handler,
  523. //! the specified interrupt handler will not be called until after the current
  524. //! interrupt handler has completed execution. The interrupt must have been
  525. //! enabled for it to be called.
  526. //!
  527. //! \return None.
  528. //
  529. //*****************************************************************************
  530. void
  531. IntPendSet(unsigned long ulInterrupt)
  532. {
  533. //
  534. // Check the arguments.
  535. //
  536. ASSERT(ulInterrupt < NUM_INTERRUPTS);
  537. //
  538. // Determine the interrupt to pend.
  539. //
  540. if(ulInterrupt == FAULT_NMI)
  541. {
  542. //
  543. // Pend the NMI interrupt.
  544. //
  545. HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_NMI_SET;
  546. }
  547. else if(ulInterrupt == FAULT_PENDSV)
  548. {
  549. //
  550. // Pend the PendSV interrupt.
  551. //
  552. HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PEND_SV;
  553. }
  554. else if(ulInterrupt == FAULT_SYSTICK)
  555. {
  556. //
  557. // Pend the SysTick interrupt.
  558. //
  559. HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTSET;
  560. }
  561. else if((ulInterrupt >= 16) && (ulInterrupt <= 47))
  562. {
  563. //
  564. // Pend the general interrupt.
  565. //
  566. HWREG(NVIC_PEND0) = 1 << (ulInterrupt - 16);
  567. }
  568. else if(ulInterrupt >= 48)
  569. {
  570. //
  571. // Pend the general interrupt.
  572. //
  573. HWREG(NVIC_PEND1) = 1 << (ulInterrupt - 48);
  574. }
  575. }
  576. //*****************************************************************************
  577. //
  578. //! Unpends an interrupt.
  579. //!
  580. //! \param ulInterrupt specifies the interrupt to be unpended.
  581. //!
  582. //! The specified interrupt is unpended in the interrupt controller. This will
  583. //! cause any previously generated interrupts that have not been handled yet
  584. //! (due to higher priority interrupts or the interrupt no having been enabled
  585. //! yet) to be discarded.
  586. //!
  587. //! \return None.
  588. //
  589. //*****************************************************************************
  590. void
  591. IntPendClear(unsigned long ulInterrupt)
  592. {
  593. //
  594. // Check the arguments.
  595. //
  596. ASSERT(ulInterrupt < NUM_INTERRUPTS);
  597. //
  598. // Determine the interrupt to unpend.
  599. //
  600. if(ulInterrupt == FAULT_PENDSV)
  601. {
  602. //
  603. // Unpend the PendSV interrupt.
  604. //
  605. HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_UNPEND_SV;
  606. }
  607. else if(ulInterrupt == FAULT_SYSTICK)
  608. {
  609. //
  610. // Unpend the SysTick interrupt.
  611. //
  612. HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTCLR;
  613. }
  614. else if((ulInterrupt >= 16) && (ulInterrupt <= 47))
  615. {
  616. //
  617. // Unpend the general interrupt.
  618. //
  619. HWREG(NVIC_UNPEND0) = 1 << (ulInterrupt - 16);
  620. }
  621. else if(ulInterrupt >= 48)
  622. {
  623. //
  624. // Unpend the general interrupt.
  625. //
  626. HWREG(NVIC_UNPEND1) = 1 << (ulInterrupt - 48);
  627. }
  628. }
  629. //*****************************************************************************
  630. //
  631. //! Sets the priority masking level
  632. //!
  633. //! \param ulPriorityMask is the priority level that will be masked.
  634. //!
  635. //! This function sets the interrupt priority masking level so that all
  636. //! interrupts at the specified or lesser priority level is masked. This
  637. //! can be used to globally disable a set of interrupts with priority below
  638. //! a predetermined threshold. A value of 0 disables priority
  639. //! masking.
  640. //!
  641. //! Smaller numbers correspond to higher interrupt priorities. So for example
  642. //! a priority level mask of 4 will allow interrupts of priority level 0-3,
  643. //! and interrupts with a numerical priority of 4 and greater will be blocked.
  644. //!
  645. //! The hardware priority mechanism will only look at the upper N bits of the
  646. //! priority level (where N is 3 for the Stellaris family), so any
  647. //! prioritization must be performed in those bits.
  648. //!
  649. //! \return None.
  650. //
  651. //*****************************************************************************
  652. void
  653. IntPriorityMaskSet(unsigned long ulPriorityMask)
  654. {
  655. CPUbasepriSet(ulPriorityMask);
  656. }
  657. //*****************************************************************************
  658. //
  659. //! Gets the priority masking level
  660. //!
  661. //! This function gets the current setting of the interrupt priority masking
  662. //! level. The value returned is the priority level such that all interrupts
  663. //! of that and lesser priority are masked. A value of 0 means that priority
  664. //! masking is disabled.
  665. //!
  666. //! Smaller numbers correspond to higher interrupt priorities. So for example
  667. //! a priority level mask of 4 will allow interrupts of priority level 0-3,
  668. //! and interrupts with a numerical priority of 4 and greater will be blocked.
  669. //!
  670. //! The hardware priority mechanism will only look at the upper N bits of the
  671. //! priority level (where N is 3 for the Stellaris family), so any
  672. //! prioritization must be performed in those bits.
  673. //!
  674. //! \return Returns the value of the interrupt priority level mask.
  675. //
  676. //*****************************************************************************
  677. unsigned long
  678. IntPriorityMaskGet(void)
  679. {
  680. return(CPUbasepriGet());
  681. }
  682. //*****************************************************************************
  683. //
  684. // Close the Doxygen group.
  685. //! @}
  686. //
  687. //*****************************************************************************