]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/src/drv/_tms570_hydctr/port_def.c
Change license to MIT
[pes-rpp/rpp-lib.git] / rpp / src / drv / _tms570_hydctr / port_def.c
1 /*
2  * Copyright (C) 2015 Czech Technical University in Prague
3  *
4  * Authors:
5  *     - Michal Sojka <sojkam1@fel.cvut.cz>
6  *
7  * Permission is hereby granted, free of charge, to any person
8  * obtaining a copy of this software and associated documentation
9  * files (the "Software"), to deal in the Software without
10  * restriction, including without limitation the rights to use,
11  * copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following
14  * conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  *
28  */
29
30 #include "drv/port.h"
31 #include "drv/gio_names.h"
32 #include "drv/gio_tab.h"
33 #include "drv/spi.h"
34 #include "drv/spi_tms570.h"
35 #include "drv/adc.h"
36
37 // Lists of pins assigned to the ports
38 static enum pin_name pins_gioa[] = {
39         PIN_GIOA0, PIN_GIOA1, PIN_GIOA2, PIN_GIOA3,
40         PIN_GIOA4, PIN_GIOA5, PIN_GIOA6, PIN_GIOA7
41 };
42 static enum pin_name pins_giob[] = {
43         PIN_GIOB0, PIN_GIOB1, PIN_GIOB2, PIN_GIOB3,
44         PIN_GIOB4, PIN_GIOB5, PIN_GIOB6, PIN_GIOB7
45 };
46 static enum pin_name pins_nhet1[] = {
47         PIN_NHET10, PIN_NHET11, PIN_NHET12,
48         PIN_NHET13, PIN_NHET14, PIN_NHET15,
49         PIN_NHET17, PIN_NHET18, PIN_NHET19,
50         PIN_NHET110, PIN_NHET111, PIN_NHET112,
51         PIN_NHET114, PIN_NHET115, PIN_NHET116,
52         PIN_NHET117, PIN_NHET118, PIN_NHET119,
53         PIN_NHET120, PIN_NHET121, PIN_NHET122,
54         PIN_NHET123, PIN_NHET124, PIN_NHET125,
55         PIN_NHET126, PIN_NHET127, PIN_NHET128,
56         PIN_NHET129, PIN_NHET130, PIN_NHET131
57 };
58
59 static enum pin_name pins_spi5[] = {
60         PIN_SPI5CS0, PIN_SPI5CS1, PIN_SPI5CS2, PIN_SPI5CS3,
61         PIN_SPI5ENA, PIN_SPI5CLK,
62         PIN_SPI5SIMO0, PIN_SPI5SIMO1, PIN_MCU_ENDRV, PIN_TEMP_ALERT,
63         PIN_SPI5SOMI0, PIN_SLEEP, PIN_SPI5SOMI2, PIN_SPI5SOMI3,
64 };
65
66 // Port descriptors
67 const struct port_desc port_desc[] = {
68         [PORT_ID_GIOA] = {
69                 .name = "GIOA",
70                 .cfg = { .gioset = { .pins = pins_gioa } },
71                 .numchn = ARRAY_SIZE(pins_gioa),
72                 .bpch = 1,
73                 .get = port_gioset_get,
74                 .set = port_gioset_set,
75         },
76         [PORT_ID_GIOB] = {
77                 .name = "GIOB",
78                 .cfg = { .gioset = { .pins = pins_giob } },
79                 .numchn = ARRAY_SIZE(pins_giob),
80                 .bpch = 1,
81                 .get = port_gioset_get,
82                 .set = port_gioset_set,
83         },
84         [PORT_ID_NHET1] = {
85                 .name = "NHET1",
86                 .cfg = { .gioset = { .pins = pins_nhet1 } },
87                 .numchn = ARRAY_SIZE(pins_nhet1),
88                 .bpch = 1,
89                 .get = port_gioset_get,
90                 .set = port_gioset_set,
91         },
92         [PORT_ID_ADC] = {
93                 .name = "ADC",
94                 .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1 } },
95                 .numchn = PORT_ADC_CHANNELS,
96                 .bpch = 16,
97                 .get = port_adc_get,
98                 .set = NULL,
99         },
100         [PORT_ID_THERMISTOR1] = {
101                 .name = "THERM1",
102                 .numchn = 1,
103                 .bpch = 16,
104                 .get = NULL,
105                 .set = port_spi_set,
106                 .cfg = { .spi = { .dev = SPIDEV_MCP6S93_TH1, .chip = "MCP6S93" }, },
107         },
108         [PORT_ID_THERMISTOR2] = {
109                 .name = "THERM2",
110                 .numchn = 1,
111                 .bpch = 16,
112                 .get = NULL,
113                 .set = port_spi_set,
114                 .cfg = { .spi = { .dev = SPIDEV_MCP6S93_TH2, .chip = "MCP6S93" }, },
115         },
116         [PORT_ID_ADC_COND] = {
117                 .name = "ADCCND",
118                 .numchn = 6,
119                 .bpch = 16, /* 6 ICs in daisy chain */
120                 .get = NULL,
121                 .set = port_spi_set,
122                 .cfg = { .spi = { .dev = SPIDEV_MCP6S93_6ADC, .chip = "MCP6S93" }, },
123         },
124         [PORT_ID_POWER_SUPPLY] = {
125                 .name = "PWR",
126                 .numchn = 1,
127                 .bpch = 16,
128                 .get = NULL,
129                 .set = port_spi_set,
130                 .cfg = { .spi = { .dev = SPIDEV_TPS65381_PWR, .chip = "TPS65381" }, },
131         },
132         [PORT_ID_SENSOR_SUPPLY] = {
133                 .name = "SENSUP",
134                 .numchn = 1,
135                 .bpch = 16,
136                 .get = NULL,
137                 .set = port_spi_set,
138                 .cfg = { .spi = { .dev = SPIDEV_MCP6S93_SENSUP, .chip = "MCP6S93" }, },
139         },
140         [PORT_ID_DAC_ADC_LOOPBACK] = {
141                 .name = "DACLBK",
142                 .numchn = 1,
143                 .bpch = 16,
144                 .get = NULL,
145                 .set = port_spi_set,
146                 .cfg = { .spi = { .dev = SPIDEV_MCP6S93_DAC, .chip = "MCP6S93" }, },
147         },
148         [PORT_ID_GIO_SPI5] = {
149                 .name = "GIOSPI5",
150                 .cfg = { .gioset = { .pins = pins_spi5 } },
151                 .numchn = ARRAY_SIZE(pins_spi5),
152                 .bpch = 1,
153                 .get = port_gioset_get,
154                 .set = port_gioset_set,
155         },
156 };