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 DIN.
31 #define FREQ_MILLIS 1000
35 * FreeRTOS Task that read digital inputs and prints them on the SCI.
37 void din_test_task(void* par)
39 rpp_sci_printf((const char*)"Digital Inputs Test [1-16]:\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();
48 for(pin = 1; pin <= 16; pin++) {
49 rpp_din_setup(pin, FALSE, TRUE, FALSE);
55 // Wait until next step
56 vTaskDelayUntil(&last_wake_time, freq_ticks);
62 // Terminal needs to be at least 31 chars long
63 rpp_sci_printf((const char*)
64 "\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\b"
67 rpp_sci_printf((const char*)
68 "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
69 rpp_din_get( 1, FALSE),
70 rpp_din_get( 2, FALSE),
71 rpp_din_get( 3, FALSE),
72 rpp_din_get( 4, FALSE),
73 rpp_din_get( 5, FALSE),
74 rpp_din_get( 6, FALSE),
75 rpp_din_get( 7, FALSE),
76 rpp_din_get( 8, FALSE),
77 rpp_din_get( 9, FALSE),
78 rpp_din_get(10, FALSE),
79 rpp_din_get(11, FALSE),
80 rpp_din_get(12, FALSE),
81 rpp_din_get(13, FALSE),
82 rpp_din_get(14, FALSE),
83 rpp_din_get(15, FALSE),
84 rpp_din_get(16, FALSE)
91 * DIN Test entry point.
95 xTaskHandle test_task_handle;
97 portBASE_TYPE task_created = xTaskCreate(din_test_task,
98 (const signed char*)"din_test_task",
99 TEST_TASK_TASK, NULL, TEST_TASK_PRIORITY,
103 if(task_created != pdPASS) {
105 rpp_sci_printf((const char*)
106 "ERROR: Problem spawning the test task. "
107 "Error code: %d\r\n", (uint32_t)task_created
114 vTaskDelete(test_task_handle);