int main(void){
  TExaS_Init();         // Bus clock is 80 MHz 
  ST7735_InitR(INITR_REDTAB); 
  PortF_Init();
  ADC_Init();         // turn on ADC, set channel to 1
  SysTick_Init();			//Initialize SysTick
  for(;;){
	  while(ADCStatus == 0){}	//Poll ADCStatus flag 
	  uint32_t x = ADCMail;		//read ADCMail (input)
	  ADCStatus = 0;			//clear flag
	  x = Convert(x);			//convert the input
	  ST7735_SetCursor(1,7);		
    ST7735_OutString("D = "); 	//print "D = "
    ST7735_SetCursor(5,7);
    LCD_OutFix(x);				// print the fixed point value 
		ST7735_SetCursor(10,7);	
		ST7735_OutString(" cm");	// print " cm"
		/////////////////////
		ST7735_SetCursor(1,2);
			ST7735_OutString("Lab 8:");	
		ST7735_SetCursor(1,3);
		ST7735_OutString("Measurment of");
		ST7735_SetCursor(1,4);
		ST7735_OutString("Distance :)");
		
			
	}
	
}
Ejemplo n.º 2
0
int main(void){uint32_t i;
  PLL_Init(Bus80MHz);
  PortF_Init();
  ST7735_InitR(INITR_REDTAB);
  while(1){
    ST7735_FillScreen(0);  // set screen to black
    ST7735_SetCursor(0,0);
    printf("Lab 1\rST7735_sDecOut3\r");
    for(i=0; i<13; i++){
      ST7735_sDecOut3(outTests1[i].InNumber);  // your solution
      ST7735_OutString((char*)outTests1[i].OutBuffer); // expected solution
    }
    //Pause();
  
    ST7735_FillScreen(0);  // set screen to black
    ST7735_SetCursor(0,0);
    printf("ST7735_uBinOut8\r");
    for(i=0; i<14; i++){
      ST7735_uBinOut8(outTests2[i].InNumber);  // your solution
      ST7735_OutString((char*)outTests2[i].OutBuffer); // expected solution
    }
    //Pause();
    
    ST7735_XYplotInit("Circle",-2500, 2500, -2500, 2500);
    ST7735_XYplot(180,(int32_t *)CircleXbuf,(int32_t *)CircleYbuf);
    //Pause();
    
    ST7735_XYplotInit("Star- upper right",-450, 150, -400, 200);
    ST7735_XYplot(50,(int32_t *)StarXbuf,(int32_t *)StarYbuf);
    Pause(); 
  } 
} 
Ejemplo n.º 3
0
//  Subroutines Section
int main(void){
  PortB_Init();        								// Initialize microcontroller ports
  PortE_Init();	
 	PortF_Init();
	while(1){
		SW2 = GPIO_PORTF_DATA_R&0x01;			// Defines on-board button as SW2

		if(SW2 == 0x00 && before == 0){		// If SW2 is pressed and wasn't pressed in 
			if(count <= 9998){								// previous loop cycle. Prevents counter from
				count++;											// increasing when button is held down.
				before = 1;
			}
			else{														// Reset counter at 9999
				count = 0;
			}
		}
		
		if(SW2 == 0x01){									// If button isn't pressed
			before = 0;
		}
		
		NumSplit(count);									// Split value in counter into 4 numbers
		Display(1,digit1);								// Display number for lowest digit
		Display(2,digit2);			
		Display(4,digit3);
		Display(8,digit4);					
  }
}
Ejemplo n.º 4
0
int main(void){
//Initialize all below:
	TExaS_Init();       // Bus clock is 80 MHz 
	ADC_Init();    			// initialize to sample ADC1
	ST7735_InitR(INITR_REDTAB);
	SysTick_Init();		
	UART_Init();
	FiFo_Init();
  PortF_Init();
	EnableInterrupts();
	
	while(1){
		while(ADCStatus == 0){};	//Poll ADCStatus flag 
		ADCStatus = 0;						//clear flag
		//Prints from a full FIFO --> BUT must know when 
		//we get to the end 			--> uses while loop to check this condition,
		//and a for loop to print 5 times
		ST7735_SetCursor(6,5);
		//Infinite loop if the fifo is empty / if returns fail
		while (FiFo_Get(&data) == 0) {};
		FiFo_Get(&data);
		for(int i = 1; i <= 5; i++){
			ST7735_OutChar(data);
			FiFo_Get(&data);
		}
		FiFo_Get(&data);
		FiFo_Get(&data);		
		ST7735_SetCursor(12,5);
		ST7735_OutString(" cm");	// print " cm"
	}

}
Ejemplo n.º 5
0
int main5(void){ 
  PortF_Init();
  while(1){
    DelayWait10ms(100);
    PF2 ^= 0x04;
  }
}
Ejemplo n.º 6
0
int main(void){ 
	unsigned long volatile delay;
	unsigned long In;
  TExaS_Init(SW_PIN_PF4, LED_PIN_PF2);  // activate grader and set system clock to 80 MHz
  // initialization goes here
	PortF_Init();
  EnableInterrupts();           // enable interrupts for the grader
	
	GPIO_PORTF_DATA_R = 0x04;
	
  while(1){
    // body goes here	
		Delay100ms(1);
		In = GPIO_PORTF_DATA_R&0x10;
		if(In == 0x00)
		{
			//Switch is pressed toggel PF2
			GPIO_PORTF_DATA_R = GPIO_PORTF_DATA_R ^ (1 << 2);
		}
		else
		{
			//Switch is not pressed, set PF2 to on
			GPIO_PORTF_DATA_R = 0x04;
		}
  }
}
Ejemplo n.º 7
0
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  TExaS_Init(SW_PIN_PF40, LED_PIN_PF31,ScopeOn);  // activate grader and set system clock to 80 MHz
  PortF_Init();                            // Init port PF4 PF3 PF1    
  EnableInterrupts();                      // enable interrupts for the grader  
  while(1){  
     SetReady();
		WaitForASLow();
		ClearReady();
		Delay1ms(10);
		WaitForASHigh();
		Delay1ms(250);
		SetVT();
		Delay1ms(250);
		ClearVT();
      		
		// Follows the nine steps list above
    // a) Ready signal goes high
    // b) wait for switch to be pressed
    // c) Ready signal goes low
    // d) wait 10ms
    // e) wait for switch to be released
    // f) wait 250ms
    // g) VT signal goes high
    // h) wait 250ms
    // i) VT signal goes low
  }
}
Ejemplo n.º 8
0
int main(void){  unsigned long i,last,now, SW1, SW2;
  TExaS_Init(SW_PIN_PF40, LED_PIN_PF1);  // activate grader and set system clock to 16 MHz
  PortF_Init();   // initialize PF1 to output
  SysTick_Init(); // initialize SysTick, runs at 16 MHz
  i = 0;          // array index
  last = NVIC_ST_CURRENT_R;
  EnableInterrupts();           // enable interrupts for the grader
  while(1){
		
		SW1= GPIO_PORTF_DATA_R & 0x01;
		SW2= GPIO_PORTF_DATA_R & 0x10;
		
		if(!SW1 || !SW2)
		{
		Led = GPIO_PORTF_DATA_R;   // read previous
    Led = Led^0x02;            // toggle red LED
    GPIO_PORTF_DATA_R = Led;   // output 
    if(i<50){
      now = NVIC_ST_CURRENT_R;
      Time[i] = (last-now)&0x00FFFFFF;  // 24-bit time difference
      //Data[i] = GPIO_PORTF_DATA_R&0x02; // record PF1
			Data[i] = GPIO_PORTF_DATA_R&0x13; // record PF1
      last = now;
      i++;
    }
    Delay();
		}
		else
		{
			GPIO_PORTF_DATA_R &=~0x02 ;   // output 
		}
  }
}
Ejemplo n.º 9
0
int main(void)
{
	PortF_Init();

	while(1)
	{
	}
}
Ejemplo n.º 10
0
int main1(void){
	TExaS_Init();
	ADC_Init();         // turn on ADC, set channel to 1
	ST7735_InitR(INITR_REDTAB); 
  PortF_Init();
	SysTick_Init();			// This makes things work
	UART1_Init();
	while(1){}					// do-nothing loop
}
Ejemplo n.º 11
0
int main(void) {
	// initialize PLL
	PLL_Init_50MHz();
	// initialize 
	SysTick_Init();
	// initialize PortF
	PortF_Init();
	while(1) {
		WaitForInterrupt();
	}
}
Ejemplo n.º 12
0
int main(void){  
  PortF_Init();  // make PF1 out (PF1 built-in LED)
  while(1){
    Led = GPIO_PORTF_DATA_R;   // read previous
    //Led = Led^0x02;            // toggle red LED, PF1
	//Led = Led^0x04;            // toggle blue LED, PF1
	//Led = Led^0x08;            // toggle green LED, PF1
	Led = Led^0x0A;            // toggle yellow LED, PF1
    GPIO_PORTF_DATA_R = Led;   // output 
    Delay();
  }
}
Ejemplo n.º 13
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
		}
  }
}
Ejemplo n.º 14
0
int main(void){
    OS_Init();
    PortF_Init();
		Timer5_Init();
//    SW1_Init(&SW1Press,3);
//    SW2_Init(&SW2Press,3);
    PC6_Init(&PC6High,3);
    PC7_Init(&PC7High,3);
    OS_AddThread(&IdleTask, 128, 7);
    OS_Launch(TIMESLICE);
    return 0;
}
Ejemplo n.º 15
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);
  }
}
Ejemplo n.º 16
0
int main(void)
{
	//char myString[6];
  PLL_Init_50MHz();
  UART5_Init(); // initialize UART
	PortF_Init();
	GPIO_PORTF_DATA_R = 0x00;
	UART5_WriteString("r - turn Red LED on");
	OutCRLF();
	UART5_WriteString("b - turn Blue LED on");
	OutCRLF();
	UART5_WriteString("g - turn Green LED on");
	OutCRLF();
	UART5_WriteString("Please input a character: ");
	OutCRLF();
	for(;;)
	{
		// UART_WrtieString 
		/*
		UART_WriteString("Please input a string (max length 5): ");
		UART_ReadString(myString, 5);
		UART_WriteString(" OutString= ");
		UART_WriteString(myString);
		OutCRLF();
		*/
		if (UART5_Available())
		{
			unsigned char recvChar = UART5_ReadChar();
			UART5_WriteString("Received Char: ");
			UART5_WriteChar(recvChar);
			OutCRLF();
			switch (recvChar)
			{
				case 'r':
					// red
					GPIO_PORTF_DATA_R = 0x02;
					break;
				case 'b':
					// blue
					GPIO_PORTF_DATA_R = 0x04;
					break;
				case 'g':
					// green
					GPIO_PORTF_DATA_R = 0x08;
					break;
				default:
					GPIO_PORTF_DATA_R = 0x00;
					break;
			}
		}
	}
}
Ejemplo n.º 17
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;
    }
  }
}
Ejemplo n.º 18
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
    }
  }
}
int main(void){ 
  TExaS_Init(SW_PIN_PE210, LED_PIN_PB543210,ScopeOff); // activate grader and set system clock to 80 MHz
// TExaS_Scope();
  PortF_Init();   // initialize PF1 to output
  SysTick_Init(); // initialize SysTick, runs at 16 MHz
  EnableInterrupts();
	cstate=0;
  while(1){
     GPIO_PORTB_DATA_R=fsm[cstate].out;
		 GPIO_PORTF_DATA_R=fsm[cstate].out1;
		 systick_wait10ms(fsm[cstate].wait);
		input=(GPIO_PORTE_DATA_R&0x07);
		cstate=fsm[cstate].next[input];
  }
}
Ejemplo n.º 20
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){
    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
  }
}
int main2(void){
  TExaS_Init();       // Bus clock is 80 MHz 
  ADC_Init();         // turn on ADC, set channel to 1
  PortF_Init();
	ST7735_InitR(INITR_REDTAB); 
  while(1){           // use scope to measure execution time for ADC_In and LCD_OutDec           
    PF2 = 0x04;       // Profile ADC
    Data = ADC_In();  // sample 12-bit channel 1
    PF2 = 0x00;       // end of ADC Profile
    ST7735_SetCursor(0,0);
    PF1 = 0x02;       // Profile LCD
    LCD_OutDec(Data); 
    ST7735_OutString("    ");  // these spaces are used to coverup characters from last output
    PF1 = 0;          // end of LCD Profile
  }
}
Ejemplo n.º 22
0
int main(void)
{
	PortF_Init();

	// Loop
	while(1)
	{
		In = GPIO_PORTF_DATA_R & 0x10; // Read PORTF 4 (left button)
		if (In==0){
			GPIO_PORTF_DATA_R = LED_BLUE; // Turn on LED BLUE
		}
		else {
			GPIO_PORTF_DATA_R = LED_RED; // Turn on LED RED
		}
	}
}
Ejemplo n.º 23
0
int main(void){
	
  PLL_Init(Bus80MHz);                   // 80 MHz
	DisableInterrupts();
  //ADC0_InitSWTriggerSeq3_Ch9();         // allow time to finish activating
  Timer0A_Init100HzInt();               // set up Timer0A for 100 Hz interrupts
	Timer1_Init();
	Display_Init();						//initialize display
	Timer2_Init1Hz();		
	PortF_Init(); //initialize portf with onboard switches
	PortE_Init(); // initialize port e as breadboard switches.
	
  EnableInterrupts();

  while(1){

	}
}
Ejemplo n.º 24
0
int main(void){
  TExaS_Init();
	ST7735_InitR(INITR_REDTAB); 
  PortF_Init();
  ADC_Init();         // turn on ADC, set channel to 1
	SysTick_Init();			// This makes things work
  // your Lab 8
  while(1){
		while(ADCStatus == 0){}
		Data = ADCMail;
		Position = Convert(Data); 
		ST7735_SetCursor(0,0);
    LCD_OutDec(Data); ST7735_OutString("    "); 
    ST7735_SetCursor(6,0);
    LCD_OutFix(Position);
		ADCStatus = 0;
  }
}
Ejemplo n.º 25
0
int main(void){
	
	unsigned long i = 0;                                 //array index
	unsigned long switches;   //PortF  00010001
	unsigned long data;
	unsigned long prevdata;   //PortF  00010011
	unsigned long last = NVIC_ST_CURRENT_R;
	unsigned long now;                          //current time
  TExaS_Init(SW_PIN_PF40, LED_PIN_PF1);  // activate grader and set system clock to 16 MHz
  PortF_Init();   // initialize PF1 to output
  SysTick_Init(); // initialize SysTick, runs at 16 MHz
  
  EnableInterrupts();           // enable interrupts for the grader
	
	prevdata = GPIO_PORTF_DATA_R & 0x13;          //Port F 00010011 getState


  while(1){
 //   Led = GPIO_PORTF_DATA_R;       // read previous
		
    switches = GPIO_PORTF_DATA_R & 0x11;   //PortF  00010001

		if (switches == 0x011)            //nothing pressed, negative logic
				GPIO_PORTF_DATA_R &= ~0x02;  //NOT Led
		else
			  GPIO_PORTF_DATA_R ^= 0x02;   //otherwise toggle LED
		
		
 //   Led = Led^0x02;            // toggle red LED
 //   GPIO_PORTF_DATA_R = Led;   // output 
		
		data = GPIO_PORTF_DATA_R & 0x13;
		
    if(i<50 && data != prevdata){
      now = NVIC_ST_CURRENT_R;
      Time[i] = (last-now)&0x00FFFFFF;  // 24-bit time difference
      Data[i] = data;// GPIO_PORTF_DATA_R&0x13; // record PF 00010011
      last = now;
      i++;
    }
		prevdata = data;
    Delay();
  }
}
Ejemplo n.º 26
0
// ***** Main function *****
int main(void){  
	// Variables
	unsigned long i = 0; // array index for Time & Data
	unsigned long sws; // current SW1 & SW2
	unsigned long data; // current PF0,PF1 & PF4
	unsigned long prevdata; // previous PF0, PF1 & PF4
	unsigned long last = NVIC_ST_CURRENT_R; // time of last data dump
	unsigned long now; // current time

	// Initialisation
	TExaS_Init(SW_PIN_PF40, LED_PIN_PF1);  // activate grader and set system clock to 80 MHz
  PortF_Init();   // initialize PF1 to output
  SysTick_Init(); // initialize SysTick, runs at 16 MHz
  EnableInterrupts();           // enable interrupts for the grader
	prevdata = GPIO_PORTF_DATA_R & 0x13;
	
  while(1){
		// Main function
			// Flicker LED is either SW1 pressed
			// Else turn LED off
		sws = GPIO_PORTF_DATA_R & 0x11;
		if(sws == 0x011)
			GPIO_PORTF_DATA_R &= ~0x02;
		else
			GPIO_PORTF_DATA_R ^= 0x02;
	
		// Data dump
			// Record PF0,PF1 & PF4 if any of them change
			// Only 50 earliest dumps
		data = GPIO_PORTF_DATA_R & 0x13;
    if(i<50 && data != prevdata){
      now = NVIC_ST_CURRENT_R;
      Time[i] = (last-now)&0x00FFFFFF;  // 24-bit time difference
      Data[i] = data;
      last = now;
			prevdata = data;
      i++;
		}
		
		// Flicker at 10Hz
		Delay(); 
  }
}
int main3(void){ 
  TExaS_Init();         // Bus clock is 80 MHz 
  PortF_Init();
  ADC_Init();         // turn on ADC, set channel to 1
	ST7735_InitR(INITR_REDTAB); 
  while(1){  
    PF2 ^= 0x04;      // Heartbeat
    Data = ADC_In();  // sample 12-bit channel 1
    PF3 = 0x08;       // Profile Convert
    Position = Convert(Data); 
    PF3 = 0;          // end of Convert Profile
    PF1 = 0x02;       // Profile LCD
    ST7735_SetCursor(0,0);
    LCD_OutDec(Data); ST7735_OutString("    "); 
    ST7735_SetCursor(6,0);
    LCD_OutFix(Position);
    PF1 = 0;          // end of LCD Profile
  }
}
Ejemplo n.º 28
0
void IO_Init( void )
{
	busSpeedPLL();
	PortF_Init();
	PortE_Init();
	PortD_Init();
	PortC_Init();

//  ADC0_InitSWTriggerSeq3_Ch1();
//	SysTick_Init_ms( 1 );
//  UART_Init_16MHz();
//	Nokia5110_Init();
//  Nokia5110_PrintBMP( 0, 47, jwrp, 0 );
// 	Nokia5110_DisplayBuffer();
//	SysTickWaitBusy( 3 );

//	Nokia5110_PrintBMP( 0, 47, cruzamento, 0 );
// 	Nokia5110_DisplayBuffer();
}
Ejemplo n.º 29
0
//debug code
int main(void){ 
	DisableInterrupts();
  PLL_Init(Bus80MHz);								// bus clock at 50 MHz
	PortF_Init();
  LEDS = 0;													// turn all LEDs off
	DAC_Init(0);
	Buttons_Init();
	SysTick_Init();
	//Timer0A_Init(&Song_PlayHandler, F20KHZ);	// initialize timer0A (20,000 Hz)
  Timer0A_Init(&Song_PlayHandler, F16HZ);		// initialize timer0A (16 Hz)
  EnableInterrupts();
	
	Song_PlayInit(Prelude);
	Pause();

  while(1){
		LEDS ^= RED;
		for(int i = 0; i < 1000000; i += 1);
  }
}
Ejemplo n.º 30
0
int main(void){
	PLL_Init();
	SysTick_Init();
	PortF_Init();
	
	GPIO_PORTF_DATA_R &= ~(1<<1);
	GPIO_PORTF_DATA_R |= (1<<0);
	GPIO_PORTF_DATA_R &= ~(1<<2);
	GPIO_PORTF_DATA_R |= (1<<4);
	
	/*GPIO_PORTF_DATA_R |= (1<<1);          // 5) PF4,PF0 input, PF3,PF2,PF1 output
	SysTick_Wait10ms(1);
	GPIO_PORTF_DATA_R &= ~(1<<1);          // 5) PF4,PF0 input, PF3,PF2,PF1 output
	SysTick_Wait10ms(30);
	GPIO_PORTF_DATA_R |= (1<<2);	// 5) PF4,PF0 input, PF3,PF2,PF1 output
	SysTick_Wait10ms(1);
	GPIO_PORTF_DATA_R &= ~(1<<2);          // 5) PF4,PF0 input, PF3,PF2,PF1 output
*/
	while(1);
}