#define FOUR 1<<26 | 1<<2 | 1<<16 | 1<<23 #define B0 1<<9 uint32_t vector_B0 [10]={X,X,X, FOUR | B0, X,X,X,X,X,X} |
#define SSEG(a,b,c,d,e,f,g) (((a) << 10) | ((b) << 11) | ((c) << 15) | ((d) << 20) | ((e) << 21) | ((f) << 25) | ((g) << 26)) |
#define SSEG1 SSEG(0,1,1,0,0,0,0) #define SSEG2 SSEG(1,1,0,1,1,0,1) #define SSEG3 SSEG(1,1,1,1,0,0,1) #define SSEG4 SSEG(0,1,1,0,0,1,1) #define SSEG5 SSEG(1,0,1,1,0,1,1) #define SSEG6 SSEG(1,0,1,1,1,1,1) #define SSEG7 SSEG(1,1,1,0,0,1,0) #define SSEG8 SSEG(1,1,1,1,1,1,1) #define SSEG9 SSEG(1,1,1,1,0,1,1) #define SSEG0 SSEG(1,1,1,1,1,1,0) #define SSEG_MASK (SSEG1|SSEG2|SSEG3|SSEG4|SSEG5|SSEG6|SSEG7|SSEG8|SSEG9|SSEG0) #define B_MASK (B0|B1|B2|B3|B4|B5) |
LPC_GPIO1->FIOCLR = SSEG_MASK; |
LPC_GPIO1->FIOSET = SSEG_MASK; |
LPC_GPIO1->FIOMASK = ~(SSEG_MASK|B_MASK);/* enable only bits for 7-segment display */ LPC_GPIO1->FIOPIN = SSEG4 | B0; LPC_GPIO1->FIOPIN = SSEG7 | B1; LPC_GPIO1->FIOPIN = SSEG3 | B2; ... LPC_GPIO1->FIOPIN = SSEG9 | B5; LPC_GPIO1->FIOMASK = (SSEG_MASK|B_MASK);/* enable all other bits than the 7-segment bits */ |
LPC_GPIO1->FIOPIN = LED1_ON | LED2_OFF; |
LPC_GPIO1->FIOMASK = 0;/* enable all bits */ |
LPC_GPIO1->FIOPIN = (LPC_GPIO1->FIOPIN & ~LED_MASK) | LED1_ON | LED2_OFF; |
for(j = i; j < DIGIT_COUNT; j++) { sDigitData[j] = ALL_OFF; } |
for(i=0; i < DIGIT_COUNT; i++) { sDigitData[j] = ALL_OFF; } |
digit = vect;/* digit is a value 0..9 */ switch(i) { case 0: sDigitData = vector_b0[digit]; break; } |
switch(i) { case 0: sDigitData = vector_b0[ vect ]; break; } |
void SysTick_Handler(void)/* This is an interrupt handler, it's called automatically. */ { sSysTickCnt++; } void Delay(uint32_t aTicks) { uint32_tstart; start = sSysTickCnt;/* read current value of sSysTickCnt */ while((sSysTickCnt - start) < aTicks);/* sSysTickCnt is incremented by the interrupt handler */ } void Set_SysTick(void)/* this sets up the SysTick interrupt */ { SYSTICK_InternalInit(1); SYSTICK_Cmd(ENABLE); SYSTICK_IntCmd(ENABLE); } |
Delay (200); |
LPC_GPIO0->FIOPIN = vector_b0[vect]; |
void Delay (float tick) { unsigned long systickcnt; systickcnt = SysTickCnt; while ((SysTickCnt - systickcnt) < tick); } |
void Delay(uint32_t aTicks) { uint32_tstart; start = sSysTickCnt; while((sSysTickCnt - start) < aTicks); } |