]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/src/drv/_tms570_rpp/port_def.c
a127ed413fd1fea8b633579437226255d8dda833
[pes-rpp/rpp-lib.git] / rpp / src / drv / _tms570_rpp / port_def.c
1 /*
2  * Copyright (C) 2015 Czech Technical University in Prague
3  *
4  * Authors:
5  *     - Michal Horn <hornmich@fel.cvut.cz>
6  *     - Michal Sojka <sojkam1@fel.cvut.cz>
7  *
8  * This document contains proprietary information belonging to Czech
9  * Technical University in Prague. Passing on and copying of this
10  * document, and communication of its contents is not permitted
11  * without prior written authorization.
12  *
13  */
14
15 #include "drv/port.h"
16 #include "drv/gio_names.h"
17 #include "drv/gio_tab.h"
18 #include "drv/spi.h"
19 #include "drv/spi_tms570.h"
20 #include "drv/adc.h"
21
22 // Lists of pins assigned to the gio ports
23 static enum pin_name pins_dinmcu[] = {
24                 PIN_DIN8, PIN_DIN9, PIN_DIN10, PIN_DIN11,
25                 PIN_DIN12, PIN_DIN13, PIN_DIN14, PIN_DIN15
26 };
27 static enum pin_name pins_houtin[] = {
28                 PIN_HOUT1IN, PIN_HOUT2IN, PIN_HOUT3IN,
29                 PIN_HOUT4IN, PIN_HOUT5IN, PIN_HOUT6IN
30 };
31 static enum pin_name pins_houtdiag[] = {
32                 PIN_HOUT1DIAG, PIN_HOUT2DIAG, PIN_HOUT3DIAG,
33                 PIN_HOUT4DIAG, PIN_HOUT5DIAG, PIN_HOUT6DIAG
34 };
35 static enum pin_name pins_mouten[] = {
36                 PIN_MOUT1EN, PIN_MOUT2EN, PIN_MOUT3EN,
37                 PIN_MOUT4EN, PIN_MOUT5EN, PIN_MOUT6EN
38 };
39 static enum pin_name pins_moutin[] = {
40                 PIN_MOUT1IN, PIN_MOUT2IN, PIN_MOUT3IN,
41                 PIN_MOUT4IN, PIN_MOUT5IN, PIN_MOUT6IN
42 };
43
44 const struct port_desc port_desc[] = {
45         [PORT_ID_DINMCU] = {
46                 .name = "DINMCU",
47                 .numchn = ARRAY_SIZE(pins_dinmcu),
48                 .bpch = 1,
49                 .get = port_gioset_get,
50                 .set = NULL,
51                 .cfg = { .gioset = { .pins = pins_dinmcu } },
52         },
53         [PORT_ID_DINSPI] = {
54                 .name = "DINSPI",
55                 .numchn = 1,
56                 .bpch = 24,
57                 .set = port_spi_set,
58                 .cfg = { .spi = { .ifc = 1, .cs = 0 } },
59         },
60         [PORT_ID_HOUTDIAG] = {
61                 .name = "HOUTDIAG",
62                 .numchn = ARRAY_SIZE(pins_houtdiag),
63                 .bpch = 1,
64                 .get = port_gioset_get,
65                 .set = NULL,
66                 .cfg = { .gioset = { .pins = pins_houtdiag } },
67         },
68         [PORT_ID_HOUTIN] = {
69                 .name = "HOUTIN",
70                 .numchn = ARRAY_SIZE(pins_houtin),
71                 .bpch = 1,
72                 .get = port_gioset_get,
73                 .set = port_gioset_set,
74                 .cfg = { .gioset = { .pins = pins_houtin } },
75         },
76         [PORT_ID_HOUTIFBK] = {
77                 .name = "HOUTIFBK",
78                 .numchn = 6,
79                 .bpch = 16,
80                 .get = port_adc_get,
81                 .set = NULL,
82                 .cfg = { .adc = { .reg = adcREG2, .group = adcGROUP1 } },
83         },
84         [PORT_ID_ADC] = {
85                 .name = "ADC",
86                 .numchn = PORT_ADC_CHANNELS,
87                 .bpch = 16,
88                 .get = port_adc_get,
89                 .set = NULL,
90                 .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1 } },
91         },
92         [PORT_ID_LOUT] = {
93                 .name = "LOUT",
94                 .numchn = 1,
95                 .bpch = 32,
96                 .get = NULL,
97                 .set = port_spi_set,
98                 .cfg = { .spi = { .ifc = 1, .cs = 1 }, },
99         },
100         [PORT_ID_DAC1_2] = {
101                 .name = "DAC12",
102                 .numchn = 1,
103                 .bpch = 16,
104                 .get = NULL,
105                 .set = port_spi_set,
106                 .cfg = { .spi = { .ifc = 3, .cs = 0 }, },
107         },
108         [PORT_ID_DAC3_4] = {
109                 .name = "DAC34",
110                 .numchn = 1,
111                 .bpch = 16,
112                 .get = NULL,
113                 .set = port_spi_set,
114                 .cfg = { .spi = { .ifc = 3, .cs = 1 }, },
115         },
116         [PORT_ID_DACDREF] = {
117                 .name = "DACDREF",              /* Reference voltage for DIN */
118                 .numchn = 1,
119                 .bpch = 16,
120                 .get = NULL,
121                 .set = port_spi_set,
122                 .cfg = { .spi = { .ifc = 3, .cs = 2 }, },
123         },
124         [PORT_ID_HBR] = {
125                 .name = "HBR",
126                 .numchn = 1,
127                 .bpch = 16,
128                 .get = NULL,
129                 .set = port_spi_set,
130                 .cfg = { .spi = { .ifc = 4, .cs = 0 }, },
131         },
132         [PORT_ID_FRAY1] = {
133                 .name = "FRAY1",
134                 .numchn = 1,
135                 .bpch = 16,
136                 .get = NULL,
137                 .set = port_spi_set,
138                 .cfg = { .spi = { .ifc = 4, .cs = 1 }, },
139         },
140         [PORT_ID_FRAY2] = {
141                 .name = "FRAY2",
142                 .numchn = 1,
143                 .bpch = 16,
144                 .get = NULL,
145                 .set = port_spi_set,
146                 .cfg = { .spi = { .ifc = 4, .cs = 2 }, },
147         },
148         [PORT_ID_MOUTEN] = {
149                 .name = "MOUTEN",
150                 .numchn = ARRAY_SIZE(pins_mouten),
151                 .bpch = 1,
152                 .get = port_gioset_get,
153                 .set = NULL,
154                 .cfg = { .gioset = { .pins = pins_mouten } },
155         },
156         [PORT_ID_MOUTIN] = {
157                 .name = "MOUTIN",
158                 .numchn = ARRAY_SIZE(pins_moutin),
159                 .bpch = 1,
160                 .get = port_gioset_get,
161                 .set = port_gioset_set,
162                 .cfg = { .gioset = { .pins = pins_moutin } },
163         }
164 };