]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/src/drv/mout.c
Merge branch 'master' of ssh://rtime.felk.cvut.cz/jenkicar/rpp-simulink
[pes-rpp/rpp-lib.git] / rpp / src / drv / mout.c
1 /* Copyright (C) 2012-2013 Czech Technical University in Prague
2  *
3  * Authors:
4  *     - Carlos Jenkins <carlos@jenkins.co.cr>
5  *
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.
10  *
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.
15  *
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/>.
18  *
19  * File : mout.c
20  * Abstract:
21  *     RPP driver implementation for MOUT.
22  *
23  * References:
24  *     hal/gpio_tms570.h
25  *     hal/gpio_tms570_def.h
26  */
27
28
29 #include "drv/mout.h"
30
31 const static uint32_t dsc_pin_map[6U][2U] = {
32     {PIN_DSC_MOUT1IN, PIN_DSC_MOUT1EN},
33     {PIN_DSC_MOUT2IN, PIN_DSC_MOUT2EN},
34     {PIN_DSC_MOUT3IN, PIN_DSC_MOUT3EN},
35     {PIN_DSC_MOUT4IN, PIN_DSC_MOUT4EN},
36     {PIN_DSC_MOUT5IN, PIN_DSC_MOUT5EN},
37     {PIN_DSC_MOUT6IN, PIN_DSC_MOUT6EN}
38 };
39
40
41 int8_t drv_mout_set(uint8_t pin, uint8_t val)
42 {
43     // Check range
44     if(pin > 5) {
45         return -1;
46     }
47
48     hal_gpio_pin_set_value(dsc_pin_map[pin][0], val);
49     return SUCCESS;
50 }
51
52
53 int8_t drv_mout_diag(uint8_t pin)
54 {
55     // Check range
56     if(pin > 5) {
57         return -1;
58     }
59
60     if(hal_gpio_pin_get_value(dsc_pin_map[pin][1]) == 1) {
61         return HIGH;
62     }
63     return LOW;
64 }
65