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 100
35 static boolean_t stop_tasks = FALSE;
36 static uint8_t tasks_running = 0;
40 * FreeRTOS Task that read digital inputs and prints them on the SCI.
42 void din_test_task(void* par)
44 rpp_sci_printf((const char*)
45 "Digital Inputs Test [1-16]:\r\n"
47 rpp_sci_printf((const char*)
48 "===========================================================\r\n"
50 rpp_sci_printf((const char*)
51 "01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16\r\n"
52 // 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
55 // Calculate wait time in OS ticks
56 static const portTickType freq_ticks = FREQ_MILLIS / portTICK_RATE_MS;
57 portTickType last_wake_time = xTaskGetTickCount();
65 // Terminal needs to be at least 47 chars long
69 rpp_sci_printf((const char*)
70 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
71 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
74 rpp_sci_printf((const char*)
75 " %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
76 rpp_din_get( 1, FALSE),
77 rpp_din_get( 2, FALSE),
78 rpp_din_get( 3, FALSE),
79 rpp_din_get( 4, FALSE),
80 rpp_din_get( 5, FALSE),
81 rpp_din_get( 6, FALSE),
82 rpp_din_get( 7, FALSE),
83 rpp_din_get( 8, FALSE),
84 rpp_din_get( 9, FALSE),
85 rpp_din_get(10, FALSE),
86 rpp_din_get(11, FALSE),
87 rpp_din_get(12, FALSE),
88 rpp_din_get(13, FALSE),
89 rpp_din_get(14, FALSE),
90 rpp_din_get(15, FALSE),
91 rpp_din_get(16, FALSE)
94 // Wait until next step
96 vTaskDelayUntil(&last_wake_time, freq_ticks);
107 * DIN Test entry point.
114 for(pin = 1; pin <= 16; pin++) {
115 // Configure pin as pull-down, active, non-wake up
116 rpp_din_setup(pin, FALSE, TRUE, FALSE);
122 xTaskHandle test_task_handle;
124 portBASE_TYPE task_created = xTaskCreate(din_test_task,
125 (const signed char*)"din_test_task",
126 TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
130 if(task_created != pdPASS) {
132 rpp_sci_printf((const char*)
133 "ERROR: Problem spawning the test task. "
134 "Error code: %d\r\n", (uint32_t)task_created
142 // Wait for user exit
145 while(tasks_running > 0) {
151 /// Reset module configuration
155 rpp_sci_printf((const char*)"\r\n");