Exemple #1
0
//------------main----------------------------
int main(void){
  PLL_Init();
	SysTick_Init();
	Switch_Init();
  Output_Init();
	
	// print intro screen to lab
	printf("   Fixed-point Lab\n");
  printf("\n\n\n\n\n\n\n\n\n\n");
	printf("          By:\n");
	printf("    Brandon Boesch\n");
	printf("    Curtis Martin\n");
	printf("  Press SW2 to begin\n");
	ST7735_DrawBitmap(30, 108, bmp_Logo, 70, 100);

	// begin tests
	while(PF0 == 0x01){};
  Fixed_uDecOut2_test();
	while(PF0 == 0x01){};
	Fixed_sDecOut3_test();
	while(PF0 == 0x01){};
	Fixed_uBinOut8_test();
  while(PF0 == 0x01){};
	// outro screen
	Output_Clear();
	ST7735_SetCursor(0,0);
  printf("Tests complete!");
	ST7735_DrawBitmap(6, 159, bmp_thumbs, 114, 146);
	
  while(1){};
}
int main(void){
  TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
  Random_Init(1);

  Output_Init();
  ST7735_FillScreen(0x0000);            // set screen to black
  
  ST7735_DrawBitmap(52, 159, PlayerShip0, 18,8); // player ship middle bottom
  ST7735_DrawBitmap(53, 151, Bunker0, 18,5);

  ST7735_DrawBitmap(0, 9, SmallEnemy10pointA, 16,10);
  ST7735_DrawBitmap(20,9, SmallEnemy10pointB, 16,10);
  ST7735_DrawBitmap(40, 9, SmallEnemy20pointA, 16,10);
  ST7735_DrawBitmap(60, 9, SmallEnemy20pointB, 16,10);
  ST7735_DrawBitmap(80, 9, SmallEnemy30pointA, 16,10);
  ST7735_DrawBitmap(100, 9, SmallEnemy30pointB, 16,10);


  Delay100ms(50);              // delay 5 sec at 80 MHz


  ST7735_FillScreen(0x0000);            // set screen to black
  ST7735_SetCursor(1, 1);
  ST7735_OutString("GAME OVER");
  ST7735_SetCursor(1, 2);
  ST7735_OutString("Nice try,");
  ST7735_SetCursor(1, 3);
  ST7735_OutString("Earthling!");
  ST7735_SetCursor(2, 4);
  LCD_OutDec(1234);
  while(1){
  }

}
Exemple #3
0
int main(void){ int i;
	Output_Init();
	
	RIT128x96x4_ClearImage(); 
 
	RIT128x96x4_Line(0,0,50,50,15); 

	RIT128x96x4_ShowImage(); 		
	
	while(1);
	
	//printf("hi\n");
	//mainTestInterrupt();
//  SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
//  RIT128x96x4Init(1000000);
////  RIT128x96x4_Logo(60);	   // place in middle
//  RIT128x96x4_BMP(0, 60, ECE);
//  Delay(50000000);        // delay 3 sec at 50 MHz 
//  RIT128x96x4Clear();
//  for(i=90; i>5; i=i-2){
//     RIT128x96x4_BMP(i, 80, Horse);
//     Delay(1000000);        // delay 0.3 sec at 50 MHz 
//  }
//  Delay(1000000000);        // delay 60 sec at 50 MHz 
//  RIT128x96x4DisplayOff(); // screen saver
//  while(1){};
}
//debug code
int main(void){
	PLL_Init(Bus80MHz);	// bus clock at 50 MHz
  Output_Init();
	SYSCTL_RCGCGPIO_R |= 0x20;       // activate port F
	//ADC0_InitTimer0ATriggerSeq3(2, F30HZ); // ADC channel 0, 1000 Hz sampling
	ADC0_InitTimer0ATriggerSeq3PD3(F30HZ);
  //ADC0_InitSWTriggerSeq3_Ch9();
	while((SYSCTL_PRGPIO_R&0x0020) == 0){};// ready?
  GPIO_PORTF_DIR_R |= 0x02;        // make PF1 output (PF1 built-in LEDs)
  GPIO_PORTF_AFSEL_R &= ~0x02;     // disable alt funct on PF1
  GPIO_PORTF_DEN_R |= 0x02;        // enable digital I/O on PF1
                                   // configure PF1 as GPIO
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF0FF)+0x00000000;
  GPIO_PORTF_AMSEL_R = 0;          // disable analog functionality on PF
  EnableInterrupts();

	plotInit();
		
	while(1){
		GPIO_PORTF_DATA_R ^= 0x02;           // toggle LED
		//ADCvalue = ADC0_InSeq3();
		temperature = adcToTemp(ADCvalue + offset);
		plotPoint();
		ST7735_SetCursor(1,2);
		ST7735_sDecOut2(temperature);
		ST7735_SetCursor(2,1);
		ST7735_OutUDec(ADCvalue + offset);
	}
}
Exemple #5
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);
  }	
}
// *************************** Capture image dimensions out of BMP**********
int main(void){
  TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
  Random_Init(69);
  Output_Init();
	ADC0_Init();
	ST7735_InvertDisplay(0);
	ST7735_SetRotation(0);
	AI_Init(0x07);
	Player_Init();
	player.potato=1;
	
	Timer0_Init(Master_Funk,  30);

  ST7735_DrawBitmap(53, 151, Bunker0, 18,5);
//	Delay100ms(1);              // delay 5 sec at 80 MHz

 /* ST7735_FillScreen(0x0000);            // set screen to black
  ST7735_SetCursor(1, 1);
  ST7735_OutString("GAME OVER");
  ST7735_SetCursor(1, 2);
  ST7735_OutString("Nice try,");
  ST7735_SetCursor(1, 3);
  ST7735_OutString("Earthling!");
  ST7735_SetCursor(2, 4);
  LCD_OutDec(1234);	 */
  while(1){							
  } 
}
Exemple #7
0
int main(void) {

    MCU_Clk_Init();
    Input_Init();
    Output_Init();
    LCD_Init();
    // Cau hinh timer xay ra ngat sau 1s
    Timer0A_Config(40000000);

    Write_Str("Hello World!", 0, 0);

    while (1) {
        if (CuaDong) {
            // Bat den
            door_is_close = true;
            GPIOPinWrite(GPIO_PORTB_BASE, LIGHT_PIN, LIGHT_PIN);
        } else {
            door_is_close = false;
            if (is_active) {
                // Neu dang nuong ma mo cua thi tat ngay lap tuc thiet bi nuong, tat timer va bat loa canh bao
                GPIOPinWrite(GPIO_PORTB_BASE, GRILL_PIN, GRILL_PIN);
                GPIOPinWrite(GPIO_PORTB_BASE, MICRO_PIN, MICRO_PIN);
                TimerDisable(TIMER0_BASE, TIMER_A);
                GPIOPinWrite(GPIO_PORTB_BASE, SPEAKER_PIN, 0);
            } else {
                // Neu da nuong xong va cua mo thi tat loa
                GPIOPinWrite(GPIO_PORTB_BASE, SPEAKER_PIN, 0);
            }

        }
    }
}
Exemple #8
0
int main(void) {
    int i;
    Output_Init();
    Output_Color(15);
    printf("Hello, world.");
    printf("%c", NEWLINE);
    Delay(4000000);           // delay ~1 sec at 12 MHz
    Output_Color(8);
    printf("A really long string should go to the next line.\r");
    printf("Oxxx(:::::::::::::::>%c", NEWLINE);
    Delay(4000000);           // delay ~1 sec at 12 MHz
    Output_Color(15);
    printf("Color Table:%c", NEWLINE);
    Delay(4000000);           // delay ~1 sec at 12 MHz
    Output_Color(8);
    printf("<:::::::::::::::)xxxO%c", NEWLINE);
    for(i=15; i>=1; i=i-2) {
        Delay(4000000);         // delay ~1 sec at 12 MHz
        Output_Color(i);
        printf("Color: %u%c", i, TAB);
        Output_Color(i-1);
        printf("Color: %u%c", i-1, NEWLINE);
    }
    Delay(4000000);           // delay ~1 sec at 12 MHz
    Output_Clear();
    while(1) {};
}
Exemple #9
0
int main(){
	int i = 0;
	PLL_Init();
	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | 
	SYSCTL_XTAL_8MHZ); // 50 MHz 
	DisableInterrupts();
	SYSCTL_RCGC1_R |= SYSCTL_RCGC1_TIMER0;// activate timer0
	SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF+SYSCTL_RCGC2_GPIOG; // activate ports F and G
	Output_Init(); 
	SysTick_InitSeconds(1);
	PolledButtons_Init();
	EnableInterrupts();
	displayMode = 0;
	ringAlarms = 0;
	timeMode = 0;
		
	while(1){
		if (ringAlarms && !soundPlaying && (alarmActive || timeMode == 4))	{
			playSound();
		}
		else if ((ringAlarms==0 || !alarmActive) && soundPlaying) {
			stopSound();
		}
		if(displayMode==0) {
			displayClock();
		}
		else if(displayMode==1){
			displaySet();
		}
	}
}
Exemple #10
0
// *************************** Capture image dimensions out of BMP**********
int main(void){
  TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
  Output_Init();
	ADC0_Init();
	DAC_Init();
	SysTick_Init();
	Menu_Init();
	Sound_Init();
	UART1_Init();
	
	Button0_Init();
	Timer0_Init(Play, 80000000/11025);	// 11.025 kHz 80000000/11025
	Timer1_Init(Master_Funk,  80000000/60);
	//Timer2_Init(SomeUART function, high speed); //for UART

 /* ST7735_FillScreen(0x0000);            // set screen to black
  ST7735_SetCursor(1, 1);
  ST7735_OutString("GAME OVER");
  ST7735_SetCursor(1, 2);
  ST7735_OutString("Nice try,");
  ST7735_SetCursor(1, 3);
  ST7735_OutString("Earthling!");
  ST7735_SetCursor(2, 4);
  LCD_OutDec(1234);	 */
  while(1){							
  } 
}
Exemple #11
0
//debug code
int main(void){
  unsigned char i;
	unsigned char * data;
//  char string[20];  // global to assist in debugging
//  unsigned long n;

  //
  // Set the clocking to run at 50MHz from the PLL.
  //
  SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                 SYSCTL_XTAL_8MHZ);
	SysTick_Init();
	Output_Init();
	Output_Color(15);
  UART_Init();              // initialize UART
	Xbee_Init(12);
	SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOG;
	i = 0;
	i += 1;
	GPIO_PORTG_DEN_R |= 0x04;
	GPIO_PORTG_DIR_R |= 0x04;
	GPIO_PORTG_DATA_R &= ~0x04;
