1 /* Copyright (C) 2013 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * RPP test suite - module for testing AIN.
31 #define FREQ_MILLIS 1000
35 * FreeRTOS Task that read analog inputs and prints them on the SCI.
37 void ain_test_task(void* par)
39 rpp_sci_printf((const char*)"Analog Inputs Test [1-12]:\r\n");
40 rpp_sci_printf((const char*)"================================\r\n");
42 // Calculate wait time in OS ticks
43 static const portTickType freq_ticks = FREQ_MILLIS / portTICK_RATE_MS;
44 portTickType last_wake_time = xTaskGetTickCount();
52 // Terminal needs to be at least 59 chars long
53 rpp_sci_printf((const char*)
54 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
55 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
57 rpp_sci_printf((const char*)
58 "%4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d",
73 // Wait until next step
74 vTaskDelayUntil(&last_wake_time, freq_ticks);
80 * AIN Test entry point.
84 xTaskHandle test_task_handle;
86 rpp_sci_printf((const char*)"Try to create task.\r\n");
87 portBASE_TYPE task_created = xTaskCreate(ain_test_task,
88 (const signed char*)"ain_test_task",
89 TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
92 rpp_sci_printf((const char*)"After try to create task.\r\n");
94 if(task_created != pdPASS) {
96 rpp_sci_printf((const char*)
97 "ERROR: Problem spawning the test task. "
98 "Error code: %d\r\n", (uint32_t)task_created
106 vTaskDelete(test_task_handle);
107 vTaskDelay(4); // Allow the idle task to free memory