5 * @copyright Copyright (C) 2012-2013 Czech Technical University in Prague
7 * @author Michal Horn <hornmich@fel.cvut.cz>
13 //#include "hal_gpio_tms570_def.h"
17 * @brief Port descriptor
19 * The structure describes the port. Port here means set of IO pins on the board.
20 * The API is designed to provide an interface for setting and reading from ports connected to the MCU by SPI, GPIO or ADC.
22 typedef struct port_desc_st {
23 uint32_t *config; /**< Configuration of the port. An arry of values, which meaning differs for the interface type:
24 for SPI: address, chip-select
25 for GPIO: descriptors for pins (defined in gpio_tms570_def.h)
26 for ADC: ADC base address, ADC group number, Peripheral type (HOUTIFBK or ADC)
28 uint32_t numValues; /**< Size of the data to be read from or written on the port. Meaning differs for the interface type:
29 for SPI: size of the command in bytes
30 for GPIO: number of pins on the port
31 for ADC: number of channels to be read from ADC.
33 uint32_t interfaceType; /**< Type of the interface to which the port or its controller is connected.
34 Can be SPI, ADC or GPIO
36 uint32_t (*port_getfnc_ptr)(uint32_t *config, uint32_t num_val, uint32_t *values); /**< Pointer to a getter function. If it is NULL, than port is write only.
37 All SPI ports are write only, because command has to be sent to obtain actual response.
38 It is allowed to read values from an output port.
40 uint32_t (*port_setfnc_ptr)(uint32_t *config, uint32_t num_val, const uint32_t *values); /**< Pointer to a setter function. If it is NULL, than port is read only.
41 All ADC ports are read only.
42 It is not allowed to write values on an input port.
47 * Maps port descriptor to the port name
49 typedef struct port_def_st {
54 #define PORT_INTERFACE_ADC 0x1
55 #define PORT_INTERFACE_SPI 0x2
56 #define PORT_INTERFACE_GPIO 0x3
60 #define PORT_NAME_DINMCU "DINMCU"
61 #define PORT_CFG_DINMCU { PIN_DSC_DIN8, PIN_DSC_DIN9, PIN_DSC_DIN10, PIN_DSC_DIN11, PIN_DSC_DIN12, PIN_DSC_DIN13, PIN_DSC_DIN14, PIN_DSC_DIN15 }
62 #define PORT_NV_DINMCU 8
63 #define PORT_GFC_DINMCU &hal_gio_port_get_val
64 #define PORT_SFC_DINMCU NULL
65 #define PORT_INT_TYPE_DINMCU PORT_INTERFACE_GPIO
67 #define PORT_NAME_DINSPI "DINSPI"
68 #define PORT_CFG_DINSPI { 1, 0 }
69 #define PORT_NV_DINSPI 3
70 #define PORT_GFC_DINSPI NULL
71 #define PORT_SFC_DINSPI &hal_spi_port_transfer_command
72 #define PORT_INT_TYPE_DINSPI PORT_INTERFACE_SPI
74 #define PORT_NAME_HOUTDIAG "HOUTDIAG"
75 #define PORT_CFG_HOUTDIAG { PIN_DSC_HOUT1DIAG, PIN_DSC_HOUT2DIAG, PIN_DSC_HOUT3DIAG, PIN_DSC_HOUT4DIAG, PIN_DSC_HOUT5DIAG, PIN_DSC_HOUT6DIAG }
76 #define PORT_NV_HOUTDIAG 6
77 #define PORT_GFC_HOUTDIAG &hal_gio_port_get_val
78 #define PORT_SFC_HOUTDIAG NULL
79 #define PORT_INT_TYPE_HOUTDIAG PORT_INTERFACE_GPIO
81 #define PORT_NAME_HOUTIN "HOUTIN"
82 #define PORT_CFG_HOUTIN { PIN_DSC_HOUT1IN, PIN_DSC_HOUT2IN, PIN_DSC_HOUT3IN, PIN_DSC_HOUT4IN, PIN_DSC_HOUT5IN, PIN_DSC_HOUT6IN }
83 #define PORT_NV_HOUTIN 6
84 #define PORT_GFC_HOUTIN &hal_gio_port_get_val
85 #define PORT_SFC_HOUTIN &hal_gio_port_set_val
86 #define PORT_INT_TYPE_HOUTIN PORT_INTERFACE_GPIO
88 // FIXME Upper layer dependency/coupling
89 // Declared in drv/adc.h
90 extern uint32_t adc_get_port_val(uint32_t *config, uint32_t num_channels, uint32_t *values);
92 #define PORT_HOUTIFBK_CHANNEL_NUM 6
93 #define PORT_NAME_HOUTIFBK "HOUTIFBK"
94 #define PORT_CFG_HOUTIFBK { (uint32_t)adcREG2, adcGROUP1, 0 }
95 #define PORT_NV_HOUTIFBK PORT_HOUTIFBK_CHANNEL_NUM
96 #define PORT_GFC_HOUTIFBK &adc_get_port_val
97 #define PORT_SFC_HOUTIFBK NULL
98 #define PORT_INT_TYPE_HOUTIFBK PORT_INTERFACE_ADC
100 #define PORT_ADC_CHANNEL_NUM 12
101 #define PORT_NAME_ADC "ADC"
102 #define PORT_CFG_ADC { (uint32_t)adcREG1, adcGROUP1, 1 }
103 #define PORT_NV_ADC PORT_ADC_CHANNEL_NUM
104 #define PORT_GFC_ADC &adc_get_port_val
105 #define PORT_SFC_ADC NULL
106 #define PORT_INT_TYPE_ADC PORT_INTERFACE_ADC
108 #define PORT_NAME_LOUT "LOUT"
109 #define PORT_CFG_LOUT { 1, 1 }
110 #define PORT_NV_LOUT 4
111 #define PORT_GFC_LOUT NULL
112 #define PORT_SFC_LOUT &hal_spi_port_transfer_command
113 #define PORT_INT_TYPE_LOUT PORT_INTERFACE_SPI
115 #define PORT_NAME_DAC1_2 "DAC12"
116 #define PORT_CFG_DAC1_2 { 3, 0 }
117 #define PORT_NV_DAC1_2 2
118 #define PORT_GFC_DAC1_2 NULL
119 #define PORT_SFC_DAC1_2 &hal_spi_port_transfer_command
120 #define PORT_INT_TYPE_DAC1_2 PORT_INTERFACE_SPI
122 #define PORT_NAME_DAC3_4 "DAC34"
123 #define PORT_CFG_DAC3_4 { 3, 1 }
124 #define PORT_NV_DAC3_4 2
125 #define PORT_GFC_DAC3_4 NULL
126 #define PORT_SFC_DAC3_4 &hal_spi_port_transfer_command
127 #define PORT_INT_TYPE_DAC3_4 PORT_INTERFACE_SPI
129 #define PORT_NAME_DACDREF "DACDREF"
130 #define PORT_CFG_DACDREF { 3, 2 }
131 #define PORT_NV_DACDREF 2
132 #define PORT_GFC_DACDREF NULL
133 #define PORT_SFC_DACDREF &hal_spi_port_transfer_command
134 #define PORT_INT_TYPE_DACDREF PORT_INTERFACE_SPI
136 #define PORT_NAME_HBR "HBR"
137 #define PORT_CFG_HBR { 4, 0 }
138 #define PORT_NV_HBR 2
139 #define PORT_GFC_HBR NULL
140 #define PORT_SFC_HBR &hal_spi_port_transfer_command
141 #define PORT_INT_TYPE_HBR PORT_INTERFACE_SPI
143 #define PORT_NAME_FRAY1 "FRAY1"
144 #define PORT_CFG_FRAY1 { 4, 1 }
145 #define PORT_NV_FRAY1 2
146 #define PORT_GFC_FRAY1 NULL
147 #define PORT_SFC_FRAY1 &hal_spi_port_transfer_command
148 #define PORT_INT_TYPE_FRAY1 PORT_INTERFACE_SPI
150 #define PORT_NAME_FRAY2 "FRAY2"
151 #define PORT_CFG_FRAY2 { 4, 2 }
152 #define PORT_NV_FRAY2 2
153 #define PORT_GFC_FRAY2 NULL
154 #define PORT_SFC_FRAY2 &hal_spi_port_transfer_command
155 #define PORT_INT_TYPE_FRAY2 PORT_INTERFACE_SPI
157 #define PORT_NAME_MOUTEN "MOUTEN"
158 #define PORT_CFG_MOUTEN { PIN_DSC_MOUT1EN, PIN_DSC_MOUT2EN, PIN_DSC_MOUT3EN, PIN_DSC_MOUT4EN, PIN_DSC_MOUT5EN, PIN_DSC_MOUT6EN }
159 #define PORT_NV_MOUTEN 6
160 #define PORT_GFC_MOUTEN &hal_gio_port_get_val
161 #define PORT_SFC_MOUTEN NULL
162 #define PORT_INT_TYPE_MOUTEN PORT_INTERFACE_GPIO
164 #define PORT_NAME_MOUTIN "MOUTIN"
165 #define PORT_CFG_MOUTIN { PIN_DSC_MOUT1IN, PIN_DSC_MOUT2IN, PIN_DSC_MOUT3IN, PIN_DSC_MOUT4IN, PIN_DSC_MOUT5IN, PIN_DSC_MOUT6IN }
166 #define PORT_NV_MOUTIN 6
167 #define PORT_GFC_MOUTIN &hal_gio_port_get_val
168 #define PORT_SFC_MOUTIN &hal_gio_port_set_val
169 #define PORT_INT_TYPE_MOUTIN PORT_INTERFACE_GPIO
171 #endif /* PORT_DEF_H_ */