//  OutCRLF();
//  for(i='A'; i<='Z'; i=i+1){// print the uppercase alphabet
//    UART_OutChar(i);
//  }
//  OutCRLF();
//  UART_OutChar(' ');
//  for(i='a'; i<='z'; i=i+1){// print the lowercase alphabet
//    UART_OutChar(i);
//  }
//  OutCRLF();
//  UART_OutChar('-');
//  UART_OutChar('-');
//  UART_OutChar('>');
//	EnableInterrupts();
  while(1){
//    UART_OutString("InString: ");
//    UART_InString(string,19);
//    UART_OutString(" OutString="); UART_OutString(string); OutCRLF();

//    UART_OutString("InUDec: ");  n=UART_InUDec();
//    UART_OutString(" OutUDec="); UART_OutUDec(n); OutCRLF();

//    UART_OutString("InUHex: ");  n=UART_InUHex();
//    UART_OutString(" OutUHex="); UART_OutUHex(n); OutCRLF();
//		WaitForInterrupt();
		GPIO_PORTG_DATA_R ^= 0x04;
		data = receiveData();
		if (data!=0)
			printf("%c", data[0] + 0x20);
		//XBee_RecieveRxFrame();
//		XBee_TxStatus();
//		XBee_Display();
  }
}
Exemple #12
0
int main(void){  
  DisableInterrupts();
  //////////////////////// perhipheral initialization ////////////////////////
  // init PLL to 80Mhz
  PLL_Init();
  
  // init screen, use white as text color
  Output_Init();
  Output_Color(ST7735_WHITE);  
  //Output_Clear();
  
  // init usb uart, generate interrupts when data received via usb
  USB_UART_Init();
  USB_UART_Enable_Interrupt();
    
  // init systick to generate an interrupt every 1ms (every 80000 cycles)  
  //SysTick_Init(80000);
  
  // init and enable PWM
 // PWM0A_Init(40000, 20000);
 // PWM0A_Enable();

  // init debug LEDs
  DEBUG_Init();

  // global enable interrupts
  EnableInterrupts();
  
  //////////////////////// main loop ////////////////////////    
	
  while(1){
		
    WaitForInterrupt();
/*
    if (updateScreen){
      updateScreen = false;
      // screen stuff here
    }
    */
    if (USB_BufferReady){
      USB_BufferReady = false;
      //INTER_HandleBuffer();
			
			loopcount++;
			dd++;
			// experimental test comment
    }
    
		
		
  }
}
Exemple #13
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);
}
/*main written by Josh Cristol and Cody Horton*/
int main(void){
	PLL_Init();
	Output_Init();
	Edge_Init();
	while(1){
		while(!Switch_Pressed()){wait(1);}
		wait(0);
		testBinary();
		while(!Switch_Pressed()){wait(1);}
		wait(0);
		testDec(); 
		while(!Switch_Pressed()){wait(1);}
		wait(0);
		testGraph();
		XYplotInit("Graph", getXMin(), getXMax(), getYMin(), getYMax());
		int32_t* xBuff = getXData();
		int32_t* yBuff = getYData();
		XYplot(xBuff, yBuff, getLength());
	}
}
void clk_graphics_init(uint32_t x, uint32_t y, uint32_t radius, int32_t color){
		Output_Init();
		clock_centerX = x;
		clock_centerY = y;
    DrawCircle(clock_centerX, clock_centerY, radius, color);
    minute_array_length = ghostCircleLength(clock_centerX, clock_centerY, (radius * 3) / 4);
    hour_array_length = ghostCircleLength(clock_centerX, clock_centerY, radius / 2);
		uint32_t array1[minute_array_length];
		uint32_t array2[minute_array_length];
		uint32_t array3[hour_array_length];
    uint32_t array4[hour_array_length];
		x_cor_minutes = array1;
		y_cor_minutes = array2;
		x_cor_hours = array3;
		y_cor_hours = array4;
		DrawGhostCircle(clock_centerX, clock_centerY, (radius * 3) / 4, x_cor_minutes, y_cor_minutes, minute_array_length);
    DrawGhostCircle(clock_centerX, clock_centerY, radius / 2, x_cor_hours, y_cor_hours, hour_array_length);
    sortGhostCircle(x_cor_minutes, y_cor_minutes, minute_array_length);
    sortGhostCircle(x_cor_hours,y_cor_hours,hour_array_length);
    drawFirstTime();
}
Exemple #16
0
int main2(void){  char data;
  DisableInterrupts();
  PLL_Init(Bus80MHz);
 // LED_Init();  
  Output_Init();       // UART0 as a terminal
  printf("\n\r-----------\n\rSystem starting at 9600 baud...\n\r");

  ESP8266_InitUART(9600,true);
  ESP8266_EnableRXInterrupt();
  EnableInterrupts();
  ESP8266SendCommand("AT+RST\r\n");
  data = UART_InChar();

  
  while(1){
// echo data back and forth
    data = UART_InCharNonBlock();
    if(data){
      ESP8266_PrintChar(data);
    }
  }
}
Exemple #17
0
// ************ OS_Init ******************
// initialize operating system, disable interrupts until OS_Launch
// initialize OS controlled I/O: serial, ADC, systick, select switch and timer2
// input: none
// output: non
void OS_Init(void) {

  int i; // Used for indexing

  // Disable interrupts
  OS_DisableInterrupts();

  // Setting the clock to 50 MHz
  SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

  // Initialze peripherals
  UART0_Init();
  ADC_Open();
  Output_Init();

  // Select switch
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
  GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
  GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
  GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_RISING_EDGE);
  GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1);

  // Down switch
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
  GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1);
  GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
  GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_RISING_EDGE);
  GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_1);

  // Initialize Timer2A and Timer2B: Periodic Background Threads
  SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
  TimerDisable(TIMER2_BASE, TIMER_A | TIMER_B);
  TimerConfigure(TIMER2_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
  
  // Initialize Timer0B: Used for time keeping
  TimerDisable(TIMER0_BASE, TIMER_B);
  TimerConfigure(TIMER0_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
  TimerIntDisable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
  TimerLoadSet(TIMER0_BASE, TIMER_B, 65535);
  TimerPrescaleSet(TIMER0_BASE, TIMER_B, 5); // One unit is 100ns
  TimerEnable(TIMER0_BASE, TIMER_B);

  // Initialize Timer1A: Used for sleep decrementing
  SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
  TimerDisable(TIMER1_BASE, TIMER_A);
  TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
  TimerIntDisable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
  TimerLoadSet(TIMER1_BASE, TIMER_A, 50000); // Every interrupt is 1ms

  // Setting priorities for all interrupts
  // To add more, look up correct names in inc\hw_ints.h

  IntPrioritySet(FAULT_PENDSV, (0x07 << 5));
  IntPrioritySet(FAULT_SYSTICK, (0x06 << 5));

  IntPrioritySet(INT_TIMER1A, (0x02 << 5));
  IntPrioritySet(INT_UART0, (0x03 << 5));
  IntPrioritySet(INT_ADC0SS0, (0x01 << 5));
  IntPrioritySet(INT_ADC0SS3, (0x01 << 5));

  // Initializing TCBs
  for(i = 0; i < MAXTHREADS; i++) {
    tcbs[i].valid = INVALID;
    tcbs[i].blockedState = '\0';
  }

  RunPt = &tcbs[0]; // Thread 0 will run first
}
Exemple #18
0
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");
		}
		

  }
}
Exemple #19
0
int main(void){
	int i = 0;
	//Score set
	score = 0;
	PLL_Init();
	//Sound init
	DAC_Init();
	Timer0A_Init(Sound_Update, 1000000/11025);
//	Timer0B_Init(updateXAxis, 1000000/11025);
//	Timer1B_Init(updateYAxis, 1000000/11025);
	//Input
	ADC_Init();
	portD_Init();
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
												GPIOPinTypeGPIOInput(GPIO_PORTG_BASE,
												(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7));
												GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
												GPIOPadConfigSet(GPIO_PORTG_BASE,
												(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7),
												GPIO_STRENGTH_2MA,
												GPIO_PIN_TYPE_STD_WPU);
	SysTick_Init(50000000/400);
	Output_Init();
	Output_Color(15);
	SysTick_IntEnable();
	EnableInterrupts();
	//Set flags
	gFlags = 0;
	HWREGBITW(&gFlags, TITLE_SCREEN) = True;	
	//Math rand set seed
	while(HWREGBITW(&gFlags, SELECT_DOWN) == 0 &&
				((GPIO_PORTG_DATA_R & 0x80) != 0)) { }
	while(HWREGBITW(&gFlags, SELECT_DOWN) == 1 ||
				((GPIO_PORTG_DATA_R & 0x80) == 0)) { }
	setSeed(NVIC_ST_CURRENT_R);
	//Game set
	setGraphics(1);//the lm3s can't handle more than 2 rocks at graphics level 3.
	gameInit();
	gameSet(0);
	while(1) {
		//Only draw to buffer when it has been output to the screen
		if(HWREGBITW(&gFlags, FRAME_BUFFER_READY) == False) {
			/*if(gameLevel == -2) {
				drawString(myMsgs[1], makePoint(50, 40));
				while ((GPIO_PORTG_DATA_R & 0x80) != 0 &&
							 HWREGBITW(&gFlags, SELECT_DOWN) == False) { }
				while ((GPIO_PORTG_DATA_R & 0x80) == 0 &&
							 HWREGBITW(&gFlags, SELECT_DOWN) == True) { }
				//Reset game
			*/
			//Check for level completion, aka all rocks and enemies are 
			//TODO: enemies
			if(HWREGBITW(&gFlags, LEVEL_COMPLETE) == True) { gameSet(++gameLevel); }
			//Redraw the screen from scratch.
			clearBuffer();
			//Draw the player.
			if(gPlayer.status == ALIVE) {
				drawPlayer(makePoint((int)gPlayer.x, (int)gPlayer.y),
									 gPlayer.angle, gPlayer.exhaustOn);
			}
			for(i = 0; i < MAX_ROCKS; i++) {
				if(gRocks[i].status == ALIVE) {
					drawRock(makePoint(gRocks[i].x, gRocks[i].y),
									 gRocks[i].rockType, gRocks[i].rockSize);
				}
			}
			//Draw allied bullets.
			for(i = 0; i < MAX_PLAYER_BULLETS; i++) {
				if(gPlayerBullets[i].status == ALIVE) {
					drawBullet(makePoint(gPlayerBullets[i].x, gPlayerBullets[i].y));
				}
			}
			//Draw enemy bullets.
			for(i = 0; i < MAX_ENEMY_BULLETS; i++) {
				if(gEnemyBullets[i].status == ALIVE) {
					drawBullet(makePoint(gEnemyBullets[i].x, gEnemyBullets[i].y));
				}
			}
			//Draw explosions.
			for(i = 0; i < MAX_EXPLOSIONS; i++) {
				if(gExplosions[i].status == ALIVE) {
					drawExplosion(gExplosions[i].pos, gExplosions[i].current);
				}
			}
			
			//
			drawNumber(score, makePoint(2,2));
			drawNumber(gameLevel, makePoint(128/2-6,2));
			
			if(HWREGBITW(&gFlags, GAME_OVER) == True) {
				drawString("GAME OVER", makePoint(40, 38));
				if((GPIO_PORTG_DATA_R & 0x80)) {
					//reset game
				}
				gameUpdate();
			} else if(HWREGBITW(&gFlags, TITLE_SCREEN) == True) {
				drawString("ASTEROIDS", makePoint(40, 38));
				gameLevel = 0;
			}
			updateXAxis();
			gameUpdate();
			HWREGBITW(&gFlags, FRAME_BUFFER_READY) = True;
		}
	}
}
Exemple #20
0
int main(void){
	volatile uint32_t delay;
	int i;
	
	PLL_Init();
	Output_Init();
//	CAN0_Open();
	
	DisableInterrupts();
	
	SYSCTL_RCGCGPIO_R |= 0x20;
  while((SYSCTL_PRGPIO_R&0x0020) == 0){};// ready?
  Count = 0;                       // allow time to finish activating
//  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
	
	GPIO_PORTF_LOCK_R = 0x4C4F434B;   // 2) unlock GPIO Port F
	GPIO_PORTF_CR_R = 0x1F;           // allow changes to PF4-0
	GPIO_PORTF_AMSEL_R = 0x00;        // 3) disable analog on
    
	GPIO_PORTF_DIR_R &= ~0x03;       // make PB6 in
  GPIO_PORTF_AFSEL_R |= 0x03;      // enable alt funct on PB6
  GPIO_PORTF_DEN_R |= 0x03;        // enable digital I/O on PB6
                                   // configure PB6 as T0CCP0
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFFF00)+0x00000077;
  GPIO_PORTF_AMSEL_R &= ~0xFF;     // disable analog functionality on PB6
		
	SYSCTL_RCGCGPIO_R  |= 0x01;
	delay = SYSCTL_RCGCGPIO_R;      // 2) allow time for clock to stabilize
  delay = SYSCTL_RCGCGPIO_R;
	GPIO_PORTA_DIR_R |= 0x01;  			// 3.11) make PA6 output
  GPIO_PORTA_AFSEL_R &= ~0x01; 		// 4.11) disable alternate function on PA6
  GPIO_PORTA_DEN_R |= 0x01;  			// 5.11) enable digital I/O on PA6
  GPIO_PORTA_AMSEL_R = 0; 				// 6.11) disable analog functionality on PA6	
	Switch_Init();
	
	Init_Timer4A();
	Timer4A_Wait(80000000); //wait 1 sec
	Init_Timer5A(80000);
	ADC0_InitTimer3ATriggerSeq3PD3(6000);
	ADC0_InitTimer3BTriggerSeq2PD2(5500);
	
	TimerCapture_Init(UserTask2);
	InitMotors();
	
	EnableInterrupts();
	
	
	while(1) {
		getSensorValues();
		printSensorValues(0);
		if(buttonL) {
			printSensorValues(6);
			ControlMotors(35000,35000);
			ST7735_SetCursor(0,8);ST7735_OutString("Buttonback");
			buttonL = 0;
			for(i = 0; i < 1440000; i++);
		}
		if(buttonR) {
			printSensorValues(6);
			ControlMotors(35000,35000);
			ST7735_SetCursor(0,1);ST7735_OutString("ButtonR");
			buttonR = 0;
			for(i = 0; i < 1440000; i++);
		}
		
		if (Ping1 < 18) {
			//ControlMotors(40000, 40000);
			ST7735_SetCursor(0,1);
			ST7735_OutString("Stopped");
			printSensorValues(3);
//			while(1) {
				ST7735_SetCursor(0,1);ST7735_OutString("Stopped");
				getSensorValues();
				printSensorValues(0);
//			}
			if(IR_L > IR_R) {
				ControlMotors(35000,35000);
				ST7735_SetCursor(0,8);ST7735_OutString("BL");
			}
			else {
				ControlMotors(35000,35000);
				ST7735_SetCursor(0,8);ST7735_OutString("BR");
			}
			for(i = 0; i < 1440000; i++);
		}
		else if (((Ping2 > 80) != (Ping3 > 80)) && (Ping1 < 40)) {
			if (Ping2>80) {
				//spot turn right
				ControlMotors(20000, 60000);
			}
			if (Ping3>80) {
				//spot turn left
				ControlMotors(60000, 20000); 
			}
		//	ControlMotors(40000,40000);
		}
		else if(IR_L < 1500 && IR_R < 1500) {
			ControlMotors(70000,65000);
			ST7735_SetCursor(0,8);ST7735_OutString("FO");
		}
		else if(IR_L < IR_R) {
			ControlMotors(70000,50000);
			ST7735_SetCursor(0,8);ST7735_OutString("LE");
		}
		else if(IR_R < IR_L) {
			ControlMotors(70000,72000);
			ST7735_SetCursor(0,8);ST7735_OutString("RI");
		}
	}
}