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 * Power Output (12V, 2A, Push/Pull) RPP API implementation file.
25 * RPP API documentation.
31 #if rppCONFIG_INCLUDE_MOUT == 1
33 #if rppCONFIG_DRV == 1
37 static boolean_t initialized = FALSE;
39 int8_t rpp_mout_init()
50 static uint8_t cache[] = {
51 LOW, LOW, LOW, LOW, LOW, LOW
54 int8_t rpp_mout_set(uint8_t pin, uint8_t val)
57 if((pin < 1) || (pin > 6)) {
62 if((val != HIGH) && (val != LOW)) {
66 #if rppCONFIG_DRV == 1
67 uint8_t idx = pin - 1;
69 // Set and store value
70 if(drv_mout_set(idx, val) != SUCCESS) {
75 // FIXME Wait some time for synchronization
76 // Don't use vTaskDelay() here because the minimum time to wait is one tick,
77 // and depending of the configuration of the user model one tick can overrun
80 for(wait = 0; wait < 10; wait++) {
84 // Get value back and compare
85 if(drv_mout_diag(idx) != val) {
94 int8_t rpp_mout_get(uint8_t pin)
97 if((pin < 1) || (pin > 6)) {
101 return cache[pin - 1];
105 int8_t rpp_mout_diag(uint8_t pin)
108 if((pin < 1) || (pin > 6)) {
112 #if rppCONFIG_DRV == 1
113 return drv_mout_diag(pin - 1);
120 #endif /* rppCONFIG_INCLUDE_MOUT */