/////////////////////////////////////////////////// // MAIN // /////////////////////////////////////////////////// int main () { int i=0; init(); clrscr(); do { WelcomeScreen(); i++; if(i==10) { clrscr(); error(-1); } } while(1); return 0; }
/*---------------------------------------------------------------------------- Main Program *----------------------------------------------------------------------------*/ int main (void) { int i; char potOutput[20]; char answer[10]; //Following statement sets the timer interrupt frequency //The clock rate on this boards MCU is 72 Mhz - this means //every second there will be 72 million clocks. So, if use this //as the parameter to the function the interrupt rate is going //to be every second. If it is reduced to 100 times less then //it will do that many clocks in 100 times less time, i.e. 10 msecs. //NOTE: We could have chosen to generate a timer interrupt every 1 msec //if we wished and that would be quite acceptable in which case we would //need to modify the interrupt handler routine in IRQ.c file. SysTick_Config(SystemCoreClock/10000); /* Generate interrupt each 10 ms */ LED_init(); /* LED Initialization */ pin_PA4_For_Speaker(); //Function that initializes the Speaker ADC_init(); //Function that initializes ADC GLCD_Init(); /* Initialize graphical LCD display */ joyStick_Init(); // Initialise the joystick userButton_Init(); // Initialise User Button userButton_IntrEnable(); //initialise the User button as an interrupt source //Here we initialise the Joystick switches as interrupt sources joyStick_IntrEnable_PG15_13(); joyStick_IntrEnable_PG7(); joyStick_IntrEnable_PD3(); AD_done = 0; ADC1->CR2 |= (1UL << 22); //Start the ADC conversion doTone = 0; WelcomeScreen(); // initialiseGetAnswer(answer, 10); // if(currentState == ON_DIFFICULTY_SCREEN) // { // GLCD_Clear(White); // if(currDifficulty == 0){ // currDifficulty = 1; // } // updateNextDifficulty(nextDifficulty); // DisplayInstructions(NULL,currentScore,currDifficulty,1); // DrawBarGraph(BAR_X,BAR_Y,currDifficulty * 20,BAR_HEIGHT,BAR_VALUE); // } while (TRUE) { // Program pauses whilst Countdown timer ticks - this is necessary because the program does not like interrupts and delay timers // i.e. SysTick does not work whilst interrupts being handled // Gives the user time to memorise the code // Program then advances to accept answer state if(currentState == QUESTION_SCREEN) { // Question Screen Delay countdown timer RunTimer(5000); currentState = ANSWER_SCREEN; answerScreen(); Vectored_Interrupt(USER_BUTTON); // Simulate user pressing the button } // // //RunTimer(TIMER_LENGTH); // GLCD_SetBackColor(Red); // DrawBarGraph(100,6*24,barWidth,15,1); // delay10th(10000); // GLCD_SetBackColor(White); // barWidth -= 20; // if(barWidth <= 0){ // barWidth = 100; // } // GLCD_DisplayString(6,0,__FI," "); //Check to see if ADC sampling is completed // if (AD_done) { // //Yes, so get part of the sample value // c = (AD_last >> 8) + 4; // if (doTone) { // //If enabled, switch the tone on // sprintf(potOutput,"Pot = %d",c); // displayTestMessage(1,0,potOutput,0); // generate_Tone_On_Speaker(c * 50, 10); // } // AD_done = 0; //Reset the ADC complete flag waiting for next sample // ADC1->CR2 |= (1UL << 22); //Start the next ADC conversion } }