]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/src/drv/mout.c
323305183068c3694be92c4b5c7782b24d94cf10
[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 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.
10  *
11  * File : mout.c
12  * Abstract:
13  *     RPP driver implementation for MOUT.
14  *
15  * References:
16  *     hal/gpio_tms570.h
17  *     hal/gpio_tms570_def.h
18  */
19
20
21 #include "drv/mout.h"
22
23 const static uint32_t dsc_pin_map[6U][2U] = {
24         {PIN_DSC_MOUT1IN, PIN_DSC_MOUT1EN},
25         {PIN_DSC_MOUT2IN, PIN_DSC_MOUT2EN},
26         {PIN_DSC_MOUT3IN, PIN_DSC_MOUT3EN},
27         {PIN_DSC_MOUT4IN, PIN_DSC_MOUT4EN},
28         {PIN_DSC_MOUT5IN, PIN_DSC_MOUT5EN},
29         {PIN_DSC_MOUT6IN, PIN_DSC_MOUT6EN}
30 };
31
32
33 int8_t drv_mout_set(uint8_t pin, uint8_t val)
34 {
35         // Check range
36         if (pin > 5)
37                 return -1;
38
39         hal_gpio_pin_set_value(dsc_pin_map[pin][0], val);
40         return SUCCESS;
41 }
42
43
44 int8_t drv_mout_diag(uint8_t pin)
45 {
46         // Check range
47         if (pin > 5)
48                 return -1;
49
50         if (hal_gpio_pin_get_value(dsc_pin_map[pin][1]) == 1)
51                 return HIGH;
52         return LOW;
53 }