Пример #1
0
int main(void){
	Output_Init();
//	ST7735_XYplotInit("Temp", 0, 100, 0, 100);
  PLL_Init(Bus80MHz);                   // 80 MHz
  SYSCTL_RCGCGPIO_R |= 0x20;            // activate port F
  ADC0_InitSWTriggerSeq3_Ch9();         // allow time to finish activating
  Timer0A_Init100HzInt();               // set up Timer0A for 100 Hz interrupts
	GPIO_PORTF_DIR_R |= 0x06;             // make PF2, PF1 out (built-in LED)
  GPIO_PORTF_AFSEL_R &= ~0x06;          // disable alt funct on PF2, PF1
  GPIO_PORTF_DEN_R |= 0x06;             // enable digital I/O on PF2, PF1
                                        // configure PF2 as GPIO
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF00F)+0x00000000;
  GPIO_PORTF_AMSEL_R = 0;               // disable analog functionality on PF
  PF2 = 0;                      // turn off LED
	EnableInterrupts();
	ST7735_SetCursor(6,0);
	printf("C");
	ST7735_SetCursor(13,0);
	printf("ADC");
  while(1){
    PF1 ^= 0x02;  // toggles when running in main
		temperature = adcToTemp(ADCvalue);
		ST7735_SetCursor(0,0);
		ST7735_sDecOut2(temperature);
		ST7735_SetCursor(9,0);
		ST7735_OutUDec(ADCvalue);
  }	
}
Пример #2
0
int main(void){  
	char* lab9greeting = "Welcome to Lab 9!";
	int temp;
//	int Temperature = 100;
//  DisableInterrupts();
//  PLL_Init(Bus80MHz);
//	//ST7735_InitR(INITR_REDTAB);
//  Output_Init();       // UART0 only used for debugging
//	ST7735_Output_Init(); 
//	ADC0_InitSWTriggerSeq3_Ch9(); //initialize the ADC
//	Timer0A_Init20HzInt(); //initialize the timer
//	ST7735_DrawString(0,0, lab9greeting, ST7735_WHITE);
//	EnableInterrupts();
	
	PLL_Init(Bus80MHz);                   // 80 MHz
  SYSCTL_RCGCGPIO_R |= 0x20;            // activate port F
  ADC0_InitSWTriggerSeq3_Ch9();         // allow time to finish activating
  Timer0A_Init20HzInt();               // set up Timer0A for 100 Hz interrupts
  GPIO_PORTF_DIR_R |= 0x06;             // make PF2, PF1 out (built-in LED)
  GPIO_PORTF_AFSEL_R &= ~0x06;          // disable alt funct on PF2, PF1
  GPIO_PORTF_DEN_R |= 0x06;             // enable digital I/O on PF2, PF1
                                        // configure PF2 as GPIO
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF00F)+0x00000000;
  GPIO_PORTF_AMSEL_R = 0;               // disable analog functionality on PF
  PF2 = 0;                      // turn off LED
	ST7735_Output_Init();
	ST7735_DrawString(0,0, lab9greeting, ST7735_WHITE);
	//Init_Plot();
	
	//ST7735_SetCursor(0,0); ST7735_OutString("Lab 9");
 ST7735_PlotClear(1000,4000);  // range from 0 to 4095
 ST7735_SetCursor(0,1); ST7735_OutString("N=");
 ST7735_SetCursor(0,2); ST7735_OutString("T="); //ST7735_DecOut2(2500);
                        ST7735_OutString(" C");
  EnableInterrupts();
	
  while(1){
						ST7735_SetCursor(3,1); ST7735_OutUDec(ADCvalue);            // 0 to 4095

		if(refresh){
				refresh = 0;
				samples++;
		    ST7735_PlotPoint(ADCvalue);  // Measured temperature
				if((samples&(N-1))==0){          // fs sampling, fs/N samples plotted per second
					ST7735_PlotNextErase();  // overwrites N points on same line
				}
				if((samples%fs)==0){    // fs sampling, 1 Hz display of numerical data
				//do conversion here, set it equal to temp.
				temp = get_temp(ADCvalue);
				ST7735_SetCursor(3,1); ST7735_OutUDec(ADCvalue);            // 0 to 4095
				ST7735_SetCursor(3,2);ST7735_DecOut2(temp); // 0.01 C 
			}

		}
	}

  
}
Пример #3
0
int main(void){
	PLL_Init(Bus80MHz);                   // 80 MHz
  SYSCTL_RCGCGPIO_R |= 0x20;            // activate port F
  ADC0_InitSWTriggerSeq3_Ch9();         // allow time to finish activating
  Timer0A_Init100HzInt();               // set up Timer0A for 100 Hz interrupts
  Timer1_Init();
	//Timer2_Init();											//Enable this for part D.
	GPIO_PORTF_DIR_R |= 0x06;             // make PF2, PF1 out (built-in LED)
  GPIO_PORTF_AFSEL_R &= ~0x06;          // disable alt funct on PF2, PF1
  GPIO_PORTF_DEN_R |= 0x06;             // enable digital I/O on PF2, PF1
                                        // configure PF2 as GPIO
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF00F)+0x00000000;
  GPIO_PORTF_AMSEL_R = 0;               // disable analog functionality on PF
  PF2 = 0;                      // turn off LED
	EnableInterrupts();
  while(1){
    PF1 ^= 0x02;  // toggles when running in main
		//GPIO_PORTF_DATA_R ^= 0x02;  // Uncomment this for part C. and comment the line above.
		//PF1 = (PF1*12345678)/1234567+0x02;  // Uncomment this for part D.
		if(i==1000){
			int largest = 0;
			for(int j; j < 1000; j++){
				if(largest < array2[i]){
					largest = array2[i];
					i++;
				}
			}
			Output_Init();              // initialize output device
			Errors = 0;
			int x;
			int y;
			DisableInterrupts();
			storeFrequency();
			makePMF(array3, pmf);
			ST7735_XYplotInit("Lab 2 PMF", 0, 4095, 0, 1000);
			for(int j = 0; j < 1000; j += 10){
			 	ST7735_PlotBar(pmf[j] * 9);
				ST7735_PlotNext();
			}
			break;
		}
  }
	while(1);
}
Пример #4
0
int main(void){int32_t retVal;  SlSecParams_t secParams;
  char *pConfig = NULL; INT32 ASize = 0; SlSockAddrIn_t  Addr;
	ADC0_InitSWTriggerSeq3_Ch9();         // allow time to finish activating
  initClk();        // PLL 50 MHz
	Output_On();
	UART_Init();      // Send data to PC, 115200 bps
  Timer1_Init();
  LED_Init();       // initialize LaunchPad I/O 
  UARTprintf("Weather App\n");
  retVal = configureSimpleLinkToDefaultState(pConfig); // set policies
  if(retVal < 0)Crash(4000000);
  retVal = sl_Start(0, pConfig, 0);
  if((retVal < 0) || (ROLE_STA != retVal) ) Crash(8000000);
  secParams.Key = PASSKEY;
  secParams.KeyLen = strlen(PASSKEY);
  secParams.Type = SEC_TYPE; // OPEN, WPA, or WEP
  sl_WlanConnect(SSID_NAME, strlen(SSID_NAME), 0, &secParams, 0);
  while((0 == (g_Status&CONNECTED)) || (0 == (g_Status&IP_AQUIRED))){
    _SlNonOsMainLoopTask();
  }
  UARTprintf("Connected\n");
  while(1){
		int i = 0;
		while(i < 10){
			int sendc = 0;
			strcpy(HostName,"openweathermap.org");
			retVal = sl_NetAppDnsGetHostByName(HostName,
							 strlen(HostName),&DestinationIP, SL_AF_INET);
			if(retVal == 0){
				Addr.sin_family = SL_AF_INET;
				Addr.sin_port = sl_Htons(80);
				Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);// IP to big endian 
				ASize = sizeof(SlSockAddrIn_t);
				SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
				if( SockID >= 0 ){
					retVal = sl_Connect(SockID, ( SlSockAddr_t *)&Addr, ASize);
				}
				if((SockID >= 0)&&(retVal >= 0)){
					strcpy(SendBuff,REQUEST); 
					sl_Send(SockID, SendBuff, strlen(SendBuff), 0);// Send the HTTP GET 
					sl_Recv(SockID, Recvbuff, MAX_RECV_BUFF_SIZE, 0);// Receive response 
					sl_Close(SockID);
					LED_GreenOn();
					UARTprintf("\r\n\r\n");
					UARTprintf(Recvbuff);  UARTprintf("\r\n");
				}
			}
			ST7735_OutUDec(sendc);
			ST7735_OutString("\n");
			i++;
		}
		
		//while(Board_Input()==0){}; // wait for touch
		LED_GreenOff();
		//Temp Part e
		getTemp(Recvbuff);
		ST7735_OutChar('T');
		ST7735_OutChar('e');
		ST7735_OutChar('m');
		ST7735_OutChar('p');
		ST7735_OutChar(' ');
		ST7735_OutChar('=');
		ST7735_OutChar(' ');
		for(int i = 0; i < 5; i++){
			ST7735_OutChar(myArray[i]);
		}
		ST7735_OutChar('\n');

		//ADC Part f
		ADC0_SAC_R = ADC_SAC_AVG_64X;    //enable 64 times average before obtaining result
    int voltage = ADC0_InSeq3();
		ST7735_OutString("Voltage~");
		ST7735_sDecOut3(voltage);
		
		char* voltageString;
		char voltageStringNum[5];
		sprintf(voltageStringNum, "%.1d.%.3d", voltage/1000, voltage%1000);
		//ST7735_OutString(voltageStringNum);
		
		char* sendString;
		char str1[173] = "GET /query?city=Austin%20Texas&id=Ty%20Winkler%20Jeremiah%20Bartlett&greet=Voltage%3D";
		strcat(str1, voltageStringNum);
		strcat(str1, "V&edxcode=8086 HTTP/1.1\r\nUser-Agent: Keil\r\nHost: embsysmooc.appspot.com\r\n\r\n");
		
		
		strcpy(HostName,"embsysmooc.appspot.com");
		retVal = sl_NetAppDnsGetHostByName(HostName,
						 strlen(HostName),&DestinationIP, SL_AF_INET);
		if(retVal == 0){
			Addr.sin_family = SL_AF_INET;
			Addr.sin_port = sl_Htons(80);
			Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);// IP to big endian 
			ASize = sizeof(SlSockAddrIn_t);
			SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
			if( SockID >= 0 ){
				retVal = sl_Connect(SockID, ( SlSockAddr_t *)&Addr, ASize);
			}
			if((SockID >= 0)&&(retVal >= 0)){
				strcpy(SendBuff, str1);
				count = 0;					
				sl_Send(SockID, SendBuff, strlen(SendBuff), 0);// Send the HTTP GET 
				sl_Recv(SockID, Recvbuff, MAX_RECV_BUFF_SIZE, 0);// Receive response 
				sl_Close(SockID);
				LED_GreenOn();
				UARTprintf("\r\n\r\n");
				//ST7735_OutString(Recvbuff);  
				UARTprintf("\r\n");
			}
		}
		while(1);
	}
}
Пример #5
0
/*
 * Application's entry point
 */
