1 /* Copyright (C) 2013 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
6 * This document contains proprietary information belonging to Czech
7 * Technical University in Prague. Passing on and copying of this
8 * document, and communication of its contents is not permitted
9 * without prior written authorization.
13 * RPP test suite - module for testing MOUT.
23 #define FREQ_MILLIS 1000
27 static boolean_t stop_tasks = FALSE;
28 static uint8_t tasks_running = 0;
31 * FreeRTOS Task that toggle the MOUT outputs, then reads the diagnostics and
34 void mout_test_task(void *par)
36 rpp_sci_printf((const char *)
37 "Power Output Test:\r\n"
39 rpp_sci_printf((const char *)
40 "===========================================================\r\n"
42 rpp_sci_printf((const char *)
44 // 1:BAD 1:BAD 1:BAD 1:BAD 1:BAD 1:BAD
45 // 1: OK 1: OK 1: OK 1: OK 1: OK 1: OK
48 // Calculate wait time in OS ticks
49 static const portTickType freq_ticks = FREQ_MILLIS / portTICK_RATE_MS;
50 portTickType last_wake_time = xTaskGetTickCount();
55 boolean_t state = TRUE;
58 // Toggle state one by one slowly
59 for (pin = 1; pin <= 6; pin++) {
62 rpp_mout_set(pin, state);
65 rpp_sci_printf((const char *)
66 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
67 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
71 for (pin = 1; pin <= 6; pin++) {
72 rpp_sci_printf((const char *)
73 "%d: ", rpp_mout_get(pin)
78 // Wait for next change
80 vTaskDelayUntil(&last_wake_time, freq_ticks);
88 rpp_sci_printf((const char *)
89 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
90 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
93 for (i = 0; i < 10; i++) {
95 // Wait until next step
97 vTaskDelayUntil(&last_wake_time, freq_ticks);
101 rpp_sci_printf((const char *)
102 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
103 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
106 for (pin = 1; pin <= 6; pin++) {
107 rpp_sci_printf((const char *)
108 "%d:%s ", rpp_mout_get(pin),
109 (rpp_mout_diag(pin) == SUCCESS) ? " OK" : "BAD"
123 * MOUT Test entry point.
132 xTaskHandle test_task_handle;
134 portBASE_TYPE task_created = xTaskCreate(mout_test_task,
135 (const signed char *)"mout_test_task",
136 TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
140 if (task_created != pdPASS) {
142 rpp_sci_printf((const char *)
143 "ERROR: Problem spawning the test task. "
144 "Error code: %d\r\n", (uint32_t)task_created
152 // Wait for user exit
155 while (tasks_running > 0)
160 /// Reset module configuration
162 for (pin = 1; pin <= 6; pin++) {
163 rpp_mout_set(pin, LOW);
167 rpp_sci_printf((const char *)"\r\n");