int main(void) { PortFInit(); while (1) { if ( (GPIO_DATA & (1 << PF4)) != 0 ) { GPIO_DATA |= (1 << PF2); } else { GPIO_DATA &= ~(1 << PF2); } } }
int main(void) { // Setup // initialize the TExaS grader lab 2 TExaS_Init(SW_PIN_PF40, LED_PIN_PF321); PortFInit(); // initialize port F EnableInterrupts(); // the grader uses interrupts // Loop while (1) { switch_input = GPIO_PORTF_DATA_R & 0x10; // read PF4 into switch if (!switch_input) { // zero means SW1 is pressed GPIO_PORTF_DATA_R = 0x08; // LED is green } else { // 0x10 means SW1 is not pressed GPIO_PORTF_DATA_R = 0x02; // LED is red } Delay(); // wait 0.1 sec GPIO_PORTF_DATA_R = 0x04; // LED is blue Delay(); // wait 0.1 sec } }