18 volatile static uint8_t flag_flash_redLED = 0;
19 volatile static uint8_t flag_flash_greenLED = 0;
21 volatile static uint16_t leftSW_count = 0;
22 volatile static uint16_t rightSW_count = 0;
24 volatile static uint16_t redLED_count = 0;
25 volatile static uint16_t greenLED_count = 0;
27 volatile static uint32_t elapsed_time_count = 0;
29 volatile static uint16_t on_count_redLED = 0;
30 volatile static uint16_t off_count_redLED = 1;
31 volatile static uint16_t on_count_greenLED = 0;
32 volatile static uint16_t off_count_greenLED = 1;
34 volatile static float voltageLipo = 0.0;
35 volatile static float voltageMotor = 0.0;
72 state = LPC_GPIO2->DATA & 0x1;
86 state = (LPC_GPIO0->DATA & 0x2)>>1;
113 return rightSW_count;
124 return elapsed_time_count;
134 elapsed_time_count = 0;
144 static void setStateGreenLED(
uint8_t state)
148 LPC_GPIO1->DATA |= 0x0100;
152 LPC_GPIO1->DATA &= ~0x0100;
162 static void setStateRedLED(
uint8_t state)
166 LPC_GPIO1->DATA |= 0x0008;
170 LPC_GPIO1->DATA &= ~0x0008;
183 flag_flash_redLED = 0;
184 setStateRedLED(state);
197 flag_flash_greenLED = 0;
198 setStateGreenLED(state);
218 flag_flash_greenLED = 1;
219 on_count_greenLED = on_count;
220 off_count_greenLED = off_count;
239 flag_flash_redLED = 1;
240 on_count_redLED = on_count;
241 off_count_redLED = off_count;
276 LPC_TMR32B0->IR=0x08;
278 if(flag_flash_redLED == 1)
281 if(redLED_count < on_count_redLED ) setStateRedLED(1);
282 else setStateRedLED(0);
283 if( (on_count_redLED + off_count_redLED) < redLED_count ) redLED_count = 0;
288 if(flag_flash_greenLED == 1)
290 if(greenLED_count < on_count_greenLED ) setStateGreenLED(1);
291 else setStateGreenLED(0);
292 if( (on_count_greenLED + off_count_greenLED) < greenLED_count ) greenLED_count = 0;
296 elapsed_time_count ++;
299 else leftSW_count = 0;
303 else rightSW_count = 0;
307 voltageLipo = (float)(ad_val[1])/1024.0 * 3.0 * 2.0;
308 voltageMotor = (float)(ad_val[0])/1024.0 * 3.0 * 2.0;
uint8_t getStateLeftSW(void)
float getLipoVoltage(void)
float getMotorVoltage(void)
void resetElapsedTime(void)
int myPrintfUART(const char *fmt,...)
void flashGreenLED(uint16_t on_count, uint16_t off_count)
CMSIS Cortex-M3 Core Peripheral Access Layer Header File.
void turnRedLED(uint8_t state)
uint8_t getStateRightSW(void)
uint16_t getRightSWcount(void)
void turnGreenLED(uint8_t state)
void TIMER32_0_IRQHandler(void)
void flashRedLED(uint16_t on_count, uint16_t off_count)
uint32_t getElapsedTime(void)
void startTimer32_0(void)
void storeAD2Array(int16_t *ad_value)
unsigned short int uint16_t
uint16_t getLeftSWcount(void)