int main(void){ unsigned long status; Switch_Init(); // PA5 is input status = Switch_Input(); // 0x00 or 0x20 status = Switch_Input(); // 0x00 or 0x20 Board_Init(); // initialize PF0 and PF4 and make them inputs // make PF3-1 out (PF3-1 built-in LEDs) GPIO_PORTF_DIR_R |= (RED|BLUE|GREEN); // disable alt funct on PF3-1 GPIO_PORTF_AFSEL_R &= ~(RED|BLUE|GREEN); // enable digital I/O on PF3-1 GPIO_PORTF_DEN_R |= (RED|BLUE|GREEN); // configure PF3-1 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFF000F)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF while(1){ status = Board_Input(); switch(status){ // switches are negative logic on PF0 and PF4 case 0x01: LEDS = BLUE; break; // SW1 pressed case 0x10: LEDS = RED; break; // SW2 pressed case 0x00: LEDS = GREEN; break; // both switches pressed case 0x11: LEDS = 0; break; // neither switch pressed default: LEDS = (RED|GREEN|BLUE);// unexpected return value } } }
int main(void){ int32_t retVal = 0; char *pConfig = NULL; retVal = initializeAppVariables(); stopWDT(); // Stop WDT initClk(); // PLL 50 MHz LCD_Init(); LED_Init(); // initialize LaunchPad I/O // LCD_OutString("Weather App\n"); LCD_OutString("Lab 16 IoT\n"); /* * Following function configures the device to default state by cleaning * the persistent settings stored in NVMEM (viz. connection profiles & * policies, power policy etc) * * Applications may choose to skip this step if the developer is sure * that the device is in its default state at start of application * * Note that all profiles and persistent settings that were done on the * device will be lost */ retVal = configureSimpleLinkToDefaultState(pConfig); if(retVal < 0){ if(DEVICE_NOT_IN_STATION_MODE == retVal){ LCD_OutString(" Failed to configure the device in its default state \r\n"); Crash(4000000); } } /* * Assumption is that the device is configured in station mode already * and it is in its default state */ retVal = sl_Start(0, pConfig, 0); if((retVal < 0) || (ROLE_STA != retVal) ){ LCD_OutString(" Failed to start the device \r\n"); Crash(8000000); } WlanConnect(); LCD_OutString("Connected\n"); /* Get weather report */ while(1){ Nokia5110_SetCursor(0,2); // retVal = getWeather(); retVal = Lab16(); if(retVal == 0){ // valid LED_GreenOn(); UARTprintf("\r\n\r\n"); UARToutString(appData.Recvbuff); UARTprintf("\r\n"); // LCD_OutString(City); LCD_OutString("\n"); // LCD_OutString(Temperature); LCD_OutString(" C\n"); // LCD_OutString(Weather); LCD_OutString(Id); LCD_OutString("\n"); LCD_OutString(Score); LCD_OutString("\n"); LCD_OutString(Edxpost); } while(Board_Input()==0){}; // wait for touch LED_GreenOff(); } }
/* * 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 } }