int main() { // init the display so we can draw on it! display_init(); // fill the display with black so it's all ready to have buttons drawn on it display_fillScreen(DISPLAY_BLACK); // Init all interrupts (but does not enable the interrupts at the devices). // Prints an error message if an internal failure occurs because the argument = true. interrupts_initAll(true); interrupts_setPrivateTimerLoadValue(TIMER_LOAD_VALUE); printf("timer load value:%ld\n\r", (int32_t) TIMER_LOAD_VALUE); u32 privateTimerTicksPerSecond = interrupts_getPrivateTimerTicksPerSecond(); printf("private timer ticks per second: %ld\n\r", privateTimerTicksPerSecond); interrupts_enableTimerGlobalInts(); // Initialization of the clock display is not time-dependent, do it outside of the state machine. // clockDisplay_init(); // Start the private ARM timer running. interrupts_startArmPrivateTimer(); // Enable interrupts at the ARM. interrupts_enableArmInts(); // The while-loop just waits until the total number of timer ticks have occurred before proceeding. while (interrupts_isrInvocationCount() < (TOTAL_SECONDS * privateTimerTicksPerSecond)); // All done, now disable interrupts and print out the interrupt counts. interrupts_disableArmInts(); printf("isr invocation count: %ld\n\r", interrupts_isrInvocationCount()); printf("internal interrupt count: %ld\n\r", isr_functionCallCount); return 0; }
/** * More advanced test that uses timer interrupts */ void test_Full() { // Initialize the GPIO LED driver and print out an error message if it fails (argument = true). // You need to init the LEDs so that LED4 can function as a heartbeat. leds_init(true); // Init all interrupts (but does not enable the interrupts at the devices). // Prints an error message if an internal failure occurs because the argument = true. interrupts_initAll(true); interrupts_setPrivateTimerLoadValue(TIMER_LOAD_VALUE); u32 privateTimerTicksPerSecond = interrupts_getPrivateTimerTicksPerSecond(); printf("private timer ticks per second: %ld\n\r", privateTimerTicksPerSecond); // Allow the timer to generate interrupts. interrupts_enableTimerGlobalInts(); // Initialization of the clock display is not time-dependent, do it outside of the state machine. //ticTacToeDisplay_init(); // Keep track of your personal interrupt count. Want to make sure that you don't miss any interrupts. int32_t personalInterruptCount = 0; // Start the private ARM timer running. interrupts_startArmPrivateTimer(); // Enable interrupts at the ARM. interrupts_enableArmInts(); // interrupts_isrInvocationCount() returns the number of times that the timer ISR was invoked. // This value is maintained by the timer ISR. Compare this number with your own local // interrupt count to determine if you have missed any interrupts. double duration_max = 0.0; while (interrupts_isrInvocationCount() < (TOTAL_SECONDS * privateTimerTicksPerSecond)) { if (interrupts_isrFlagGlobal) { // This is a global flag that is set by the timer interrupt handler. // Count ticks. personalInterruptCount++; intervalTimer_initAll(); intervalTimer_start(INTERVALTIMER_TIMER0); ticTacToeControl_tick(); intervalTimer_stop(INTERVALTIMER_TIMER0); // print out the longest tick execution time for user reference. double duration; // measured with the intervalTimer intervalTimer_getTotalDurationInSeconds(INTERVALTIMER_TIMER0, &duration); // If this duration was larger than the previous max, update the values // and print it out. if (duration_max < duration) { duration_max = duration; printf("Duration:%lf\n", duration); } intervalTimer_resetAll(); interrupts_isrFlagGlobal = 0; } } interrupts_disableArmInts(); printf("isr invocation count: %ld\n\r", interrupts_isrInvocationCount()); printf("internal interrupt count: %ld\n\r", personalInterruptCount); }
int main() { srand(LARGE_PRIME_NUMBER); // Initialize the GPIO LED driver and print out an error message if it fails (argument = true). // You need to init the LEDs so that LD4 can function as a heartbeat. leds_init(true); // Init all interrupts (but does not enable the interrupts at the devices). // Prints an error message if an internal failure occurs because the argument = true. interrupts_initAll(true); interrupts_setPrivateTimerLoadValue(TIMER_LOAD_VALUE); u32 privateTimerTicksPerSecond = interrupts_getPrivateTimerTicksPerSecond(); printf("private timer ticks per second: %ld\n\r", privateTimerTicksPerSecond); // Allow the timer to generate interrupts. interrupts_enableTimerGlobalInts(); // Initialization of the clock display is not time-dependent, do it outside of the state machine. //TicTacToeDisplay_init(); display_init(); display_fillScreen(DISPLAY_BLACK); buttons_init(); // Keep track of your personal interrupt count. Want to make sure that you don't miss any interrupts. int32_t personalInterruptCount = 0; // Start the private ARM timer running. interrupts_startArmPrivateTimer(); // Enable interrupts at the ARM. interrupts_enableArmInts(); // interrupts_isrInvocationCount() returns the number of times that the timer ISR was invoked. // This value is maintained by the timer ISR. Compare this number with your own local // interrupt count to determine if you have missed any interrupts. while (interrupts_isrInvocationCount() < (TOTAL_SECONDS * privateTimerTicksPerSecond)) { if (interrupts_isrFlagGlobal) { // This is a global flag that is set by the timer interrupt handler. // Count ticks. double duration0; personalInterruptCount++; SimonControl_tick(); verifySequence_tick(); flashSequence_tick(); simonbuttonHandler_tick(); interrupts_isrFlagGlobal = FLAG_DOWN; } } interrupts_disableArmInts(); printf("isr invocation count: %ld\n\r", interrupts_isrInvocationCount()); printf("internal interrupt count: %ld\n\r", personalInterruptCount); return 0; }
int main() { //buttonHandler_runTest(10); //flashSequence_runTest(); //verifySequence_runTest(); // The formula for computing the load value is based upon the formula from 4.1.1 (calculating timer intervals) // in the Cortex-A9 MPCore Technical Reference Manual 4-2. // Assuming that the prescaler = 0, the formula for computing the load value based upon the desired period is: // load-value = (period * timer-clock) - 1 // Initialize the GPIO LED driver and print out an error message if it fails (argument = true). // You need to init the LEDs so that LD4 can function as a heartbeat. leds_init(true); // Init all interrupts (but does not enable the interrupts at the devices). // Prints an error message if an internal failure occurs because the argument = true. interrupts_initAll(true); interrupts_setPrivateTimerLoadValue(TIMER_LOAD_VALUE); u32 privateTimerTicksPerSecond = interrupts_getPrivateTimerTicksPerSecond(); printf("private timer ticks per second: %ld\n\r", privateTimerTicksPerSecond); // Allow the timer to generate interrupts. interrupts_enableTimerGlobalInts(); // Initialization of the Simon game state machines is not time-dependent so we do it outside of the state machine. display_init(); display_fillScreen(DISPLAY_BLACK); // Keep track of your personal interrupt count. Want to make sure that you don't miss any interrupts. int32_t personalInterruptCount = 0; // Start the private ARM timer running. interrupts_startArmPrivateTimer(); // Enable interrupts at the ARM. interrupts_enableArmInts(); // interrupts_isrInvocationCount() returns the number of times that the timer ISR was invoked. // This value is maintained by the timer ISR. Compare this number with your own local // interrupt count to determine if you have missed any interrupts. double *seconds; while (interrupts_isrInvocationCount() < (TOTAL_SECONDS * privateTimerTicksPerSecond)) { if (interrupts_isrFlagGlobal) { // This is a global flag that is set by the timer interrupt handler. // Count ticks. personalInterruptCount++; verifySequence_tick(); flashSequence_tick(); buttonHandler_tick(); intervalTimer_start(1); simonControl_tick(); intervalTimer_stop(1); intervalTimer_getTotalDurationInSeconds(1,seconds); printf("%f \r\n",*seconds); //printf("interrupt count: %lu \r\n", interrupts_isrInvocationCount()); intervalTimer_reset(1); interrupts_isrFlagGlobal = 0; } } interrupts_disableArmInts(); printf("isr invocation count: %ld\n\r", interrupts_isrInvocationCount()); printf("internal interrupt count: %ld\n\r", personalInterruptCount); return 0; }