2 \defgroup gpio_interface_gr GPIO Interface
3 \brief Driver API for GPIO Interface (%Driver_GPIO.h)
5 The <b>General-purpose Input/Output Interface</b> (GPIO) features Input/Output operations on pin level (does not support simultaneous operations on multiple pins belonging to the same port).
8 - basic pin configuration (direction, output mode, pull-resistor, event trigger) excluding advanced settings (drive strength or speed, input filter, ...),
9 - events on edge detection,
13 Each function operates on a pin level and uses a pin identification as the first parameter. Pin identification is a virtual number which is mapped to an actual pin.
17 The following header files define the Application Programming Interface (API) for the GPIO interface:
18 - \b %Driver_GPIO.h : Driver API for GPIO Interface
20 The driver implementation is a typical part of the Device Family Pack (DFP) that supports the
21 peripherals of the microcontroller family.
24 <b>Driver Functions</b>
26 The driver functions are published in the access struct as explained in \ref DriverFunctions
27 - \ref ARM_DRIVER_GPIO : access struct for GPIO driver functions
32 The following example code shows the usage of the GPIO interface.
41 \struct ARM_DRIVER_GPIO
43 The functions of the GPIO driver are accessed by function pointers exposed by this structure.
44 Refer to \ref DriverFunctions for overview information.
46 Each instance of a GPIO interface provides such an access structure.
47 The instance is identified by a postfix number in the symbol name of the access structure, for example:
48 - \b Driver_GPIO0 is the name of the access struct of the first instance (no. 0).
49 - \b Driver_GPIO1 is the name of the access struct of the second instance (no. 1).
51 A middleware configuration setting allows connecting the middleware to a specific driver instance \b %Driver_GPIO<i>n</i>.
52 The default is \token{0}, which connects a middleware to the first instance of a driver.
53 **************************************************************************************************************************/
56 \typedef ARM_GPIO_DIRECTION
58 Specifies values for setting the direction.
61 - \ref ARM_GPIO_SetDirection
62 *****************************************************************************************************************/
65 \typedef ARM_GPIO_OUTPUT_MODE
67 Specifies values for setting the output mode.
70 - \ref ARM_GPIO_SetOutputMode
71 *****************************************************************************************************************/
74 \typedef ARM_GPIO_PULL_RESISTOR
76 Specifies values for setting the pull resistor.
79 - \ref ARM_GPIO_SetPullResistor
80 *****************************************************************************************************************/
83 \typedef ARM_GPIO_EVENT_TRIGGER
85 Specifies values for setting the event trigger.
88 - \ref ARM_GPIO_SetEventTrigger
89 *****************************************************************************************************************/
92 \typedef ARM_GPIO_SignalEvent_t
94 Provides the typedef for the callback function \ref ARM_GPIO_SignalEvent.
98 *******************************************************************************************************************/
101 \defgroup gpio_execution_status GPIO Status Error Codes
102 \ingroup gpio_interface_gr
103 \brief Negative values indicate errors (GPIO has specific codes in addition to common \ref execution_status).
105 The GPIO driver has additional status error codes that are listed below.
106 Note that the GPIO driver also returns the common \ref execution_status.
109 \def ARM_GPIO_ERROR_PIN
110 The \b pin specified is not available.
115 \defgroup GPIO_events GPIO Events
116 \ingroup gpio_interface_gr
117 \brief The GPIO driver generates call back events that are notified via the function \ref ARM_GPIO_SignalEvent.
119 This section provides the event values for the \ref ARM_GPIO_SignalEvent callback function.
121 The following call back notification events are generated:
123 \def ARM_GPIO_EVENT_RISING_EDGE
124 \def ARM_GPIO_EVENT_FALLING_EDGE
125 \def ARM_GPIO_EVENT_EITHER_EDGE
133 int32_t ARM_GPIO_Setup (ARM_GPIO_Pin_t pin, ARM_GPIO_SignalEvent_t cb_event) {
134 return ARM_DRIVER_OK;
137 \fn int32_t ARM_GPIO_Setup (ARM_GPIO_Pin_t pin, ARM_GPIO_SignalEvent_t cb_event)
139 The function \b ARM_GPIO_Setup sets-up the specified \em pin as GPIO with default configuration.
140 Pin is configured as input without pull-resistor and without event trigger.
142 The parameter \em cb_event specifies a pointer to the \ref ARM_GPIO_SignalEvent callback function.
143 Use a NULL pointer when no callback events are required.
144 **************************************************************************************************************************/
146 int32_t ARM_GPIO_SetDirection (ARM_GPIO_Pin_t pin, ARM_GPIO_DIRECTION direction) {
147 return ARM_DRIVER_OK;
150 \fn int32_t ARM_GPIO_SetDirection (ARM_GPIO_Pin_t pin, ARM_GPIO_DIRECTION direction)
152 The function \b ARM_GPIO_SetDirection configures the direction of the specified \em pin.
154 Direction is specified with parameter \em direction:
155 - \ref ARM_GPIO_INPUT : Input (default),
156 - \ref ARM_GPIO_OUTPUT : Output.
157 **************************************************************************************************************************/
159 int32_t ARM_GPIO_SetOutputMode (ARM_GPIO_Pin_t pin, ARM_GPIO_OUTPUT_MODE mode) {
160 return ARM_DRIVER_OK;
163 \fn int32_t ARM_GPIO_SetOutputMode (ARM_GPIO_Pin_t pin, ARM_GPIO_OUTPUT_MODE mode)
165 The function \b ARM_GPIO_SetOutputMode configures the output mode of the specified \em pin.
167 Output mode is specified with parameter \em mode:
168 - \ref ARM_GPIO_PUSH_PULL : Push-pull (default),
169 - \ref ARM_GPIO_OPEN_DRAIN : Open-drain.
171 \note Output mode is relevant only when the pin is configured as output.
172 **************************************************************************************************************************/
174 int32_t ARM_GPIO_SetPullResistor (ARM_GPIO_Pin_t pin, ARM_GPIO_PULL_RESISTOR resistor) {
175 return ARM_DRIVER_OK;
178 \fn int32_t ARM_GPIO_SetPullResistor (ARM_GPIO_Pin_t pin, ARM_GPIO_PULL_RESISTOR resistor)
180 The function \b ARM_GPIO_SetPullResistor configures the pull resistor of the specified \em pin.
182 Pull resistor is specified with parameter \em resistor:
183 - \ref ARM_GPIO_PULL_NONE : None (default),
184 - \ref ARM_GPIO_PULL_UP : Pull-up,
185 - \ref ARM_GPIO_PULL_DOWN : Pull-down.
187 \note Pull resistor applies to the pin regardless of pin direction.
188 **************************************************************************************************************************/
190 int32_t ARM_GPIO_SetEventTrigger (ARM_GPIO_Pin_t pin, ARM_GPIO_EVENT_TRIGGER trigger) {
191 return ARM_DRIVER_OK;
194 \fn int32_t ARM_GPIO_SetEventTrigger (ARM_GPIO_Pin_t pin, ARM_GPIO_EVENT_TRIGGER trigger)
196 The function \b ARM_GPIO_SetEventTrigger configures the event trigger of the specified \em pin.
198 Event trigger is specified with parameter \em trigger:
199 - \ref ARM_GPIO_TRIGGER_NONE : None (default),
200 - \ref ARM_GPIO_TRIGGER_RISING_EDGE : Rising-edge,
201 - \ref ARM_GPIO_TRIGGER_FALLING_EDGE : Falling-edge,
202 - \ref ARM_GPIO_TRIGGER_EITHER_EDGE : Either edge (rising and falling).
203 **************************************************************************************************************************/
205 void ARM_GPIO_SetOutput (ARM_GPIO_Pin_t pin, uint32_t val) {
208 \fn void ARM_GPIO_SetOutput (ARM_GPIO_Pin_t pin, uint32_t val)
210 The function \b ARM_GPIO_SetOutput sets the level of the specified \em pin defined as output to the value specified by \em val.
213 When a pin is configured as input, the level is latched and will be driven once the pin is configured as output.
214 **************************************************************************************************************************/
216 uint32_t ARM_GPIO_GetInput (ARM_GPIO_Pin_t pin) {
220 \fn uint32_t ARM_GPIO_GetInput (ARM_GPIO_Pin_t pin)
222 The function \b ARM_GPIO_GetInput reads the level of the specified \em pin.
223 **************************************************************************************************************************/
225 void ARM_GPIO_SignalEvent (ARM_GPIO_Pin_t pin, uint32_t event) {
228 \fn void ARM_GPIO_SignalEvent (ARM_GPIO_Pin_t pin, uint32_t event)
230 The function \b ARM_GPIO_SignalEvent is a callback functions registered by the function \ref ARM_GPIO_Setup.
231 It is called by the GPIO driver to notify the application about \ref GPIO_events occurred during operation.
233 The parameter \em pin indicates on which pin the event occurred and parameter \em event indicates one or more events that occurred.
235 The following events can be generated:
237 <table class="cmtable" summary="">
239 <th> Parameter \em event </th><th> Bit </th><th> Description </th>
242 <td> \ref ARM_GPIO_EVENT_RISING_EDGE </td><td> 0 </td><td> Occurs when rising-edge is detected on the indicated pin. </td>
245 <td> \ref ARM_GPIO_EVENT_FALLING_EDGE </td><td> 1 </td><td> Occurs when falling-edge is detected on the indicated pin. </td>
248 <td> \ref ARM_GPIO_EVENT_EITHER_EDGE </td><td> 2 </td><td> Occurs when either edge is detected on the indicated pin
249 when trigger is configured as \ref ARM_GPIO_TRIGGER_EITHER_EDGE
250 and hardware is not able to distinguish between rising and falling edge. </td>
253 **************************************************************************************************************************/
258 // End GPIO Interface