cc2530按键中断
作者:互联网
cc2530按键中断
#include "ioCC2530.h"
#define LED1 P1_0
#define LED2 P1_1
#define ON 1
#define OFF 0
void delay(unsigned int time)
{
unsigned int i;
unsigned int j;
for(i=0;i<time;i++)
for(j=0;j<240;j++)
{
asm("NOP");
asm("NOP");
asm("NOP");
}
}
void xtal_init()
{
CLKCONCMD &=~0x40;
while(CLKCONSTA & 0x40);
CLKCONCMD &=~0x07;
}
void ext_init()
{
IEN2 |=0x10;
P1IEN |=0x04;
PICTL |=0x02;
EA=1;
}
void led_io_init(){
P1SEL &=~0x03;
P1DIR |=0x03;
}
void main(void){
xtal_init();
led_io_init();
ext_init();
LED2=ON;
while(1);
}
#pragma vector=P1INT_VECTOR
__interrupt void P1_ISR(void)
{
if((P1IFG & 0x04)>0){
P1IFG &=~0x04;
delay(10);
}
}
标签:中断,void,unsigned,int,init,0x04,cc2530,按键,define 来源: https://blog.csdn.net/huachengdianxia/article/details/115336382