int main(void){
	SlSecParams_t secParams;
  char *pConfig = NULL;
	uint32_t timeElapsed;
  initClk();        // PLL 50 MHz
  UART_Init();      // Send data to PC, 115200 bps
  LED_Init();       // initialize LaunchPad I/O 
	Timer1_Init();
	ADC0_InitSWTriggerSeq3_Ch9(); //initialize ADC sampler
	ST7735_InitR(INITR_REDTAB);
	
	ST7735_SetCursor(1,1);
	printf("Lab4C\n");
	Wifi_Connect(pConfig, &secParams);
  UARTprintf("Weather App\n");
	while(1){
		// clear the data output
		ST7735_SetCursor(0,4);
		for(uint16_t i = 0; i < 6; i += 1) {
			printf("               \n");
		}
		ST7735_SetCursor(0,4);

		LED_GreenOn();
		Timer1_StartWatch();
		char *weather_data = HTTP_Request(
			"api.openweathermap.org", 80,
			"GET", "/data/2.5/weather?q=Austin%20Texas&units=metric&APPID=d6e361f259c47a6ea9837d41b1856b03",
			NULL,
			NULL
		);
		timeElapsed = Timer1_StopWatch();
		LED_GreenOff();
		UARTprintf("\r\n\r\n");
		UARTprintf(weather_data);  UARTprintf("\r\n");
    
		printf("Temp = %6s C\n", Extract_Temperature(weather_data));
		printf("Time = %lums\n", timeElapsed * 125 / 10 / 1000000 );
		
		uint32_t sample = ADC0_InSeq3();
		LED_GreenOn();
		Timer1_StartWatch();
		char *send_data = HTTP_Request(
			// embsysmooc or embedded-systems-server?
			"embsysmooc.appspot.com", 80,
			"GET", "/query?city=Austin%20Texas&id=John%20Starich%20and%20Jon%20Ambrose&edxcode=8086&greet=Voltage~",
			VoltageToString(sample),
			"V"
		);
		timeElapsed = Timer1_StopWatch();
		LED_GreenOff();
		UARTprintf("\r\n\r\n");
		UARTprintf(send_data);  UARTprintf("\r\n");
		printf("Voltage~%luV\n", sample);
		printf("Time = %lums\n", timeElapsed * 125 / 10 / 1000000 );

		LED_GreenOn();
		Timer1_StartWatch();
		char *custom = HTTP_Request(
			"tomcat.johnstarich.com", 80,
			"GET", "/%22temp%22:1000,",
			NULL,
			NULL
		);
		timeElapsed = Timer1_StopWatch();
		LED_GreenOff();
		UARTprintf("\r\n\r\n");
		UARTprintf(send_data);  UARTprintf("\r\n");
		UARTprintf("Custom temp: %s", custom);  UARTprintf("\r\n");
		printf("Custom temp: %s\n", Extract_Temperature(custom));
		printf("Time = %lums\n", timeElapsed * 125 / 10 / 1000000 );

    while(Board_Input()==0){}; // wait for touch
  }
}