This shows you the differences between two versions of the page.
milestone_3_task_2 [2023/02/20 21:22] scott [Hit LED Timer] |
milestone_3_task_2 [2023/03/02 17:53] (current) scott [Source Code] |
||
---|---|---|---|
Line 62: | Line 62: | ||
* drivers/switches.h | * drivers/switches.h | ||
* include/leds.h | * include/leds.h | ||
+ | * include/mio.h | ||
+ | * include/utils.h | ||
* lasertag/main.c | * lasertag/main.c | ||
* lasertag/transmitter.h | * lasertag/transmitter.h | ||
Line 323: | Line 325: | ||
void transmitter_runTest() { | void transmitter_runTest() { | ||
printf("starting transmitter_runTest()\n"); | printf("starting transmitter_runTest()\n"); | ||
- | mio_init(false); | ||
- | buttons_init(); // Using buttons | ||
- | switches_init(); // and switches. | ||
transmitter_init(); // init the transmitter. | transmitter_init(); // init the transmitter. | ||
- | transmitter_enableTestMode(); // Prints diagnostics to stdio. | + | while (!(buttons_read() & BUTTONS_BTN3_MASK)) { // Run continuously until BTN3 is pressed. |
- | while (!(buttons_read() & BUTTONS_BTN1_MASK)) { // Run continuously until BTN1 is pressed. | + | |
uint16_t switchValue = switches_read() % FILTER_FREQUENCY_COUNT; // Compute a safe number from the switches. | uint16_t switchValue = switches_read() % FILTER_FREQUENCY_COUNT; // Compute a safe number from the switches. | ||
transmitter_setFrequencyNumber(switchValue); // set the frequency number based upon switch value. | transmitter_setFrequencyNumber(switchValue); // set the frequency number based upon switch value. | ||
Line 338: | Line 336: | ||
printf("completed one test period.\n"); | printf("completed one test period.\n"); | ||
} | } | ||
- | transmitter_disableTestMode(); | ||
do {utils_msDelay(BOUNCE_DELAY);} while (buttons_read()); | do {utils_msDelay(BOUNCE_DELAY);} while (buttons_read()); | ||
printf("exiting transmitter_runTest()\n"); | printf("exiting transmitter_runTest()\n"); | ||
Line 437: | Line 434: | ||
As you transition to the state when the "press" of the trigger has been successfully debounced, print the 'D' character to the console using the DPCHAR() macro shown above. Make sure that you only print the 'D' character once as you enter the state when the trigger switch has been successfully debounced. Similarly, print out a 'U' character when the release of the trigger has been debounced. If you only print out a single 'D' and a single 'U' for each press-release of BTN0, the trigger is probably getting debounced properly. | As you transition to the state when the "press" of the trigger has been successfully debounced, print the 'D' character to the console using the DPCHAR() macro shown above. Make sure that you only print the 'D' character once as you enter the state when the trigger switch has been successfully debounced. Similarly, print out a 'U' character when the release of the trigger has been debounced. If you only print out a single 'D' and a single 'U' for each press-release of BTN0, the trigger is probably getting debounced properly. | ||
- | In ''trigger_runTest()'', enable the trigger state machine and demonstrate the required behavior to the TA. | + | In ''trigger_runTest()'', enable the trigger state machine and demonstrate the required behavior to a TA. |
==== Hit LED Timer ==== | ==== Hit LED Timer ==== | ||
Line 464: | Line 461: | ||
- Print out the time duration from the interval timer. | - Print out the time duration from the interval timer. | ||
- | Show the TA the execution of ''lockoutTimer_runTest()''. | + | Show a TA the execution of ''lockoutTimer_runTest()''. |
==== Code Submission ==== | ==== Code Submission ==== |