Example #1
0
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
    }
  }
}
Example #2
0
void GPIOPortD_Handler(void) {
	
	PortF_Output(GPIO_PORTF_DATA_R ^= RED);
	
	// PUSH 
	__asm("mov r2, #5");
	
	// ACK INTERRUPT
	GPIO_PORTD_ICR_R = 0x08;
}
Example #3
0
int main(void){ 
	SysTick_Init(); // initialize SysTick timer, see SysTick.c
  Switch_Init();      // initialize PF0 and PF4 and make them inputs
  EnableInterrupts(); // I=0
			
	//__set_BASEPRI(5<<5);
	
  while(1){
		set_reg();
		if(SW1){
			elapsed = (before-NVIC_ST_CURRENT_R)&0x00FFFFFF;
			SW1=0;  // Mark it as read
			PortF_Output(GPIO_PORTF_DATA_R | 0x04); // Turn Blue LED (PF2) ON
		}
		if (SW2){
			elapsed = (before-NVIC_ST_CURRENT_R)&0x00FFFFFF;
			SW2=0;
			PortF_Output(0x00); // Turn Red LED (PF1) OFF
		}
  }
}
Example #4
0
int main(void){  
  PLL_Init();
  SYSCTL_RCGCGPIO_R |= 0x20;   // activate port F
  while((SYSCTL_PRGPIO_R&0x0020) == 0){};// ready?
  GPIO_PORTF_DIR_R |= 0x04;    // make PF2 out (PF2 built-in LED)
  GPIO_PORTF_AFSEL_R &= ~0x04; // regular port function
  GPIO_PORTF_DEN_R |= 0x04;    // enable digital I/O on PF2
                               // configure PF4 as GPIO
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFF0FFFF)+0x00000000;
  GPIO_PORTF_AMSEL_R = 0;      // disable analog functionality on PF
  while(1){
		status = GPIO_PORTF_DATA_R;
		
		if( status & 0x04 ) {
			PortF_Output(0);
		} else {
			PortF_Output(BLUE);
		}
		
		delay_asm(1000000);
		
    //Delay(1000000);           // delay ~0.5 sec at 80 MHz
  }
}