1 /* Copyright (C) 2013-2014 Czech Technical University in Prague
3 * - Michal Horn <hornmich@fel.cvut.cz>
5 * This document contains proprietary information belonging to Czech
6 * Technical University in Prague. Passing on and copying of this
7 * document, and communication of its contents is not permitted
8 * without prior written authorization.
18 * @brief Port descriptor
20 * The structure describes the port. Port here means set of IO pins on the board.
21 * The API is designed to provide an interface for setting and reading from ports connected to the MCU by SPI, GPIO or ADC.
23 typedef struct port_desc_st {
24 uint32_t *config; /**< Configuration of the port. An array of values, which meaning differs for the interface type:
25 for SPI: address, chip-select
26 for GPIO: descriptors for pins (defined in gpio_rm48_def.h)
27 for ADC: ADC base address, ADC group number, Peripheral type (HOUTIFBK or ADC)
29 uint32_t numValues; /**< Size of the data to be read from or written on the port. Meaning differs for the interface type:
30 for SPI: size of the command in bytes
31 for GPIO: number of pins on the port
32 for ADC: number of channels to be read from ADC.
34 uint32_t interfaceType; /**< Type of the interface to which the port or its controller is connected.
35 Can be SPI, ADC or GPIO
37 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.
38 All SPI ports are write only, because command has to be sent to obtain actual response.
39 It is allowed to read values from an output port.
41 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.
42 All ADC ports are read only.
43 It is not allowed to write values on an input port.
48 * Maps port descriptor to the port name
50 typedef struct port_def_st {
55 #define PORT_INTERFACE_ADC 0x1
56 #define PORT_INTERFACE_SPI 0x2
57 #define PORT_INTERFACE_GPIO 0x3
61 #define PORT_NAME_GIOA "GIOA"
62 #define PORT_CFG_GIOA { PIN_DSC_GIOA0, PIN_DSC_GIOA1, PIN_DSC_GIOA2, PIN_DSC_GIOA3, \
63 PIN_DSC_GIOA4, PIN_DSC_GIOA5, PIN_DSC_GIOA6, PIN_DSC_GIOA7 }
64 #define PORT_NV_GIOA 8
65 #define PORT_GFC_GIOA &hal_gio_port_get_val
66 #define PORT_SFC_GIOA &hal_gio_port_set_val
67 #define PORT_INT_TYPE_GIOA PORT_INTERFACE_GPIO
69 #define PORT_NAME_GIOB "GIOB"
70 #define PORT_CFG_GIOB { PIN_DSC_GIOB0, PIN_DSC_GIOB1, PIN_DSC_GIOB2, PIN_DSC_GIOB3, \
71 PIN_DSC_GIOB4, PIN_DSC_GIOB5, PIN_DSC_GIOB6, PIN_DSC_GIOB7 }
72 #define PORT_NV_GIOB 8
73 #define PORT_GFC_GIOB &hal_gio_port_get_val
74 #define PORT_SFC_GIOB &hal_gio_port_set_val
75 #define PORT_INT_TYPE_GIOB PORT_INTERFACE_GPIO
77 /* Some pins are commented out, because they are muxed with SCI. */
78 #define PORT_NAME_NHET1 "NHET1"
79 #define PORT_CFG_NHET1 { PIN_DSC_NHET1_0, PIN_DSC_NHET1_1, PIN_DSC_NHET1_2, PIN_DSC_NHET1_3, \
80 PIN_DSC_NHET1_4, PIN_DSC_NHET1_5, /*PIN_DSC_NHET1_6,*/ PIN_DSC_NHET1_7, \
81 PIN_DSC_NHET1_8, PIN_DSC_NHET1_9, PIN_DSC_NHET1_10, PIN_DSC_NHET1_11, \
82 PIN_DSC_NHET1_12, /*PIN_DSC_NHET1_13,*/ PIN_DSC_NHET1_14, PIN_DSC_NHET1_15, \
83 PIN_DSC_NHET1_16, PIN_DSC_NHET1_17, PIN_DSC_NHET1_18, PIN_DSC_NHET1_19, \
84 PIN_DSC_NHET1_20, PIN_DSC_NHET1_21, PIN_DSC_NHET1_22, PIN_DSC_NHET1_23, \
85 PIN_DSC_NHET1_24, PIN_DSC_NHET1_25, PIN_DSC_NHET1_26, PIN_DSC_NHET1_27, \
86 PIN_DSC_NHET1_28, PIN_DSC_NHET1_29, PIN_DSC_NHET1_30, PIN_DSC_NHET1_31 }
87 #define PORT_NV_NHET1 30
88 #define PORT_GFC_NHET1 &hal_gio_port_get_val
89 #define PORT_SFC_NHET1 &hal_gio_port_set_val
90 #define PORT_INT_TYPE_NHET1 PORT_INTERFACE_GPIO
92 #define PORT_ADC_CHANNEL_NUM 16
93 #define PORT_NAME_ADC "ADC"
94 #define PORT_CFG_ADC { (uint32_t)adcREG1, adcGROUP1, 1 }
95 #define PORT_NV_ADC PORT_ADC_CHANNEL_NUM
96 #define PORT_GFC_ADC &adc_get_port_val
97 #define PORT_SFC_ADC NULL
98 #define PORT_INT_TYPE_ADC PORT_INTERFACE_ADC
100 #endif /* PORT_DEF_H_ */