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 * Power Output (12V, 2A, Push/Pull) RPP API implementation file.
17 * RPP API documentation.
23 #ifndef FREERTOS_POSIX
27 static boolean_t initialized = FALSE;
29 int8_t rpp_mout_init()
34 #ifndef FREERTOS_POSIX
44 static uint8_t cache[] = {
45 LOW, LOW, LOW, LOW, LOW, LOW
48 int8_t rpp_mout_set(uint8_t pin, uint8_t val)
51 if ((pin < 1) || (pin > 6))
55 if ((val != HIGH) && (val != LOW))
58 uint8_t idx = pin - 1;
60 #ifndef FREERTOS_POSIX
61 // Set and store value
62 if (drv_mout_set(idx, val) != SUCCESS)
66 // FIXME Wait some time for synchronization
67 // Don't use vTaskDelay() here because the minimum time to wait is one tick,
68 // and depending of the configuration of the user model one tick can overrun
71 for (wait = 0; wait < 10; wait++) {
75 // Get value back and compare
76 if (drv_mout_diag(idx) == FAILURE)
87 int8_t rpp_mout_get(uint8_t pin)
90 if ((pin < 1) || (pin > 6))
93 return cache[pin - 1];
97 int8_t rpp_mout_diag(uint8_t pin)
100 if ((pin < 1) || (pin > 6))
103 #ifndef FREERTOS_POSIX
104 if (drv_mout_diag(pin - 1) == 0)