Alexan E
/
blinky
blinky example from NXP code bundle for LPC11Uxx. No mbed library used
KEIL_LPC11U_COMMON_LIB/nmi.c@1:0f1be4e75668, 2012-05-28 (annotated)
- Committer:
- alexan_e
- Date:
- Mon May 28 00:13:23 2012 +0000
- Revision:
- 1:0f1be4e75668
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alexan_e | 1:0f1be4e75668 | 1 | /**************************************************************************** |
alexan_e | 1:0f1be4e75668 | 2 | * $Id:: nmi.c 9190 2012-02-16 20:59:45Z nxp41306 $ |
alexan_e | 1:0f1be4e75668 | 3 | * Project: NXP LPC11Uxx NMI interrupt example |
alexan_e | 1:0f1be4e75668 | 4 | * |
alexan_e | 1:0f1be4e75668 | 5 | * Description: |
alexan_e | 1:0f1be4e75668 | 6 | * This file contains NMI interrupt handler code example. |
alexan_e | 1:0f1be4e75668 | 7 | * |
alexan_e | 1:0f1be4e75668 | 8 | **************************************************************************** |
alexan_e | 1:0f1be4e75668 | 9 | * Software that is described herein is for illustrative purposes only |
alexan_e | 1:0f1be4e75668 | 10 | * which provides customers with programming information regarding the |
alexan_e | 1:0f1be4e75668 | 11 | * products. This software is supplied "AS IS" without any warranties. |
alexan_e | 1:0f1be4e75668 | 12 | * NXP Semiconductors assumes no responsibility or liability for the |
alexan_e | 1:0f1be4e75668 | 13 | * use of the software, conveys no license or title under any patent, |
alexan_e | 1:0f1be4e75668 | 14 | * copyright, or mask work right to the product. NXP Semiconductors |
alexan_e | 1:0f1be4e75668 | 15 | * reserves the right to make changes in the software without |
alexan_e | 1:0f1be4e75668 | 16 | * notification. NXP Semiconductors also make no representation or |
alexan_e | 1:0f1be4e75668 | 17 | * warranty that such application will be suitable for the specified |
alexan_e | 1:0f1be4e75668 | 18 | * use without further testing or modification. |
alexan_e | 1:0f1be4e75668 | 19 | |
alexan_e | 1:0f1be4e75668 | 20 | * Permission to use, copy, modify, and distribute this software and its |
alexan_e | 1:0f1be4e75668 | 21 | * documentation is hereby granted, under NXP Semiconductors' |
alexan_e | 1:0f1be4e75668 | 22 | * relevant copyright in the software, without fee, provided that it |
alexan_e | 1:0f1be4e75668 | 23 | * is used in conjunction with NXP Semiconductors microcontrollers. This |
alexan_e | 1:0f1be4e75668 | 24 | * copyright, permission, and disclaimer notice must appear in all copies of |
alexan_e | 1:0f1be4e75668 | 25 | * this code. |
alexan_e | 1:0f1be4e75668 | 26 | |
alexan_e | 1:0f1be4e75668 | 27 | ****************************************************************************/ |
alexan_e | 1:0f1be4e75668 | 28 | |
alexan_e | 1:0f1be4e75668 | 29 | #include "LPC11Uxx.h" |
alexan_e | 1:0f1be4e75668 | 30 | #include "nmi.h" |
alexan_e | 1:0f1be4e75668 | 31 | |
alexan_e | 1:0f1be4e75668 | 32 | #if NMI_ENABLED |
alexan_e | 1:0f1be4e75668 | 33 | volatile uint32_t NMI_Counter[MAX_NMI_NUM]; |
alexan_e | 1:0f1be4e75668 | 34 | |
alexan_e | 1:0f1be4e75668 | 35 | /***************************************************************************** |
alexan_e | 1:0f1be4e75668 | 36 | ** Function name: NMI_Handler |
alexan_e | 1:0f1be4e75668 | 37 | ** |
alexan_e | 1:0f1be4e75668 | 38 | ** Descriptions: NMI interrupt handler |
alexan_e | 1:0f1be4e75668 | 39 | ** parameters: None |
alexan_e | 1:0f1be4e75668 | 40 | ** |
alexan_e | 1:0f1be4e75668 | 41 | ** Returned value: None |
alexan_e | 1:0f1be4e75668 | 42 | ** |
alexan_e | 1:0f1be4e75668 | 43 | *****************************************************************************/ |
alexan_e | 1:0f1be4e75668 | 44 | void NMI_Handler( void ) |
alexan_e | 1:0f1be4e75668 | 45 | { |
alexan_e | 1:0f1be4e75668 | 46 | uint32_t regVal; |
alexan_e | 1:0f1be4e75668 | 47 | |
alexan_e | 1:0f1be4e75668 | 48 | regVal = LPC_SYSCON->NMISRC; |
alexan_e | 1:0f1be4e75668 | 49 | regVal &= ~0x80000000; |
alexan_e | 1:0f1be4e75668 | 50 | if ( regVal < MAX_NMI_NUM ) |
alexan_e | 1:0f1be4e75668 | 51 | { |
alexan_e | 1:0f1be4e75668 | 52 | if ( regVal == TIMER_16_0_IRQn ) |
alexan_e | 1:0f1be4e75668 | 53 | { |
alexan_e | 1:0f1be4e75668 | 54 | /* Use TIMER16_0_IRQHandler as example for real application. */ |
alexan_e | 1:0f1be4e75668 | 55 | LPC_CT16B0->IR = 0xFF; /* Clear timer16_0 interrupt */ |
alexan_e | 1:0f1be4e75668 | 56 | } |
alexan_e | 1:0f1be4e75668 | 57 | else if ( regVal == TIMER_16_1_IRQn ) |
alexan_e | 1:0f1be4e75668 | 58 | { |
alexan_e | 1:0f1be4e75668 | 59 | /* Use TIMER16_1_IRQHandler as example for real application. */ |
alexan_e | 1:0f1be4e75668 | 60 | LPC_CT16B1->IR = 0xFF; /* Clear timer16_1 interrupt */ |
alexan_e | 1:0f1be4e75668 | 61 | } |
alexan_e | 1:0f1be4e75668 | 62 | else if ( regVal == TIMER_32_0_IRQn ) |
alexan_e | 1:0f1be4e75668 | 63 | { |
alexan_e | 1:0f1be4e75668 | 64 | /* Use TIMER32_0_IRQHandler as example for real application. */ |
alexan_e | 1:0f1be4e75668 | 65 | LPC_CT32B0->IR = 0xFF; /* Clear timer32_0 interrupt */ |
alexan_e | 1:0f1be4e75668 | 66 | } |
alexan_e | 1:0f1be4e75668 | 67 | else if ( regVal == TIMER_32_1_IRQn ) |
alexan_e | 1:0f1be4e75668 | 68 | { |
alexan_e | 1:0f1be4e75668 | 69 | /* Use TIMER32_0_IRQHandler as example for real application. */ |
alexan_e | 1:0f1be4e75668 | 70 | LPC_CT32B1->IR = 0xFF; /* Clear timer32_1 interrupt */ |
alexan_e | 1:0f1be4e75668 | 71 | } |
alexan_e | 1:0f1be4e75668 | 72 | NMI_Counter[regVal]++; |
alexan_e | 1:0f1be4e75668 | 73 | } |
alexan_e | 1:0f1be4e75668 | 74 | return; |
alexan_e | 1:0f1be4e75668 | 75 | } |
alexan_e | 1:0f1be4e75668 | 76 | |
alexan_e | 1:0f1be4e75668 | 77 | /***************************************************************************** |
alexan_e | 1:0f1be4e75668 | 78 | ** Function name: NMI_Init |
alexan_e | 1:0f1be4e75668 | 79 | ** |
alexan_e | 1:0f1be4e75668 | 80 | ** Descriptions: NMI initialization |
alexan_e | 1:0f1be4e75668 | 81 | ** parameters: NMI number |
alexan_e | 1:0f1be4e75668 | 82 | ** |
alexan_e | 1:0f1be4e75668 | 83 | ** Returned value: None |
alexan_e | 1:0f1be4e75668 | 84 | ** |
alexan_e | 1:0f1be4e75668 | 85 | *****************************************************************************/ |
alexan_e | 1:0f1be4e75668 | 86 | void NMI_Init( uint32_t NMI_num ) |
alexan_e | 1:0f1be4e75668 | 87 | { |
alexan_e | 1:0f1be4e75668 | 88 | uint32_t i; |
alexan_e | 1:0f1be4e75668 | 89 | |
alexan_e | 1:0f1be4e75668 | 90 | for ( i = 0; i < MAX_NMI_NUM; i++ ) |
alexan_e | 1:0f1be4e75668 | 91 | { |
alexan_e | 1:0f1be4e75668 | 92 | NMI_Counter[i] = 0x0; |
alexan_e | 1:0f1be4e75668 | 93 | } |
alexan_e | 1:0f1be4e75668 | 94 | LPC_SYSCON->NMISRC = 0x80000000|NMI_num; |
alexan_e | 1:0f1be4e75668 | 95 | return; |
alexan_e | 1:0f1be4e75668 | 96 | } |
alexan_e | 1:0f1be4e75668 | 97 | |
alexan_e | 1:0f1be4e75668 | 98 | #endif |