#include "ioCC2530.h" #define LED2 P1_1 #define LED1 P1_0 #define SW2 P0_4 #define SW1 P0_1 unsigned int KeyTouchtimes = 0 ; void delay(unsigned int time) { unsigned int i; unsigned char j; for(i = 0; i < time; i++) { for(j = 0; j < 240; j++) { asm("NOP"); asm("NOP"); asm("NOP"); } } } void init() { P1SEL &=~0x03; P1DIR |= 0x03 ; LED1 = 1; LED2 = 1; PICTL &= ~0x01; P0IEN |= 0x02; IEN1 |= 0x20; EA = 1; } #pragma vector=P0INT_VECTOR __interrupt void P1_INT(void) { EA = 0; if(P0IFG & 0x12) { KeyTouchtimes++; if(KeyTouchtimes >=4) { KeyTouchtimes = 0; } switch(KeyTouchtimes) { case 0: LED1 = 0; LED2 = 0; break; case 1: LED1= 1;LED2 = 0; break; case 2: LED1 = 0;LED2= 1; break; case 3: LED1 = 1;LED2= 1; break; }
P0IFG &= ~0x12; } EA = 1; } void main(void) { init(); while(1) { } }