// runs a test to see if timers are operating correctly uint32_t intervalTimer_runTest(uint32_t timerNumber) { intervalTimer_init(timerNumber); //initialize the timer intervalTimer_reset(timerNumber); //reset the timer printf("timer_0 TCR0 should be 0 at this point:%ld\n\r", readTimerRegister(timerNumber, INTERVALTIMER_TCR0_OFFSET)); // Show that the timer is reset. printf("timer_0 TCR1 should be 0 at this point:%ld\n\r", readTimerRegister(timerNumber, INTERVALTIMER_TCR1_OFFSET)); //reset the TCR1 as well as TCR0 intervalTimer_start(timerNumber); // Show that the timer is running. printf("The following register values should be changing while reading them.\n\r"); //print statement to the screen printf("timer_0 TCR0 should be changing at this point:%ld\n\r", readTimerRegister(timerNumber, INTERVALTIMER_TCR0_OFFSET)); //these print the current values of the timer printf("timer_0 TCR0 should be changing at this point:%ld\n\r", readTimerRegister(timerNumber, INTERVALTIMER_TCR0_OFFSET)); //repeat multiple times to show that change is continuous as time passes printf("timer_0 TCR0 should be changing at this point:%ld\n\r", readTimerRegister(timerNumber, INTERVALTIMER_TCR0_OFFSET)); printf("timer_0 TCR0 should be changing at this point:%ld\n\r", readTimerRegister(timerNumber, INTERVALTIMER_TCR0_OFFSET)); printf("timer_0 TCR0 should be changing at this point:%ld\n\r", readTimerRegister(timerNumber, INTERVALTIMER_TCR0_OFFSET)); waitALongTime(); // Wait about 2 minutes so that you roll over to TCR1. printf("timer_0 TCR0 value after wait:%lx\n\r", readTimerRegister(timerNumber, INTERVALTIMER_TCR0_OFFSET));// If you don't see a '1' in TCR1 after this long wait you probably haven't programmed the timer correctly. printf("timer_0 TCR1 should have changed at this point:%ld\n\r", readTimerRegister(timerNumber, INTERVALTIMER_TCR1_OFFSET));//this shows the time that has passed }
uint32_t intervalTimer_runTest(uint32_t timerNumber) { intervalTimer_init(timerNumber); intervalTimer_reset(timerNumber); // Show that the timer is reset. printf("timer %ld TCR0 should be 0 at this point:%ld\n\r", timerNumber , readTimerRegister(INTERVALTIMER_TCR0_ADDRESS, timerNumber)); printf("timer %ld TCR1 should be 0 at this point:%ld\n\r", timerNumber , readTimerRegister(INTERVALTIMER_TCR0_ADDRESS, timerNumber)); // Statements returns false if TCR0 and TCR1 aren't 0 if (readTimerRegister(INTERVALTIMER_TCR0_ADDRESS , timerNumber) !=INTERVALTIMER_INITIALIZE) { return INTERVALTIMER_VALID_TIMER_FALSE; } if (readTimerRegister(INTERVALTIMER_TCR1_ADDRESS , timerNumber) !=INTERVALTIMER_INITIALIZE) { return INTERVALTIMER_VALID_TIMER_FALSE; } intervalTimer_start(timerNumber); // Show that the timer is running. // Test points for comparison u32 TP_One; u32 TP_Two; printf("The following register values should be changing while reading them.\n\r"); printf("timer %ld TCR0 should be changing at this point:%ld\n\r", timerNumber , readTimerRegister(INTERVALTIMER_TCR0_ADDRESS, timerNumber)); TP_One = readTimerRegister(INTERVALTIMER_TCR0_ADDRESS , timerNumber); printf("timer %ld TCR0 should be changing at this point:%ld\n\r", timerNumber , readTimerRegister(INTERVALTIMER_TCR0_ADDRESS, timerNumber)); printf("timer %ld TCR0 should be changing at this point:%ld\n\r", timerNumber , readTimerRegister(INTERVALTIMER_TCR0_ADDRESS, timerNumber)); printf("timer %ld TCR0 should be changing at this point:%ld\n\r", timerNumber , readTimerRegister(INTERVALTIMER_TCR0_ADDRESS, timerNumber)); TP_Two = readTimerRegister(INTERVALTIMER_TCR0_ADDRESS , timerNumber); printf("timer %ld TCR0 should be changing at this point:%ld\n\r", timerNumber , readTimerRegister(INTERVALTIMER_TCR0_ADDRESS, timerNumber)); // Statement returns false if TCR0 isn't changing if (TP_One == TP_Two) { return INTERVALTIMER_VALID_TIMER_FALSE; } // Wait about 2 minutes so that you roll over to TCR1. // If you don't see a '1' in TCR1 after this long wait you probably haven't programmed the timer correctly. waitALongTime(); printf("timer %ld TCR0 value after wait:%lx\n\r", timerNumber , readTimerRegister(INTERVALTIMER_TCR0_ADDRESS, timerNumber)); printf("timer %ld TCR1 should have changed at this point:%ld\n\r", timerNumber ,readTimerRegister(INTERVALTIMER_TCR1_ADDRESS, timerNumber)); // Statement returns false if TCR1 didn't change if (readTimerRegister(INTERVALTIMER_TCR1_ADDRESS , timerNumber) == INTERVALTIMER_INITIALIZE) { return INTERVALTIMER_VALID_TIMER_FALSE; } return INTERVALTIMER_VALID_TIMER_TRUE; }