int main(void){ uint32_t status; PortF_Init(); // initialize PF0 and PF4 and make them inputs // make PF3-1 out (PF3-1 built-in LEDs) while(1){ status = PortF_Input(); switch(status){ // switches are negative logic on PF0 and PF4 case 0x01: PortF_Output(BLUE); break; // SW1 pressed case 0x10: PortF_Output(RED); break; // SW2 pressed case 0x00: PortF_Output(GREEN); break; // both switches pressed case 0x11: PortF_Output(0); break; // neither switch pressed } } }
/*--------------------------------------------------*- switches_led() if SW1 is pressed light Blue led if SW2 is pressed light Green led if both switches are pressed light Red led -*--------------------------------------------------*/ void switches_leds(void){ while(1){ /*Read buttons*/ status = PortF_Input((SW2 | SW1));//this can accept 1 or more parameters switch (status){ /*Note logic inversed 0 = switch pressed*/ case 0x00: PORTF_PORT = LED_RED;break; case 0x01: PORTF_PORT = LED_BLUE;break; case 0x10: PORTF_PORT = LED_GREEN;break; case 0x11: PORTF_PORT = 0x00;break; } } }