libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Defined Constants and Types for the GD32F1x0 General Purpose I/O More...
Modules | |
GPIO Pin Identifiers | |
GPIO Port IDs | |
GPIO Pin Direction and Analog/Digital Mode | |
GPIO Output Pin Driver Type | |
GPIO Output Pin Speed | |
GPIO Output Pin Pullup | |
Alternate Function Pin Selection | |
Functions | |
void | gpio_set (uint32_t gpioport, uint16_t gpios) |
Set a Group of Pins Atomic. More... | |
void | gpio_clear (uint32_t gpioport, uint16_t gpios) |
Clear a Group of Pins Atomic. More... | |
uint16_t | gpio_get (uint32_t gpioport, uint16_t gpios) |
Read a Group of Pins. More... | |
void | gpio_toggle (uint32_t gpioport, uint16_t gpios) |
Toggle a Group of Pins. More... | |
uint16_t | gpio_port_read (uint32_t gpioport) |
Read from a Port. More... | |
void | gpio_port_write (uint32_t gpioport, uint16_t data) |
Write to a Port. More... | |
void | gpio_port_config_lock (uint32_t gpioport, uint16_t gpios) |
Lock the Configuration of a Group of Pins. More... | |
void | gpio_mode_setup (uint32_t gpioport, uint8_t mode, uint8_t pull_up_down, uint16_t gpios) |
Set GPIO Pin Mode. More... | |
void | gpio_set_output_options (uint32_t gpioport, uint8_t otype, uint8_t speed, uint16_t gpios) |
Set GPIO Output Options. More... | |
void | gpio_set_af (uint32_t gpioport, uint8_t alt_func_num, uint16_t gpios) |
Set GPIO Alternate Function Selection. More... | |
Defined Constants and Types for the GD32F1x0 General Purpose I/O
Defined Constants and Types for the STM32F0xx General Purpose I/O
LGPL License Terms libopencm3 License
#define GPIO_AFR | ( | n, | |
af | |||
) | ((af) << ((n) * 4)) |
Definition at line 243 of file gpio_common_f234.h.
#define GPIO_AFR_MASK | ( | n | ) | (0xf << ((n) * 4)) |
Definition at line 244 of file gpio_common_f234.h.
#define GPIO_AFRH | ( | port | ) | MMIO32((port) + 0x24) |
Definition at line 161 of file gpio_common_f234.h.
#define GPIO_AFRL | ( | port | ) | MMIO32((port) + 0x20) |
Definition at line 150 of file gpio_common_f234.h.
#define GPIO_BSRR | ( | port | ) | MMIO32((port) + 0x18) |
Definition at line 128 of file gpio_common_f234.h.
#define GPIO_IDR | ( | port | ) | MMIO32((port) + 0x10) |
Definition at line 106 of file gpio_common_f234.h.
#define GPIO_LCKK (1 << 16) |
Definition at line 45 of file gpio_common_all.h.
#define GPIO_LCKK (1 << 16) |
Definition at line 235 of file gpio_common_f234.h.
#define GPIO_LCKR | ( | port | ) | MMIO32((port) + 0x1c) |
Definition at line 139 of file gpio_common_f234.h.
#define GPIO_MODE | ( | n, | |
mode | |||
) | ((mode) << (2 * (n))) |
Definition at line 173 of file gpio_common_f234.h.
#define GPIO_MODE_MASK | ( | n | ) | (0x3 << (2 * (n))) |
Definition at line 174 of file gpio_common_f234.h.
#define GPIO_MODER | ( | port | ) | MMIO32((port) + 0x00) |
Definition at line 62 of file gpio_common_f234.h.
#define GPIO_ODR | ( | port | ) | MMIO32((port) + 0x14) |
Definition at line 117 of file gpio_common_f234.h.
#define GPIO_OSPEED | ( | n, | |
speed | |||
) | ((speed) << (2 * (n))) |
Definition at line 197 of file gpio_common_f234.h.
#define GPIO_OSPEED_MASK | ( | n | ) | (0x3 << (2 * (n))) |
Definition at line 198 of file gpio_common_f234.h.
#define GPIO_OSPEEDR | ( | port | ) | MMIO32((port) + 0x08) |
Definition at line 84 of file gpio_common_f234.h.
#define GPIO_OTYPER | ( | port | ) | MMIO32((port) + 0x04) |
Definition at line 73 of file gpio_common_f234.h.
#define GPIO_PUPD | ( | n, | |
pupd | |||
) | ((pupd) << (2 * (n))) |
Definition at line 210 of file gpio_common_f234.h.
#define GPIO_PUPD_MASK | ( | n | ) | (0x3 << (2 * (n))) |
Definition at line 211 of file gpio_common_f234.h.
#define GPIO_PUPDR | ( | port | ) | MMIO32((port) + 0x0c) |
Definition at line 95 of file gpio_common_f234.h.
Definition at line 162 of file gpio_common_f234.h.
Definition at line 151 of file gpio_common_f234.h.
Definition at line 129 of file gpio_common_f234.h.
Definition at line 107 of file gpio_common_f234.h.
Definition at line 140 of file gpio_common_f234.h.
#define GPIOA_MODER GPIO_MODER(GPIOA) |
Definition at line 63 of file gpio_common_f234.h.
Definition at line 118 of file gpio_common_f234.h.
#define GPIOA_OSPEEDR GPIO_OSPEEDR(GPIOA) |
Definition at line 85 of file gpio_common_f234.h.
#define GPIOA_OTYPER GPIO_OTYPER(GPIOA) |
Definition at line 74 of file gpio_common_f234.h.
#define GPIOA_PUPDR GPIO_PUPDR(GPIOA) |
Definition at line 96 of file gpio_common_f234.h.
Definition at line 163 of file gpio_common_f234.h.
Definition at line 152 of file gpio_common_f234.h.
Definition at line 130 of file gpio_common_f234.h.
Definition at line 108 of file gpio_common_f234.h.
Definition at line 141 of file gpio_common_f234.h.
#define GPIOB_MODER GPIO_MODER(GPIOB) |
Definition at line 64 of file gpio_common_f234.h.
Definition at line 119 of file gpio_common_f234.h.
#define GPIOB_OSPEEDR GPIO_OSPEEDR(GPIOB) |
Definition at line 86 of file gpio_common_f234.h.
#define GPIOB_OTYPER GPIO_OTYPER(GPIOB) |
Definition at line 75 of file gpio_common_f234.h.
#define GPIOB_PUPDR GPIO_PUPDR(GPIOB) |
Definition at line 97 of file gpio_common_f234.h.
Definition at line 164 of file gpio_common_f234.h.
Definition at line 153 of file gpio_common_f234.h.
Definition at line 131 of file gpio_common_f234.h.
Definition at line 109 of file gpio_common_f234.h.
Definition at line 142 of file gpio_common_f234.h.
#define GPIOC_MODER GPIO_MODER(GPIOC) |
Definition at line 65 of file gpio_common_f234.h.
Definition at line 120 of file gpio_common_f234.h.
#define GPIOC_OSPEEDR GPIO_OSPEEDR(GPIOC) |
Definition at line 87 of file gpio_common_f234.h.
#define GPIOC_OTYPER GPIO_OTYPER(GPIOC) |
Definition at line 76 of file gpio_common_f234.h.
#define GPIOC_PUPDR GPIO_PUPDR(GPIOC) |
Definition at line 98 of file gpio_common_f234.h.
Definition at line 165 of file gpio_common_f234.h.
Definition at line 154 of file gpio_common_f234.h.
Definition at line 132 of file gpio_common_f234.h.
Definition at line 110 of file gpio_common_f234.h.
Definition at line 143 of file gpio_common_f234.h.
#define GPIOD_MODER GPIO_MODER(GPIOD) |
Definition at line 66 of file gpio_common_f234.h.
Definition at line 121 of file gpio_common_f234.h.
#define GPIOD_OSPEEDR GPIO_OSPEEDR(GPIOD) |
Definition at line 88 of file gpio_common_f234.h.
#define GPIOD_OTYPER GPIO_OTYPER(GPIOD) |
Definition at line 77 of file gpio_common_f234.h.
#define GPIOD_PUPDR GPIO_PUPDR(GPIOD) |
Definition at line 99 of file gpio_common_f234.h.
Definition at line 166 of file gpio_common_f234.h.
Definition at line 155 of file gpio_common_f234.h.
Definition at line 133 of file gpio_common_f234.h.
Definition at line 111 of file gpio_common_f234.h.
Definition at line 144 of file gpio_common_f234.h.
#define GPIOE_MODER GPIO_MODER(GPIOE) |
Definition at line 67 of file gpio_common_f234.h.
Definition at line 122 of file gpio_common_f234.h.
#define GPIOE_OSPEEDR GPIO_OSPEEDR(GPIOE) |
Definition at line 89 of file gpio_common_f234.h.
#define GPIOE_OTYPER GPIO_OTYPER(GPIOE) |
Definition at line 78 of file gpio_common_f234.h.
#define GPIOE_PUPDR GPIO_PUPDR(GPIOE) |
Definition at line 100 of file gpio_common_f234.h.
Definition at line 167 of file gpio_common_f234.h.
Definition at line 156 of file gpio_common_f234.h.
Definition at line 134 of file gpio_common_f234.h.
Definition at line 112 of file gpio_common_f234.h.
Definition at line 145 of file gpio_common_f234.h.
#define GPIOF_MODER GPIO_MODER(GPIOF) |
Definition at line 68 of file gpio_common_f234.h.
Definition at line 123 of file gpio_common_f234.h.
#define GPIOF_OSPEEDR GPIO_OSPEEDR(GPIOF) |
Definition at line 90 of file gpio_common_f234.h.
#define GPIOF_OTYPER GPIO_OTYPER(GPIOF) |
Definition at line 79 of file gpio_common_f234.h.
#define GPIOF_PUPDR GPIO_PUPDR(GPIOF) |
Definition at line 101 of file gpio_common_f234.h.
Definition at line 168 of file gpio_common_f234.h.
Definition at line 157 of file gpio_common_f234.h.
Definition at line 135 of file gpio_common_f234.h.
Definition at line 113 of file gpio_common_f234.h.
Definition at line 146 of file gpio_common_f234.h.
#define GPIOG_MODER GPIO_MODER(GPIOG) |
Definition at line 69 of file gpio_common_f234.h.
Definition at line 124 of file gpio_common_f234.h.
#define GPIOG_OSPEEDR GPIO_OSPEEDR(GPIOG) |
Definition at line 91 of file gpio_common_f234.h.
#define GPIOG_OTYPER GPIO_OTYPER(GPIOG) |
Definition at line 80 of file gpio_common_f234.h.
#define GPIOG_PUPDR GPIO_PUPDR(GPIOG) |
Definition at line 102 of file gpio_common_f234.h.
Definition at line 169 of file gpio_common_f234.h.
Definition at line 158 of file gpio_common_f234.h.
Definition at line 136 of file gpio_common_f234.h.
Definition at line 114 of file gpio_common_f234.h.
Definition at line 147 of file gpio_common_f234.h.
#define GPIOH_MODER GPIO_MODER(GPIOH) |
Definition at line 70 of file gpio_common_f234.h.
Definition at line 125 of file gpio_common_f234.h.
#define GPIOH_OSPEEDR GPIO_OSPEEDR(GPIOH) |
Definition at line 92 of file gpio_common_f234.h.
#define GPIOH_OTYPER GPIO_OTYPER(GPIOH) |
Definition at line 81 of file gpio_common_f234.h.
#define GPIOH_PUPDR GPIO_PUPDR(GPIOH) |
Definition at line 103 of file gpio_common_f234.h.
Definition at line 101 of file gpio_common_f24.h.
Definition at line 96 of file gpio_common_f24.h.
Definition at line 86 of file gpio_common_f24.h.
Definition at line 76 of file gpio_common_f24.h.
Definition at line 91 of file gpio_common_f24.h.
#define GPIOI_MODER GPIO_MODER(GPIOI) |
Definition at line 56 of file gpio_common_f24.h.
Definition at line 81 of file gpio_common_f24.h.
#define GPIOI_OSPEEDR GPIO_OSPEEDR(GPIOI) |
Definition at line 66 of file gpio_common_f24.h.
#define GPIOI_OTYPER GPIO_OTYPER(GPIOI) |
Definition at line 61 of file gpio_common_f24.h.
#define GPIOI_PUPDR GPIO_PUPDR(GPIOI) |
Definition at line 71 of file gpio_common_f24.h.
Definition at line 102 of file gpio_common_f24.h.
Definition at line 97 of file gpio_common_f24.h.
Definition at line 87 of file gpio_common_f24.h.
Definition at line 77 of file gpio_common_f24.h.
Definition at line 92 of file gpio_common_f24.h.
#define GPIOJ_MODER GPIO_MODER(GPIOJ) |
Definition at line 57 of file gpio_common_f24.h.
Definition at line 82 of file gpio_common_f24.h.
#define GPIOJ_OSPEEDR GPIO_OSPEEDR(GPIOJ) |
Definition at line 67 of file gpio_common_f24.h.
#define GPIOJ_OTYPER GPIO_OTYPER(GPIOJ) |
Definition at line 62 of file gpio_common_f24.h.
#define GPIOJ_PUPDR GPIO_PUPDR(GPIOJ) |
Definition at line 72 of file gpio_common_f24.h.
Definition at line 103 of file gpio_common_f24.h.
Definition at line 98 of file gpio_common_f24.h.
Definition at line 88 of file gpio_common_f24.h.
Definition at line 78 of file gpio_common_f24.h.
Definition at line 93 of file gpio_common_f24.h.
#define GPIOK_MODER GPIO_MODER(GPIOK) |
Definition at line 58 of file gpio_common_f24.h.
Definition at line 83 of file gpio_common_f24.h.
#define GPIOK_OSPEEDR GPIO_OSPEEDR(GPIOK) |
Definition at line 68 of file gpio_common_f24.h.
#define GPIOK_OTYPER GPIO_OTYPER(GPIOK) |
Definition at line 63 of file gpio_common_f24.h.
#define GPIOK_PUPDR GPIO_PUPDR(GPIOK) |
Definition at line 73 of file gpio_common_f24.h.
void gpio_clear | ( | uint32_t | gpioport, |
uint16_t | gpios | ||
) |
Clear a Group of Pins Atomic.
Clear one or more pins of the given GPIO port to 0 in an atomic operation.
[in] | gpioport | Unsigned int32. Port identifier GPIO Port IDs |
[in] | gpios | Unsigned int16. Pin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them. |
Definition at line 56 of file gpio_common_all.c.
References GPIO_BSRR.
uint16_t gpio_get | ( | uint32_t | gpioport, |
uint16_t | gpios | ||
) |
Read a Group of Pins.
[in] | gpioport | Unsigned int32. Port identifier GPIO Port IDs |
[in] | gpios | Unsigned int16. Pin identifiers GPIO Pin Identifiers If multiple pins are to be read, use bitwise OR '|' to separate them. |
Definition at line 71 of file gpio_common_all.c.
References gpio_port_read().
void gpio_mode_setup | ( | uint32_t | gpioport, |
uint8_t | mode, | ||
uint8_t | pull_up_down, | ||
uint16_t | gpios | ||
) |
Set GPIO Pin Mode.
Sets the Pin Direction and Analog/Digital Mode, and Output Pin Pullup, for a set of GPIO pins on a given GPIO port.
[in] | gpioport | Unsigned int32. Port identifier GPIO Port IDs |
[in] | mode | Unsigned int8. Pin mode GPIO Pin Direction and Analog/Digital Mode |
[in] | pull_up_down | Unsigned int8. Pin pullup/pulldown configuration GPIO Output Pin Pullup |
[in] | gpios | Unsigned int16. Pin identifiers GPIO Pin Identifiers If multiple pins are to be set, use bitwise OR '|' to separate them. |
Definition at line 89 of file gpio_common_f0234.c.
References GPIO_MODE, GPIO_MODER, GPIO_PUPD, and GPIO_PUPDR.
void gpio_port_config_lock | ( | uint32_t | gpioport, |
uint16_t | gpios | ||
) |
Lock the Configuration of a Group of Pins.
The configuration of one or more pins of the given GPIO port is locked. There is no mechanism to unlock these via software. Unlocking occurs at the next reset.
[in] | gpioport | Unsigned int32. Port identifier GPIO Port IDs |
[in] | gpios | Unsigned int16. Pin identifiers GPIO Pin Identifiers If multiple pins are to be locked, use bitwise OR '|' to separate them. |
Definition at line 132 of file gpio_common_all.c.
uint16_t gpio_port_read | ( | uint32_t | gpioport | ) |
Read from a Port.
Read the current value of the given GPIO port. Only the lower 16 bits contain valid pin data.
[in] | gpioport | Unsigned int32. Port identifier GPIO Port IDs |
Definition at line 102 of file gpio_common_all.c.
References GPIO_IDR.
Referenced by gpio_get().
void gpio_port_write | ( | uint32_t | gpioport, |
uint16_t | data | ||
) |
Write to a Port.
Write a value to the given GPIO port.
[in] | gpioport | Unsigned int32. Port identifier GPIO Port IDs |
[in] | data | Unsigned int16. The value to be written to the GPIO port. |
Definition at line 115 of file gpio_common_all.c.
References GPIO_ODR.
void gpio_set | ( | uint32_t | gpioport, |
uint16_t | gpios | ||
) |
Set a Group of Pins Atomic.
Set one or more pins of the given GPIO port to 1 in an atomic operation.
[in] | gpioport | Unsigned int32. Port identifier GPIO Port IDs |
[in] | gpios | Unsigned int16. Pin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them. |
Definition at line 41 of file gpio_common_all.c.
References GPIO_BSRR.
void gpio_set_af | ( | uint32_t | gpioport, |
uint8_t | alt_func_num, | ||
uint16_t | gpios | ||
) |
Set GPIO Alternate Function Selection.
Set the alternate function mapping number for each pin. Most pins have alternate functions associated with them. When set to AF mode, a pin may be used for one of its allocated alternate functions selected by the number given here. To determine the number to be used for the desired function refer to the individual datasheet for the particular device. A table is given under the Pin Selection chapter.
Note that a number of pins may be set but only with a single AF number. In practice this would rarely be useful as each pin is likely to require a different number.
[in] | gpioport | Unsigned int32. Port identifier GPIO Port IDs |
[in] | alt_func_num | Unsigned int8. Pin alternate function number Alternate Function Pin Selection |
[in] | gpios | Unsigned int16. Pin identifiers GPIO Pin Identifiers If multiple pins are to be set, use bitwise OR '|' to separate them. |
Definition at line 178 of file gpio_common_f0234.c.
void gpio_set_output_options | ( | uint32_t | gpioport, |
uint8_t | otype, | ||
uint8_t | speed, | ||
uint16_t | gpios | ||
) |
Set GPIO Output Options.
When the pin is set to output mode, this sets the configuration (analog/digital and open drain/push pull) and speed, for a set of GPIO pins on a given GPIO port.
[in] | gpioport | Unsigned int32. Port identifier GPIO Port IDs |
[in] | otype | Unsigned int8. Pin output type GPIO Output Pin Driver Type |
[in] | speed | Unsigned int8. Pin speed GPIO Output Pin Speed |
[in] | gpios | Unsigned int16. Pin identifiers GPIO Pin Identifiers If multiple pins are to be set, use bitwise OR '|' to separate them. |
Definition at line 132 of file gpio_common_f0234.c.
References GPIO_OSPEED, GPIO_OSPEEDR, and GPIO_OTYPER.
void gpio_toggle | ( | uint32_t | gpioport, |
uint16_t | gpios | ||
) |
Toggle a Group of Pins.
Toggle one or more pins of the given GPIO port. The toggling is not atomic, but the non-toggled pins are not affected.
[in] | gpioport | Unsigned int32. Port identifier GPIO Port IDs |
[in] | gpios | Unsigned int16. Pin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them. |
Definition at line 87 of file gpio_common_all.c.