This shows you the differences between two versions of the page.
milestone_3_task_2 [2023/02/20 21:11] scott [Transmitter] |
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 ==== | ||
- | Goal: demonstrate that your hitLedTimer state machine illuminates LD0 and drives a '1' onto the JF-3 pin for 1/2 second each time it is activated. You will see LED1 blink on and off at 1/2-second intervals if this is working correctly. LED1 is directly connected to JF-3 and is provided for debug and pass off. | + | Goal: demonstrate that your hitLedTimer state machine illuminates LD0 and drives a '1' onto the JF-3 pin for 1/2 second each time it is activated. You will see LED1 blink on for 1/2-second intervals if this is working correctly. LED1 is directly connected to JF-3 and is provided for debug and pass off. |
In your ''hitLedTimer_runTest()'' function do the following inside a while-loop: | In your ''hitLedTimer_runTest()'' function do the following inside a while-loop: | ||
- | * Step 1: invoke ''hitLedTimer_start()'', | + | * Step 1: invoke ''hitLedTimer_start()''. |
* Step 2: wait until ''hitLedTimer_running()'' is false (use another while-loop for this). | * Step 2: wait until ''hitLedTimer_running()'' is false (use another while-loop for this). | ||
- | * Delay for 300 ms using utils_msDelay(). | + | * Step 3: Delay for 300 ms using utils_msDelay(). |
* Go back to Step 1. | * Go back to Step 1. | ||
- | Demonstrate to the TA that LD0 and LED1 is blinking at a rate of 1/2 second (this will be approximate because this will be a visual inspection). Also show the TA that pin "Hit Detected" has the appropriate waveform by attaching an oscilloscope probe to the "Hit Detected" pin. | + | Demonstrate to a TA that LD0 and LED1 blink on for 1/2 second (this is an approximate visual inspection). |
{{::hitledpicture.jpg?400|}} | {{::hitledpicture.jpg?400|}} | ||
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 ==== |