1 /* Copyright (C) 2013 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
29 * RPP test suite - module for testing MOUT.
39 #define FREQ_MILLIS 1000
43 static boolean_t stop_tasks = FALSE;
44 static uint8_t tasks_running = 0;
47 * FreeRTOS Task that toggle the MOUT outputs, then reads the diagnostics and
50 void mout_test_task(void *par)
52 rpp_sci_printf((const char *)
53 "Power Output Test:\r\n"
55 rpp_sci_printf((const char *)
56 "===========================================================\r\n"
58 rpp_sci_printf((const char *)
60 // 1:BAD 1:BAD 1:BAD 1:BAD 1:BAD 1:BAD
61 // 1: OK 1: OK 1: OK 1: OK 1: OK 1: OK
64 // Calculate wait time in OS ticks
65 static const portTickType freq_ticks = FREQ_MILLIS / portTICK_RATE_MS;
66 portTickType last_wake_time = xTaskGetTickCount();
71 boolean_t state = TRUE;
74 // Toggle state one by one slowly
75 for (pin = 1; pin <= 6; pin++) {
78 rpp_mout_set(pin, state);
81 rpp_sci_printf((const char *)
82 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
83 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
87 for (pin = 1; pin <= 6; pin++) {
88 rpp_sci_printf((const char *)
89 "%d: ", rpp_mout_get(pin)
94 // Wait for next change
96 vTaskDelayUntil(&last_wake_time, freq_ticks);
104 rpp_sci_printf((const char *)
105 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
106 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
109 for (i = 0; i < 10; i++) {
111 // Wait until next step
113 vTaskDelayUntil(&last_wake_time, freq_ticks);
117 rpp_sci_printf((const char *)
118 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
119 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
122 for (pin = 1; pin <= 6; pin++) {
123 rpp_sci_printf((const char *)
124 "%d:%s ", rpp_mout_get(pin),
125 (rpp_mout_diag(pin) == SUCCESS) ? " OK" : "BAD"
139 * MOUT Test entry point.
148 xTaskHandle test_task_handle;
150 portBASE_TYPE task_created = xTaskCreate(mout_test_task,
151 (const signed char *)"mout_test_task",
152 TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
156 if (task_created != pdPASS) {
158 rpp_sci_printf((const char *)
159 "ERROR: Problem spawning the test task. "
160 "Error code: %d\r\n", (uint32_t)task_created
168 // Wait for user exit
171 while (tasks_running > 0)
176 /// Reset module configuration
178 for (pin = 1; pin <= 6; pin++) {
179 rpp_mout_set(pin, LOW);
183 rpp_sci_printf((const char *)"\r\n");