These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!
gpio_int.c
00001 /***********************************************************************//** 00002 * @file gpio_int.c 00003 * @purpose This example used to test GPIO interrupt function 00004 * @version 2.0 00005 * @date 21. May. 2010 00006 * @author NXP MCU SW Application Team 00007 *--------------------------------------------------------------------- 00008 * Software that is described herein is for illustrative purposes only 00009 * which provides customers with programming information regarding the 00010 * products. This software is supplied "AS IS" without any warranties. 00011 * NXP Semiconductors assumes no responsibility or liability for the 00012 * use of the software, conveys no license or title under any patent, 00013 * copyright, or mask work right to the product. NXP Semiconductors 00014 * reserves the right to make changes in the software without 00015 * notification. NXP Semiconductors also make no representation or 00016 * warranty that such application will be suitable for the specified 00017 * use without further testing or modification. 00018 **********************************************************************/ 00019 #include "LPC17xx.h" 00020 #include "lpc17xx_gpio.h" 00021 #include "lpc17xx_pinsel.h" 00022 #include "lpc17xx_libcfg.h" 00023 00024 /* Example group ----------------------------------------------------------- */ 00025 /** @defgroup GPIO_Interrupt GPIO_Interrupt 00026 * @ingroup GPIO_Examples 00027 * @{ 00028 */ 00029 00030 /************************** PRIVATE DEFINITIONS *************************/ 00031 #define MCB_LPC_1768 00032 //#define IAR_LPC_1768 00033 00034 #ifdef MCB_LPC_1768 00035 /* LED pin in byte style on P1 */ 00036 #define POLL_LED (1<<4) // P1.28 00037 #define INT3_LED (1<<5) // P1.29 00038 #define GPIO_INT (1<<25) // test GPIO interrupt on P0.25 00039 #elif defined(IAR_LPC_1768) 00040 #define POLL_LED (1<<1) //P1.25 (LED2) 00041 #define INT3_LED (1<<4) //P0.4 (LED1) 00042 #define GPIO_INT (1<<23) // test GPIO interrupt on P0.23 00043 #endif 00044 00045 00046 /************************** PRIVATE FUNCTIONS *************************/ 00047 void EINT3_IRQHandler(void); 00048 00049 void delay (void); 00050 00051 /*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/ 00052 /*********************************************************************//** 00053 * @brief External interrupt 3 handler sub-routine 00054 * @param[in] None 00055 * @return None 00056 **********************************************************************/ 00057 void EINT3_IRQHandler(void) 00058 { 00059 int j; 00060 if(GPIO_GetIntStatus(0, 25, 1)) 00061 { 00062 GPIO_ClearInt(0,(1<<25)); 00063 for (j= 0; j<8; j++) 00064 { 00065 #ifdef MCB_LPC_1768 00066 /* Use MCB1700 board: 00067 * blink LED P1.29 when EINT3 occur 00068 */ 00069 FIO_ByteSetValue(1, 3, INT3_LED); 00070 delay(); 00071 FIO_ByteClearValue(1, 3, INT3_LED); 00072 delay(); 00073 #elif defined(IAR_LPC_1768) 00074 /* Use IAR LPC1768 KS board: 00075 * blink LED2 P0.4 when EINT3 occur 00076 */ 00077 FIO_ByteSetValue(0, 0, INT3_LED); 00078 delay(); 00079 FIO_ByteClearValue(0, 0, INT3_LED); 00080 delay(); 00081 #endif 00082 } 00083 } 00084 } 00085 00086 /*-------------------------PRIVATE FUNCTIONS------------------------------*/ 00087 /*********************************************************************//** 00088 * @brief Delay function 00089 * @param[in] None 00090 * @return None 00091 **********************************************************************/ 00092 void delay (void) { 00093 unsigned int i; 00094 00095 for (i = 0; i < 0x100000; i++) { 00096 } 00097 } 00098 00099 00100 /*-------------------------MAIN FUNCTION------------------------------*/ 00101 /*********************************************************************//** 00102 * @brief c_entry: Main program body 00103 * @param[in] None 00104 * @return int 00105 **********************************************************************/ 00106 int c_entry (void) 00107 { 00108 /** Use: LEDs for polling when idle and when GPIO interrupt occurs 00109 * If using MCB1700 board: Polling led: P1.28; Interrupt led: P1.29 00110 * If using IAR KS board: Polling led: P1.25 (LED1); Interrupt led: P0.4 (LED2) 00111 */ 00112 #ifdef MCB_LPC_1768 00113 FIO_ByteSetDir(1, 3, POLL_LED, 1); 00114 FIO_ByteSetDir(1, 3, INT3_LED, 1); 00115 // Turn off all LEDs 00116 FIO_ByteClearValue(1, 3, POLL_LED); 00117 FIO_ByteClearValue(1, 3, INT3_LED); 00118 #elif defined(IAR_LPC_1768) 00119 FIO_ByteSetDir(1, 3, POLL_LED, 1); 00120 FIO_ByteSetDir(0, 0, INT3_LED, 1); 00121 // Turn off all LEDs 00122 FIO_ByteSetValue(1, 3, POLL_LED); 00123 FIO_ByteSetValue(0, 0, INT3_LED); 00124 #endif 00125 00126 // Enable GPIO interrupt 00127 /* Use MCB1700: test GPIO interrupt on P0.25->connects with ADC potentiometer 00128 * Use IAR KS : test GPIO interrupt on P0.23->connects with BUT1 button 00129 */ 00130 GPIO_IntCmd(0,(1<<25),1); 00131 NVIC_EnableIRQ(EINT3_IRQn); 00132 00133 while (1) 00134 { 00135 //polling led while idle 00136 FIO_ByteSetValue(1, 3, POLL_LED); 00137 delay(); 00138 FIO_ByteClearValue(1, 3, POLL_LED); 00139 delay(); 00140 } 00141 } 00142 00143 00144 /* With ARM and GHS toolsets, the entry point is main() - this will 00145 allow the linker to generate wrapper code to setup stacks, allocate 00146 heap area, and initialize and copy code and data segments. For GNU 00147 toolsets, the entry point is through __start() in the crt0_gnu.asm 00148 file, and that startup code will setup stacks and data */ 00149 int main(void) 00150 { 00151 return c_entry(); 00152 } 00153 00154 #ifdef DEBUG 00155 /******************************************************************************* 00156 * @brief Reports the name of the source file and the source line number 00157 * where the CHECK_PARAM error has occurred. 00158 * @param[in] file Pointer to the source file name 00159 * @param[in] line assert_param error line source number 00160 * @return None 00161 *******************************************************************************/ 00162 void check_failed(uint8_t *file, uint32_t line) 00163 { 00164 /* User can add his own implementation to report the file name and line number, 00165 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 00166 00167 /* Infinite loop */ 00168 while(1); 00169 } 00170 #endif 00171 00172 /* 00173 * @} 00174 */
Generated on Tue Jul 12 2022 17:28:08 by
![doxygen](doxygen.png)