main.c

来自「Keil CARM Examples 很好的例子」· C语言 代码 · 共 61 行

C
61
字号
/************************************************************/
/* PROJECT NAME: SWI	                                    */
/* Project:      LPC2100 Training course                    */
/* Engineer:     T Martin      tmartin@hitex.co.uk          */
/* Filename:     main.c                                     */
/* Language:     C                      	                */
/* Compiler:     Keil ARM		V2.00b	              		*/
/* Assembler:    				               				*/
/*                                                          */
/************************************************************/
/* COPYRIGHT: Hitex UK Ltd 		2005						*/
/* LICENSE:   THIS VERSION CREATED FOR FREE DISTRIBUTION	*/
/************************************************************/
/* Function:                                                */
/*                                                          */
/* Example software interrupt for LPC2100              		*/
/*															*/
/* Demonstrates serving an SWI and running selected code	*/
/*															*/	
/* Oscillator frequency 12.000 Mhz							*/
/* Target board Keil MCB21000								*/
/************************************************************/




#include <LPC21xx.H> 


void SWI_Call1(int pattern) __swi(8)   		 //Software interrupt with passed parameters
{

IOCLR1 		= 0x00FF0000;			 		//set the leds
IOSET1 		= pattern;						
}

void SWI_Call2(void)   __swi(9)				 //void call to software intterupt
{
IOCLR1 		= 0x00FF0000;			 		//write default pattern to the LEDs
IOSET1 		= 0x00AA0000;
}


void main(void)
{
int pattern = 0x00550000;
IODIR1 		= 0x00FF0000;					//Set LED pins as outputs
IOCLR1 		= 0x00FF0000;					//Generate software interrupt

SWI_Call1(pattern);							//call software interrupt

SWI_Call2();								//Call second software interrupt
									

while(1)
{
;											//Loop forever
}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?