libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
gpio.c
Go to the documentation of this file.
1/*
2 * This file is part of the libopencm3 project.
3 *
4 * Copyright (C) 2011 Gareth McMullin <gareth@blacksphere.co.nz>
5 * Copyright (C) 2013 Alexandru Gagniuc <mr.nuke.me@gmail.com>
6 *
7 * This library is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21/** @defgroup gpio_file GPIO
22 *
23 *
24 * @ingroup LM4Fxx
25 *
26 * @version 1.0.0
27 *
28 * @author @htmlonly &copy; @endhtmlonly 2011
29 * Gareth McMullin <gareth@blacksphere.co.nz>
30 * @author @htmlonly &copy; @endhtmlonly 2013
31 * Alexandru Gagniuc <mr.nuke.me@gmail.com>
32 *
33 * @date 16 March 2013
34 *
35 * LGPL License Terms @ref lgpl_license
36 *
37 * @brief <b>libopencm3 LM4F General Purpose I/O</b>
38 *
39 * The LM4F GPIO API provides functionality for accessing the GPIO pins of the
40 * LM4F.
41 *
42 * @attention @code An important aspect to consider is that libopencm3 uses the
43 * AHB aperture for accessing the GPIO registers on the LM4F. The AHB must be
44 * explicitly enabled with a call to gpio_enable_ahb_aperture() before accessing
45 * any GPIO functionality.
46 * @endcode
47 *
48 * Please see the individual GPIO modules for more details. To use the GPIO, the
49 * gpio.h header needs to be included:
50 * @code{.c}
51 * #include <libopencm3/lm4f/gpio.h>
52 * @endcode
53 */
54
55/**@{*/
56
59
60/* Value we need to write to unlock the GPIO commit register */
61#define GPIO_LOCK_UNLOCK_CODE 0x4C4F434B
62
63
64/** @defgroup gpio_config GPIO pin configuration
65 * @ingroup gpio_file
66 *
67 * \brief <b>Enabling and configuring GPIO pins</b>
68 *
69 * @section gpio_api_enable Enabling GPIO ports
70 * @attention
71 * Before accessing GPIO functionality through this API, the AHB aperture for
72 * GPIO ports must be enabled via a call to @ref gpio_enable_ahb_aperture().
73 * Failing to do so will cause a hard fault.
74 *
75 * @note
76 * Once the AHB aperture is enabled, GPIO registers can no longer be accessed
77 * via the APB aperture. The two apertures are mutually exclusive.
78 *
79 * Enabling the AHB aperture only needs to be done once. However, in order to
80 * access a certain GPIO port, its clock must also be enabled. Enabling the
81 * GPIO clock needs to be done for every port that will be used.
82 *
83 * For example, to enable GPIOA and GPIOD:
84 * @code{.c}
85 * // Make sure we can access the GPIO via the AHB aperture
86 * gpio_enable_ahb_aperture();
87 * ...
88 * // Enable GPIO ports A and D
89 * periph_clock_enable(RCC_GPIOA);
90 * periph_clock_enable(RCC_GPIOD);
91 * @endcode
92 *
93 * On reset all ports are configured as digital floating inputs (no pull-up or
94 * pull-down), except for special function pins.
95 *
96 *
97 * @section gpio_api_in Configuring pins as inputs
98 *
99 * Configuring GPIO pins as inputs is done with @ref gpio_mode_setup(), with
100 * @ref GPIO_MODE_INPUT for the mode parameter. The direction of the pull-up
101 * must be specified with the same call
102 *
103 * For example, PA2, PA3, and PA4 as inputs, with pull-up on PA4:
104 * @code{.c}
105 * gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO2 | GPIO3);
106 * gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, GPIO4);
107 * @endcode
108 *
109 *
110 * @section gpio_api_out Configuring pins as outputs
111 *
112 * Output pins have more configuration options than input pins. LM4F pins can be
113 * configured as either push-pull, or open drain. The drive strength of each pin
114 * can be adjusted between 2mA, 4mA, or 8mA. Slew-rate control is available when
115 * the pins are configured to drive 8mA. These extra options can be specified
116 * with @ref gpio_set_output_config().
117 * The default is push-pull configuration with 2mA drive capability.
118 *
119 * @note
120 * @ref gpio_set_output_config() controls different capabilities than the
121 * similar sounding gpio_set_output_options() from the STM GPIO API. They are
122 * intentionally named differently to prevent confusion between the two. They
123 * are API incompatible.
124 *
125 * For example, to set PA2 to output push-pull with a drive strength of 8mA:
126 * @code{.c}
127 * gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO2);
128 * gpio_set_output_config(GPIOA, GPIO_OTYPE_PP, GPIO_DRIVE_8MA, GPIO2);
129 * @endcode
130 *
131 *
132 * @section gpio_api_analog Configuring pins as analog function
133 *
134 * Configuring GPIO pins to their analog function is done with
135 * @ref gpio_mode_setup(), with @ref GPIO_MODE_ANALOG for the mode parameter.
136 *
137 * Suppose PD4 and PD5 are the USB pins. To enable their analog functionality
138 * (USB D+ and D- in this case), use:
139 * @code
140 * // Mux USB pins to their analog function
141 * gpio_mode_setup(GPIOD, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4 | GPIO5);
142 * @endcode
143 *
144 * @section gpio_api_alf_func Configuring pins as alternate functions
145 *
146 * Most pins have alternate functions associated with them. When a pin is set to
147 * an alternate function, it is multiplexed to one of the dedicated hardware
148 * peripheral in the chip. The alternate function mapping can be found in the
149 * part's datasheet, and usually varies between arts of the same family.
150 *
151 * Multiplexing a pin, or group of pins to an alternate function is done with
152 * @ref gpio_set_af(). Because AF0 is not used on the LM4F, passing 0 as the
153 * alt_func_num parameter will disable the alternate function of the given pins.
154 *
155 * @code
156 * // Mux PB0 and PB1 to AF1 (UART1 TX/RX in this case)
157 * gpio_set_af(GPIOB, 1, GPIO0 | GPIO1);
158 * @endcode
159 *
160 * @section gpio_api_sfpins Changing configuration of special function pins
161 *
162 * On the LM4F, the NMI and JTAG/SWD default to their alternate function. These
163 * pins cannot normally be committed to GPIO usage. To enable these special
164 * function pins to be used as GPIO, they must be unlocked. This may be achieved
165 * via @ref gpio_unlock_commit. Once a special function pin is unlocked, its
166 * settings may be altered in the usual way.
167 *
168 * For example, to unlock the PF0 pin (NMI on the LM4F120):
169 * @code
170 * // PF0 is an NMI pin, and needs to be unlocked
171 * gpio_unlock_commit(GPIOF, GPIO0);
172 * // Now the pin can be configured
173 * gpio_mode_setup(RGB_PORT, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, btnpins);
174 * @endcode
175 */
176/**@{*/
177
178/**
179 * \brief Enable access to GPIO registers via the AHB aperture
180 *
181 * All GPIO registers are accessed in libopencm3 via the AHB aperture. It
182 * provides faster control over the older APB aperture. This aperture must be
183 * enabled before calling any other gpio_*() function.
184 *
185 */
187{
188 SYSCTL_GPIOHBCTL = 0xffffffff;
189}
190
191/**
192 * \brief Configure a group of pins
193 *
194 * Sets the Pin direction, analog/digital mode, and pull-up configuration of
195 * or a set of GPIO pins on a given GPIO port.
196 *
197 * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
198 * @param[in] mode Pin mode (@ref gpio_mode) \n
199 * - GPIO_MODE_OUTPUT -- Configure pin as output \n
200 * - GPIO_MODE_INPUT -- Configure pin as input \n
201 * - GPIO_MODE_ANALOG -- Configure pin as analog function
202 * @param[in] pullup Pin pullup/pulldown configuration (@ref gpio_pullup) \n
203 * - GPIO_PUPD_NONE -- Do not pull the pin high or low \n
204 * - GPIO_PUPD_PULLUP -- Pull the pin high \n
205 * - GPIO_PUPD_PULLDOWN -- Pull the pin low
206 * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
207 * by OR'ing then together
208 */
209void gpio_mode_setup(uint32_t gpioport, enum gpio_mode mode,
210 enum gpio_pullup pullup, uint8_t gpios)
211{
212 switch (mode) {
213 case GPIO_MODE_OUTPUT:
214 GPIO_DIR(gpioport) |= gpios;
215 GPIO_DEN(gpioport) |= gpios;
216 GPIO_AMSEL(gpioport) &= ~gpios;
217 break;
218 case GPIO_MODE_INPUT:
219 GPIO_DIR(gpioport) &= ~gpios;
220 GPIO_DEN(gpioport) |= gpios;
221 GPIO_AMSEL(gpioport) &= ~gpios;
222 break;
223 case GPIO_MODE_ANALOG:
224 GPIO_DEN(gpioport) &= ~gpios;
225 GPIO_AMSEL(gpioport) |= gpios;
226 break;
227 default:
228 /* Don't do anything */
229 break;
230 }
231
232 /*
233 * Setting a bit in the GPIO_PDR register clears the corresponding bit
234 * in the GPIO_PUR register, and vice-versa.
235 */
236 switch (pullup) {
237 case GPIO_PUPD_PULLUP:
238 GPIO_PUR(gpioport) |= gpios;
239 break;
241 GPIO_PDR(gpioport) |= gpios;
242 break;
243 case GPIO_PUPD_NONE: /* Fall through */
244 default:
245 GPIO_PUR(gpioport) &= ~gpios;
246 GPIO_PDR(gpioport) &= ~gpios;
247 break;
248 }
249}
250
251/**
252 * \brief Configure output parameters of a group of pins
253 *
254 * Sets the output configuration and drive strength, of or a set of GPIO pins
255 * for a set of GPIO pins in output mode.
256 *
257 * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
258 * @param[in] otype Output driver configuration (@ref gpio_output_type) \n
259 * - GPIO_OTYPE_PP -- Configure pin driver as push-pull \n
260 * - GPIO_OTYPE_OD -- Configure pin driver as open drain
261 * @param[in] drive Pin drive strength (@ref gpio_drive_strength) \n
262 * - GPIO_DRIVE_2MA -- 2mA drive \n
263 * - GPIO_DRIVE_4MA -- 4mA drive \n
264 * - GPIO_DRIVE_8MA -- 8mA drive \n
265 * - GPIO_DRIVE_8MA_SLEW_CTL -- 8mA drive with slew rate
266 * control
267 * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
268 * by OR'ing then together
269 */
270void gpio_set_output_config(uint32_t gpioport, enum gpio_output_type otype,
271 enum gpio_drive_strength drive, uint8_t gpios)
272{
273 if (otype == GPIO_OTYPE_OD) {
274 GPIO_ODR(gpioport) |= gpios;
275 } else {
276 GPIO_ODR(gpioport) &= ~gpios;
277 }
278
279 /*
280 * Setting a bit in the GPIO_DRxR register clears the corresponding bit
281 * in the other GPIO_DRyR registers, and vice-versa.
282 */
283 switch (drive) {
285 GPIO_DR8R(gpioport) |= gpios;
286 GPIO_SLR(gpioport) |= gpios;
287 break;
288 case GPIO_DRIVE_8MA:
289 GPIO_DR8R(gpioport) |= gpios;
290 GPIO_SLR(gpioport) &= ~gpios;
291 break;
292 case GPIO_DRIVE_4MA:
293 GPIO_DR4R(gpioport) |= gpios;
294 break;
295 case GPIO_DRIVE_2MA: /* Fall through */
296 default:
297 GPIO_DR2R(gpioport) |= gpios;
298 break;
299 }
300}
301
302#define PCTL_AF(pin, af) ((af) << ((pin) << 2))
303#define PCTL_MASK(pin) PCTL_AF((pin), 0xf)
304/**
305 * \brief Multiplex group of pins to the given alternate function
306 *
307 * Mux the pin or group of pins to the given alternate function. Note that a
308 * number of pins may be set but only with a single AF number. This is useful
309 * when one or more of a peripheral's pins are assigned to the same alternate
310 * function.
311 *
312 * Because AF0 is not used on the LM4F, passing 0 as the alt_func_num parameter
313 * will disable the alternate function of the given pins.
314 *
315 * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
316 * @param[in] alt_func_num Pin alternate function number or 0 to disable the
317 * alternate function multiplexing.
318 * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
319 * by OR'ing then together
320 */
321void gpio_set_af(uint32_t gpioport, uint8_t alt_func_num, uint8_t gpios)
322{
323 uint32_t pctl32;
324 uint8_t pin_mask;
325 int i;
326
327 /* Did we mean to disable the alternate function? */
328 if (alt_func_num == 0) {
329 GPIO_AFSEL(gpioport) &= ~gpios;
330 return;
331 }
332
333 /* Enable the alternate function */
334 GPIO_AFSEL(gpioport) |= gpios;
335 /* Alternate functions are digital */
336 GPIO_DEN(gpioport) |= gpios;
337
338 /* Now take care of the actual multiplexing */
339 pctl32 = GPIO_PCTL(gpioport);
340 for (i = 0; i < 8; i++) {
341 pin_mask = (1 << i);
342
343 if (!(gpios & pin_mask)) {
344 continue;
345 }
346
347 pctl32 &= ~PCTL_MASK(i);
348 pctl32 |= PCTL_AF(i, (alt_func_num & 0xf));
349 }
350
351 GPIO_PCTL(gpioport) = pctl32;
352}
353
354/**
355 * \brief Unlock the commit control of a special function pin
356 *
357 * Unlocks the commit control of the given pin or group of pins. If a pin is a
358 * JTAG/SWD or NMI, the pin may then be reconfigured as a GPIO pin. If the pin
359 * is not locked by default, this has no effect.
360 *
361 * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
362 * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
363 * by OR'ing then together.
364 */
365void gpio_unlock_commit(uint32_t gpioport, uint8_t gpios)
366{
367 /* Unlock the GPIO_CR register */
369 /* Enable committing changes */
370 GPIO_CR(gpioport) |= gpios;
371 /* Lock the GPIO_CR register */
372 GPIO_LOCK(gpioport) = ~GPIO_LOCK_UNLOCK_CODE;
373}
374/**@}*/
375
376/** @defgroup gpio_control GPIO pin control
377 * @ingroup gpio_file
378 *
379 * \brief <b>Controlling GPIO pins</b>
380 *
381 * Each I/O port has 8 individually configurable bits. When reading and writing
382 * data to the GPIO ports, address bits [9:2] mask the pins to be read or
383 * written. This mechanism makes all GPIO port reads and writes on the LM4F
384 * atomic operations. The GPIO API takes full advantage of this fact to preserve
385 * the atomicity of these operations.
386 *
387 * Setting or clearing a group of bits can be accomplished with @ref gpio_set()
388 * and @ref gpio_clear() respectively. These operation use the masking mechanism
389 * described above to only affect the specified pins.
390 *
391 * Sometimes it is more appropriate to read or set the level of a group of pins
392 * on a port, in one atomic operation. Reading the status can be accomplished
393 * with @ref gpio_read(). The result is equivalent to reading all the pins, then
394 * masking only the desired pins; however, the masking is done in hardware, and
395 * does not require an extra hardware operation.
396 *
397 * Writing a group of pins can be accomplished with @ref gpio_write(). The mask
398 * ('gpios' parameter) is applied in hardware, and the masked pins are not
399 * affected, regardless of the value of the respective bits written to the GPIO
400 * port.
401 *
402 * Two extra functions are provided, @ref gpio_port_read() and
403 * @ref gpio_port_write(). They are functionally identical to
404 * @ref gpio_read (port, GPIO_ALL) and @ref gpio_write (port, GPIO_ALL, val)
405 * respectively. Hence, they are also atomic.
406 *
407 * GPIO pins may be toggled with @ref gpio_toggle(). This function does not
408 * translate to an atomic operation.
409 *
410 * @note
411 * The @ref gpio_toggle() operation is the only GPIO port operation which is not
412 * atomic. It involves a read-modify-write cycle.
413 *
414 * Suppose PA0, PA1, PA2, and PA3 are to be modified without affecting the other
415 * pins on port A. This is common when controlling, for example, a 4-bit bus:
416 * @code{.c}
417 * // Pins 4,5,6, and 7 are unaffected, regardless of the bits in val
418 * gpio_write(GPIOA, GPIO0 | GPIO1 | GPIO2 | GPIO3, val);
419 * // Wait a bit then send the other 4 bits
420 * wait_a_bit();
421 * gpio_write(GPIOA, GPIO0 | GPIO1 | GPIO2 | GPIO3, val >> 4);
422 * @endcode
423 *
424 * Suppose a LED is connected to PD4, and we want to flash the LED for a brief
425 * period of time:
426 * @code
427 * gpio_set(GPIOD, GPIO4);
428 * wait_a_bit();
429 * gpio_set(GPIOD, GPIO4);
430 * @endcode
431 */
432/**@{*/
433/**
434 * \brief Toggle a Group of Pins
435 *
436 * Toggle one or more pins of the given GPIO port.
437 *
438 * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
439 * @param[in] gpios Pin identifiers. @ref gpio_pin_id
440 */
441void gpio_toggle(uint32_t gpioport, uint8_t gpios)
442{
443 /* The mask makes sure we only toggle the GPIOs we want to */
444 GPIO_DATA(gpioport)[gpios] ^= GPIO_ALL;
445}
446/**@}*/
447
448
449/** @defgroup gpio_irq GPIO Interrupt control
450 * @ingroup gpio_file
451 *
452 * \brief <b>Configuring interrupts from GPIO pins</b>
453 *
454 * GPIO pins can trigger interrupts on either edges or levels. The type of
455 * trigger can be configured with @ref gpio_configure_int_trigger(). To have an
456 * event on the given pin generate an interrupt, its interrupt source must be
457 * unmasked. This can be achieved with @ref gpio_enable_interrupts(). Interrupts
458 * which are no longer needed can be disabled through
459 * @ref gpio_disable_interrupts().
460 *
461 * In order for the interrupt to generate an IRQ and a call to the interrupt
462 * service routine, the interrupt for the GPIO port must be routed through the
463 * NVIC with @ref nvic_enable_irq(). For this last step, the nvic.h header is
464 * needed:
465 * @code{.c}
466 * #include <libopencm3/lm4f/nvic.h>
467 * @endcode
468 *
469 * Enabling an interrupt is as simple as configuring the desired trigger,
470 * unmasking the desired interrupt, and routing the desired GPIO port's
471 * interrupt through the NVIC.
472 * @code{.c}
473 * // Trigger interrupt on each rising edge
474 * gpio_configure_trigger(GPIOF, GPIO_TRIG_EDGE_RISE, GPIO0 | GPIO4);
475 * // Unmask the interrupt on those pins
476 * gpio_enable_interrupts(GPIOF, GPIO0 | GPIO4);
477 * // Enable the interrupt in the NVIC as well
478 * nvic_enable_irq(NVIC_GPIOF_IRQ);
479 * @endcode
480 *
481 * After interrupts are properly enabled and routed through the NVIC, when an
482 * event occurs, the appropriate IRQ flag is set by hardware, and execution
483 * jumps to the GPIO ISR. The ISR should query the IRQ flags to determine which
484 * event caused the interrupt. For this, use @ref gpio_is_interrupt_source(),
485 * with the desired GPIO flag. After one or more interrupt sources are
486 * serviced, the IRQ flags must be cleared by the ISR. This can be done with
487 * @ref gpio_clear_interrupt_flag().
488 *
489 * A typical GPIO ISR may look like the following:
490 * @code{.c}
491 * void gpiof_isr(void)
492 * {
493 * uint8_t serviced_irqs = 0;
494 *
495 * // Process individual IRQs
496 * if (gpio_is_interrupt_source(GPIOF, GPIO0)) {
497 * process_gpio0_event();
498 * serviced_irq |= GPIO0;
499 * }
500 * if (gpio_is_interrupt_source(GPIOF, GPIO4)) {
501 * process_gpio4_event();
502 * serviced_irq |= GPIO4;
503 * }
504 *
505 * // Clear the interrupt flag for the processed IRQs
506 * gpio_clear_interrupt_flag(GPIOF, serviced_irqs);
507 * }
508 * @endcode
509 */
510/**@{*/
511/**
512 * \brief Configure the interrupt trigger on the given GPIO pins
513 *
514 * Sets the Pin direction, analog/digital mode, and pull-up configuration of
515 * or a set of GPIO pins on a given GPIO port.
516 *
517 * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
518 * @param[in] trigger Trigger configuration (@ref gpio_trigger) \n
519 * - GPIO_TRIG_LVL_LOW -- Trigger on low level \n
520 * - GPIO_TRIG_LVL_HIGH -- Trigger on high level \n
521 * - GPIO_TRIG_EDGE_FALL -- Trigger on falling edges \n
522 * - GPIO_TRIG_EDGE_RISE -- Trigger on rising edges \n
523 * - GPIO_TRIG_EDGE_BOTH -- Trigger on all edges
524 * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
525 * by OR'ing then together
526 */
527void gpio_configure_trigger(uint32_t gpioport, enum gpio_trigger trigger,
528 uint8_t gpios)
529{
530 switch (trigger) {
532 GPIO_IS(gpioport) |= gpios;
533 GPIO_IEV(gpioport) &= ~gpios;
534 break;
536 GPIO_IS(gpioport) |= gpios;
537 GPIO_IEV(gpioport) |= gpios;
538 break;
540 GPIO_IS(gpioport) &= ~gpios;
541 GPIO_IBE(gpioport) &= ~gpios;
542 GPIO_IEV(gpioport) &= ~gpios;
543 break;
545 GPIO_IS(gpioport) &= ~gpios;
546 GPIO_IBE(gpioport) &= ~gpios;
547 GPIO_IEV(gpioport) |= gpios;
548 break;
550 GPIO_IS(gpioport) &= ~gpios;
551 GPIO_IBE(gpioport) |= gpios;
552 break;
553 default:
554 /* Don't do anything */
555 break;
556 }
557}
558
559/**
560 * \brief Enable interrupts on specified GPIO pins
561 *
562 * Enable interrupts on the specified GPIO pins
563 *
564 * Note that the NVIC must be enabled and properly configured for the interrupt
565 * to be routed to the CPU.
566 *
567 * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
568 * @param[in] gpios @ref gpio_pin_id. Pins whose interrupts to enable. Any
569 * combination of pins may be specified by OR'ing them
570 * together.
571 */
572void gpio_enable_interrupts(uint32_t gpioport, uint8_t gpios)
573{
574 GPIO_IM(gpioport) |= gpios;
575}
576
577/**
578 * \brief Disable interrupts on specified GPIO pins
579 *
580 * Disable interrupts on the specified GPIO pins
581 *
582 * Note that the NVIC must be enabled and properly configured for the interrupt
583 * to be routed to the CPU.
584 *
585 * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
586 * @param[in] gpios @ref gpio_pin_id. Pins whose interrupts to disable. Any
587 * combination of pins may be specified by OR'ing them
588 * together.
589 */
590void gpio_disable_interrupts(uint32_t gpioport, uint8_t gpios)
591{
592 GPIO_IM(gpioport) |= gpios;
593}
594
595/**@}*/
596
597/**@}*/
598
void gpio_mode_setup(uint32_t gpioport, enum gpio_mode mode, enum gpio_pullup pullup, uint8_t gpios)
Configure a group of pins.
Definition: gpio.c:209
void gpio_unlock_commit(uint32_t gpioport, uint8_t gpios)
Unlock the commit control of a special function pin.
Definition: gpio.c:365
void gpio_set_af(uint32_t gpioport, uint8_t alt_func_num, uint8_t gpios)
Multiplex group of pins to the given alternate function.
Definition: gpio.c:321
void gpio_set_output_config(uint32_t gpioport, enum gpio_output_type otype, enum gpio_drive_strength drive, uint8_t gpios)
Configure output parameters of a group of pins.
Definition: gpio.c:270
void gpio_enable_ahb_aperture(void)
Enable access to GPIO registers via the AHB aperture.
Definition: gpio.c:186
#define PCTL_AF(pin, af)
Definition: gpio.c:302
void gpio_toggle(uint32_t gpioport, uint8_t gpios)
Toggle a Group of Pins.
Definition: gpio.c:441
#define GPIO_DR2R(port)
Definition: gpio.h:123
gpio_drive_strength
Definition: gpio.h:200
#define GPIO_DR8R(port)
Definition: gpio.h:129
gpio_pullup
Definition: gpio.h:189
#define GPIO_AFSEL(port)
Definition: gpio.h:120
#define GPIO_ODR(port)
Definition: gpio.h:132
gpio_mode
Definition: gpio.h:183
#define GPIO_DEN(port)
Definition: gpio.h:144
#define GPIO_PUR(port)
Definition: gpio.h:135
#define GPIO_AMSEL(port)
Definition: gpio.h:153
#define GPIO_PDR(port)
Definition: gpio.h:138
#define GPIO_IBE(port)
Definition: gpio.h:102
#define GPIO_CR(port)
Definition: gpio.h:150
#define GPIO_DIR(port)
Definition: gpio.h:96
#define GPIO_DR4R(port)
Definition: gpio.h:126
gpio_output_type
Definition: gpio.h:195
#define GPIO_SLR(port)
Definition: gpio.h:141
#define GPIO_LOCK(port)
Definition: gpio.h:147
#define GPIO_DATA(port)
Definition: gpio.h:93
#define GPIO_PCTL(port)
Definition: gpio.h:156
#define GPIO_IM(port)
Definition: gpio.h:108
#define GPIO_IEV(port)
Definition: gpio.h:105
#define GPIO_IS(port)
Definition: gpio.h:99
gpio_trigger
Definition: gpio.h:207
@ GPIO_DRIVE_8MA_SLEW_CTL
8mA drive with slew rate control
Definition: gpio.h:204
@ GPIO_DRIVE_8MA
8mA drive
Definition: gpio.h:203
@ GPIO_DRIVE_2MA
2mA drive
Definition: gpio.h:201
@ GPIO_DRIVE_4MA
4mA drive
Definition: gpio.h:202
@ GPIO_PUPD_PULLUP
Pull the pin high.
Definition: gpio.h:191
@ GPIO_PUPD_PULLDOWN
Pull the pin low.
Definition: gpio.h:192
@ GPIO_PUPD_NONE
Do not pull the pin high or low.
Definition: gpio.h:190
@ GPIO_MODE_ANALOG
Configure pin as analog function.
Definition: gpio.h:186
@ GPIO_MODE_INPUT
Configure pin as input.
Definition: gpio.h:185
@ GPIO_MODE_OUTPUT
Configure pin as output.
Definition: gpio.h:184
@ GPIO_OTYPE_OD
Open drain configuration.
Definition: gpio.h:197
@ GPIO_TRIG_EDGE_BOTH
Falling and Rising edges trigger.
Definition: gpio.h:212
@ GPIO_TRIG_EDGE_FALL
Falling edge trigger.
Definition: gpio.h:210
@ GPIO_TRIG_LVL_LOW
Level trigger, signal low.
Definition: gpio.h:208
@ GPIO_TRIG_LVL_HIGH
Level trigger, signal high.
Definition: gpio.h:209
@ GPIO_TRIG_EDGE_RISE
Rising edge trigger.
Definition: gpio.h:211
#define GPIO_LOCK_UNLOCK_CODE
Definition: gpio.c:61
void gpio_enable_interrupts(uint32_t gpioport, uint8_t gpios)
Enable interrupts on specified GPIO pins.
Definition: gpio.c:572
void gpio_configure_trigger(uint32_t gpioport, enum gpio_trigger trigger, uint8_t gpios)
Configure the interrupt trigger on the given GPIO pins.
Definition: gpio.c:527
void gpio_disable_interrupts(uint32_t gpioport, uint8_t gpios)
Disable interrupts on specified GPIO pins.
Definition: gpio.c:590
#define GPIO_ALL
Definition: gpio.h:85
#define SYSCTL_GPIOHBCTL
Definition: systemcontrol.h:64