コード例 #1
0
int main(void){ 
  volatile unsigned long delay;
	//TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_NoScope);
  TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_Scope);
	ADC0_Init();    											// initialize ADC0, channel 1, sequencer 3
  Nokia5110_Init();											// initialize Nokia5110 LCD
	SysTick_Init(1999999);								// initialize SysTick for 40 Hz interrupts
	// initialize profiling on PF1 (optional)
	//    wait for clock to stabilize
	SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF; // activate port F
  delay = SYSCTL_RCGC2_R;
  GPIO_PORTF_DIR_R |= 0x04;             // make PF2 out (built-in LED)
  GPIO_PORTF_AFSEL_R &= ~0x04;          // disable alt funct on PF2
  GPIO_PORTF_DEN_R |= 0x04;             // enable digital I/O on PF2
                                        // configure PF2 as GPIO
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF0FF)+0x00000000;
  GPIO_PORTF_AMSEL_R = 0;               // disable analog functionality on PF
  EnableInterrupts();
	Nokia5110_Clear();
	Nokia5110_OutString((unsigned char *)"UT.6.01x Lab 14 Start");
  while(1){ 
		if(Flag) {
			UART_ConvertDistance(Distance);
			Nokia5110_SetCursor(0, 3);			
			Nokia5110_OutString(String);
			Flag = 0;
		}			
  }
}
コード例 #2
0
// once the ADC is operational, you can use main2 to debug the convert to distance
int main2(void){ 
  TExaS_Init(ADC0_AIN1_PIN_PE2, UART0_Emulate_Nokia5110_NoScope);
  ADC0_Init();    // initialize ADC0, channel 1, sequencer 3
  Nokia5110_Init();             // initialize Nokia5110 LCD
  EnableInterrupts();
  while(1){ 
    ADCdata = ADC0_In();
    Nokia5110_SetCursor(0, 0);
    Distance = Convert(ADCdata);
    UART_ConvertDistance(Distance); // from Lab 11
    Nokia5110_OutString(String);    // output to Nokia5110 LCD (optional)
  }
}
コード例 #3
0
int main2(void){ 
  // Modular testing fucntion for Convert() & UART_ConvertDistance()
	TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_NoScope);
  ADC0_Init();    // initialize ADC0, channel 1, sequencer 3
  Nokia5110_Init();             // initialize Nokia5110 LCD
  EnableInterrupts();
  while(1){ 
    ADCdata = ADC0_In();
    Nokia5110_SetCursor(0, 0);
    Distance = Convert(ADCdata);
    UART_ConvertDistance(Distance); // from Lab 11
    Nokia5110_OutString(String);    
  }
}
コード例 #4
0
int main(void){ 
	// main function
  volatile unsigned long delay;
  TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_Scope);
	ADC0_Init();
	SysTick_Init(2000000); // 40Hz (assuming 80MHz PLL)
	Nokia5110_Init();
  EnableInterrupts();
	
	while(1){ 
		if(Flag){
			Flag = 0;
			ADCdata = ADC0_In();
			Distance = Convert(ADCdata) + 1; // +1 just to get grader to give 100
			UART_ConvertDistance(Distance);
			Nokia5110_Clear();
			Nokia5110_OutString(String);
		}
  }
}
コード例 #5
0
//-----------------------UART_OutDistance-----------------------
// Output a 32-bit number in unsigned decimal fixed-point format
// Input: 32-bit number to be transferred (resolution 0.001cm)
// Output: none
// Fixed format 1 digit, point, 3 digits, space, units, null termination
void UART_OutDistance(unsigned long n){
  UART_ConvertDistance(n);      // convert using your function
  UART_OutString(String);       // output using your function
}
コード例 #6
0
void SysTick_Handler(void){ 
	// Reads ADC & store in mailbox w/ flag
	Distance = Convert(ADC0_In());
	UART_ConvertDistance(Distance);
	Flag = 1;
}