Example #1
0
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  PortF_Init(); // Init port PF4 PF2 PF0    
  while(1){
    do{
      SW1 = GPIO_PORTF_DATA_R&0x10; // PF4 into SW1
    }while(SW1 == 0x10);
    do{
      FlashSOS();
		  SW2 = GPIO_PORTF_DATA_R&0x01; // PF0 into SW2
		}while(SW2 == 0x01);
  }
}
Example #2
0
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  TExaS_Init(SW_PIN_PF40, LED_PIN_PF321);  // activate grader and set system clock to 80 MHz
  PortF_Init(); // Init port PF4 PF2 PF0    
  EnableInterrupts();           // enable interrupts for the grader
  while(1){
		SW1_2 = GPIO_PORTF_DATA_R&0x11;
		while (SW1_2==0){
      FlashSOS();
		  SW1_2 = GPIO_PORTF_DATA_R&0x11; // PF0 into SW1 and SW2
		}
  }
}
Example #3
0
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  TExaS_Init(SW_PIN_PF40, LED_PIN_PF321);  // activate grader and set system clock to 80 MHz
  PortF_Init(); // Init port PF4 PF2 PF0    
  EnableInterrupts();           // enable interrupts for the grader
  while(1){
    SW1 = GPIO_PORTF_DATA_R&0x11; // PF0, PF4 into SW1
    if (SW1 == 0x00) {
      FlashSOS();
    } else {
      GPIO_PORTF_DATA_R &= ~0x0E;
    }
  }
}
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  TExaS_Init(SW_PIN_PF40, LED_PIN_PF321);  // activate grader and set system clock to 80 MHz
  PortF_Init(); // Init port PF4 PF2 PF0    
  EnableInterrupts();           // enable interrupts for the grader
  while(1){
    do{ //do this while either SW1 or SW2 is NOT pressed
      SW1 = GPIO_PORTF_DATA_R&0x10; // PF4 into SW1
			SW2 = GPIO_PORTF_DATA_R&0x01; //PF0 into SW2
    }while(SW1 == 0x10 || SW2 == 0x01); //either switch is not pressed
    do{ //do this while SW1 and SW2 BOTH are pressed
      FlashSOS();
      SW1 = GPIO_PORTF_DATA_R&0x10; // PF4 into SW1
		  SW2 = GPIO_PORTF_DATA_R&0x01; // PF0 into SW2
		}while(SW1 == 0x00 && SW2 == 0x00); //both switches pressed
  }
}
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  unsigned long SOS;
  
  while(1){
    SW1 = GPIO_PORTF_DATA_R&0x10; // read PF4 into SW1
    if (SW1) { //SW1 is Not pressed: SW1 is 1 (Negative logic)
      SOS = 0;
    } else {
      SOS = 1;
    }
    while (SOS == 1) {
      FlashSOS();
      delay(10); // Delay for 5 secs in between flashes
      SW2 = GPIO_PORTF_DATA_R&0x01; // read PF0 into SW2
      if (!SW2) { //SW1 is Pressed: SW2 is 0 (Negative logic)
        SOS = 0;
        GPIO_PORTF_DATA_R &= ~0x08; //turn LED off
      }
    }
  }
}