// 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); } }
//*******************final user main DEMONTRATE THIS TO TA********** int main(void){ OS_Init(); // initialize, disable interrupts PortE_Init(); DataLost = 0; // lost data between producer and consumer NumSamples = 0; MaxJitter = 0; // in 1us units //********initialize communication channels OS_MailBox_Init(); OS_Fifo_Init(128); // ***note*** 4 is not big enough***** ST7735_InitR(INITR_REDTAB); // initialize LCD UART_Init(); // initialize UART //*******attach background tasks*********** OS_AddSW1Task(&SW1Push,2); // OS_AddSW2Task(&SW2Push,2); // add this line in Lab 3 ADC_Init(4); // sequencer 3, channel 4, PD3, sampling in DAS() OS_AddPeriodicThread(&DAS,PERIOD,1); // 2 kHz real time sampling of PD3 NumCreated = 0 ; // create initial foreground threads NumCreated += OS_AddThread(&Interpreter,128,2); NumCreated += OS_AddThread(&Consumer,128,1); NumCreated += OS_AddThread(&PID,128,3); // Lab 3, make this lowest priority OS_Launch(TIME_2MS); // doesn't return, interrupts enabled in here return 0; // this never executes }
void encoderInit(int32_t *newArray) { position = newArray; PortA_Init(); PortB_Init(); PortD_Init(); PortE_Init(); }
int main(void) { TExaS_Init(SW_PIN_PE0, LED_PIN_PE1); // activate grader and set system clock to 80 MHz PortE_Init(); EnableInterrupts(); // enable interrupts for the grader while(1) { Delay100ms(1); In = GPIO_PORTE_DATA_R&0x01; // read PE0 into In if (In == 0x01) GPIO_PORTE_DATA_R = GPIO_PORTE_DATA_R ^ 0x02; // toggle the LED else GPIO_PORTE_DATA_R |= 0x02; // the LED ON (make PE1 =1). } }
// PE0, PB0, or PA2 connected to positive logic momentary switch using 10 k ohm pull down resistor // PE1, PB1, or PA3 connected to positive logic LED through 470 ohm current limiting resistor // To avoid damaging your hardware, ensure that your circuits match the schematic // shown in Lab8_artist.sch (PCB Artist schematic file) or // Lab8_artist.pdf (compatible with many various readers like Adobe Acrobat). // 1) Make PE1 an output and make PE0 an input. // 2) The system starts with the LED on (make PE1 =1). // 3) Wait about 100 ms // 4) If the switch is pressed (PE0 is 1), then toggle the LED once, else turn the LED on. // 5) Steps 3 and 4 are repeated over and over. int main(void){ //********************************************************************** // The following version tests input on PE0 and output on PE1 //********************************************************************** TExaS_Init(SW_PIN_PE0, LED_PIN_PE1); // activate grader and set system clock to 80 MHz PortE_Init(); EnableInterrupts(); // enable interrupts for the grader while(1){ Delay100ms(time_delay); button = GPIO_PORTE_DATA_R&0x01; // read PE0 into the switch if(button == 1){ GPIO_PORTE_DATA_R ^=0x02; // Toggle PE1 }else{ GPIO_PORTE_DATA_R |=0x02; // Set PE1 } } }
int main(void){ unsigned char input; PLL_Init(); // Program 10.1 SysTick_Init(); // Program 10.2 PortB_Init(); // initialize motor outputs on Port B PortE_Init(); // initialize sensor inputs on Port E cState = 0; // initial state = 0 while(1){ // output based on current state GPIO_PORTB_DATA_R = Fsm[cState].out; // step motor // wait for time according to state SysTick_Wait10ms(Fsm[cState].wait); // get input input = GPIO_PORTE_DATA_R&0x03; // Input 0,1,2,3 // change the state based on input and current state cState = Fsm[cState].next[input]; } }
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){ } }
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(); }
// PE0, PB0, or PA2 connected to positive logic momentary switch using 10 k ohm pull down resistor // PE1, PB1, or PA3 connected to positive logic LED through 470 ohm current limiting resistor // To avoid damaging your hardware, ensure that your circuits match the schematic // shown in Lab8_artist.sch (PCB Artist schematic file) or // Lab8_artist.pdf (compatible with many various readers like Adobe Acrobat). int main(void){ //********************************************************************** // The following version tests input on PE0 and output on PE1 //********************************************************************** TExaS_Init(SW_PIN_PE0, LED_PIN_PE1); // activate grader and set system clock to 80 MHz PortE_Init(); EnableInterrupts(); // enable interrupts for the grader while(1){ Delay100ms(1); In = GPIO_PORTE_DATA_R&0x01; // read PE0 into In if (In == 0x01) { GPIO_PORTE_DATA_R = GPIO_PORTE_DATA_R ^ 0x02; // toggle the LED } else { GPIO_PORTE_DATA_R |= 0x02; // the LED ON (make PE1 =1). } } }
// PE0, PB0, or PA2 connected to positive logic momentary switch using 10k ohm pull down resistor // PE1, PB1, or PA3 connected to positive logic LED through 470 ohm current limiting resistor // To avoid damaging your hardware, ensure that your circuits match the schematic // shown in Lab8_artist.sch (PCB Artist schematic file) or // Lab8_artist.pdf (compatible with many various readers like Adobe Acrobat). int main(void){ //********************************************************************** // The following version tests input on PE0 and output on PE1 //********************************************************************** TExaS_Init(SW_PIN_PE0, LED_PIN_PE1); // activate grader and set system clock to 80 MHz PortE_Init(); EnableInterrupts(); // enable interrupts for the grader while(1){ // body goes here //for(i=0;i<2666667;i++); // Delay for about 100 ms 100 ms * 80 MHZ/3 Delay100ms(1); In = GPIO_PORTE_DATA_R&0x01; // read PE0 into Sw1 if (In == 0x01) { GPIO_PORTE_DATA_R = GPIO_PORTE_DATA_R ^ 0x02; } else { GPIO_PORTE_DATA_R |= 0x02; } } }
int main(void){ unsigned long volatile delay; TExaS_Init(SW_PIN_PE210, LED_PIN_PB543210); // activate grader and set system clock to 80 MHz //TExaS_Scope(); PortB_Init(delay); PortE_Init(delay); PortF_Init(delay); SysTick_Init(); EnableInterrupts(); while(1){ outputB = fsm[S].outB; outputF = fsm[S].outF; SetOutputB(outputB); SetOutputF(outputF); SysTick_Wait_10ms(fsm[S].delay*10); input = GetInput(); S = fsm[S].next[input]; } }
int main(void){ char* lab_greeting = "Smart \"Mirror\"!"; DisableInterrupts(); PLL_Init(Bus80MHz); Output_Init(); // UART0 only used for debugging ST7735_Output_Init(); PortF_Init(); PortE_Init(); printf("\n\r-----------\n\rSystem starting...\n\r"); ESP8266_Init(115200); // connect to access point, set up as client ESP8266_GetVersionNumber(); while(1){ if(last_mode != mode){ refresh =1; last_mode = mode; memset(ResponseJson, 0, SERVER_RESPONSE_SIZE * sizeof(ResponseJson[0])); } if(mode==0&&refresh){ refresh = 0; ST7735_FillScreen(0); ST7735_DrawString(0,0, lab_greeting, ST7735_WHITE); ST7735_DrawString(0,1, "MODE: WEATHER", ST7735_GREEN); ESP8266_GetStatus(); if(ESP8266_MakeTCPConnection("kylepolansky.dyndns.org")){ // open socket in server LED_GreenOn(); ESP8266_SendTCP(Fetch_Kyle); } ESP8266_CloseTCPConnection(); ParseWeather(ResponseJson); printf("START RESPONSE\n"); printf(ResponseJson); printf("STOP RESPONSE\n"); } else if(mode==1&&refresh){ refresh = 0; ST7735_FillScreen(0); ST7735_DrawString(0,0, lab_greeting, ST7735_WHITE); ST7735_DrawString(0,1, "MODE: TIME", ST7735_GREEN); ESP8266_GetStatus(); if(ESP8266_MakeTCPConnection("kylepolansky.dyndns.org")){ // open socket in server LED_GreenOn(); ESP8266_SendTCP(Fetch_Kyle); } ESP8266_CloseTCPConnection(); ParseTime(ResponseJson); printf("START RESPONSE\n"); printf(ResponseJson); printf("STOP RESPONSE\n"); } else if(mode==2&&refresh){ refresh = 0; ST7735_FillScreen(0); ST7735_DrawString(0,0, lab_greeting, ST7735_WHITE); ST7735_DrawString(0,1, "MODE: REMINDERS", ST7735_GREEN); ESP8266_GetStatus(); if(ESP8266_MakeTCPConnection("kylepolansky.dyndns.org")){ // open socket in server LED_GreenOn(); ESP8266_SendTCP(Fetch_Kyle); } ESP8266_CloseTCPConnection(); ParseReminders(ResponseJson); printf("START RESPONSE\n"); printf(ResponseJson); printf("STOP RESPONSE\n"); } else if(mode==3&&refresh){ refresh = 0; ST7735_FillScreen(0); ST7735_DrawString(0,0, lab_greeting, ST7735_WHITE); ST7735_DrawString(0,1, "MODE: NEWS", ST7735_GREEN); ESP8266_GetStatus(); if(ESP8266_MakeTCPConnection("kylepolansky.dyndns.org")){ // open socket in server LED_GreenOn(); ESP8266_SendTCP(Fetch_Kyle); } ESP8266_CloseTCPConnection(); ParseHeadline(ResponseJson); printf("START RESPONSE\n"); printf(ResponseJson); printf("STOP RESPONSE\n"); } else if(mode==4&&refresh){ refresh = 0; ST7735_FillScreen(0); ST7735_DrawString(0,0, lab_greeting, ST7735_WHITE); ST7735_DrawString(0,1, "MODE: STOCK", ST7735_GREEN); ESP8266_GetStatus(); if(ESP8266_MakeTCPConnection("kylepolansky.dyndns.org")){ // open socket in server LED_GreenOn(); ESP8266_SendTCP(Fetch_Kyle); } ESP8266_CloseTCPConnection(); ParseStock(ResponseJson); printf("START RESPONSE\n"); printf(ResponseJson); printf("STOP RESPONSE\n"); } } }
void Switch_Init(void) { PortE_Init(); }