//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(); } }
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) {}; }
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 } } }
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; } } }