Exemple #1
0
//Runs a test of the switches
//switches_read() will run until all switches are in the UP position.
//Masking is used to determine which switches are in the UP position.
//When all switches are on the on position, the LED's are turned off.
void switches_runTest()
{
    switches_init();
    u32 read = switches_read();
    while(read  != HEX_F)
    {
        read = switches_read();
        char result = read & HEX_F;
        leds_write(result);
    }
    leds_write(0);

}
// Standard tick function.
void hitLedTimer_tick() {
	//State actions
	switch(hitLedState) {
		case idle_st:
			break;
		case run_on_st:
			break;
		case run_off_st:
			break;
		}
	//Transition State conditions
	switch(hitLedState) {
		case idle_st:
			// hitLedRunning acts as the enable for state machine
			if(hitLedRunning) {
				hitLedState = run_on_st;
				leds_write(HITLED_ACTIVATE);	// hitLed turns on
				hitLedRunning = true;
			}
			break;
		case run_on_st:
			if(timerCount >= HITLED_PERIOD) {
				hitLedState = run_off_st;
				timerCount =0;
				leds_write(ALL_LEDS_OFF);
				mio_writePin(LED_OUTPUT_PIN, 1);  //off

				hitLedRunning = false;
			}
				timerCount++;

			break;
		case run_off_st: {
			if(timerCount >= HITLED_PERIOD) {
				hitLedState = idle_st;
				timerCount =0;
				leds_write(ALL_LEDS_OFF);
				mio_writePin(LED_OUTPUT_PIN, 0);

				hitLedRunning = false;
			}
				timerCount++;

			break;
			}
	}

}
Exemple #3
0
void switches_runTest()
{
    //initialize the LEDS
    leds_init(0);

    //initalize the switches, aka turn off tristate
    switches_init();


    int32_t switchValue = 0;

    //while not all the swtiches are up, continue to test
    //we mask the switchValue with all switches so we just see those bits
    while ((switchValue & SWITCHES_ALL_SWITCHES_ON) != SWITCHES_ALL_SWITCHES_ON)
    {
        switchValue = switches_read();
        //if switch0, led 0 on
        if ((switchValue & SWITCHES_SW0) == SWITCHES_SW0)
        {
            leds_write(SWITCHES_SW0); // this might cause problem, because it specifically turns off the other LEDS
        }
        //if switch1, led 1 on
        if ((switchValue & SWITCHES_SW1) == SWITCHES_SW1)
        {
            leds_write(SWITCHES_SW1); // this might cause problem, because it specifically turns off the other LEDS
        }
            //if switch2, led 2 on
        if ((switchValue & SWITCHES_SW2) == SWITCHES_SW2)
        {
            leds_write(SWITCHES_SW2); // this might cause problem, because it specifically turns off the other LEDS
        }
            //if switch3, led 3 on
        if ((switchValue & SWITCHES_SW3) == SWITCHES_SW3)
        {
            leds_write(SWITCHES_SW3); // this might cause problem, because it specifically turns off the other LEDS
        }
        else //no LEDS on
        {
            //when we put a switch down, turn off that LED
            leds_write(0);
        }
    }
    //turn off all LEDS, test is over
    leds_write(0);
}