libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
gpio.h File Reference
Include dependency graph for gpio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GPIOA   GPIOA_BASE
 
#define GPIOB   GPIOB_BASE
 
#define GPIOC   GPIOC_BASE
 
#define GPIOD   GPIOD_BASE
 
#define GPIOE   GPIOE_BASE
 
#define GPIOF   GPIOF_BASE
 
#define GPIOG   GPIOG_BASE
 
#define GPIOH   GPIOH_BASE
 
#define GPIOJ   GPIOJ_BASE
 
#define GPIOK   GPIOK_BASE
 
#define GPIOL   GPIOL_BASE
 
#define GPIOM   GPIOM_BASE
 
#define GPION   GPION_BASE
 
#define GPIOP   GPIOP_BASE
 
#define GPIOQ   GPIOQ_BASE
 
#define GPIO0   (1 << 0)
 
#define GPIO1   (1 << 1)
 
#define GPIO2   (1 << 2)
 
#define GPIO3   (1 << 3)
 
#define GPIO4   (1 << 4)
 
#define GPIO5   (1 << 5)
 
#define GPIO6   (1 << 6)
 
#define GPIO7   (1 << 7)
 
#define GPIO_ALL   0xff
 
#define GPIO_DATA(port)   (&MMIO32((port) + 0x000))
 
#define GPIO_DIR(port)   MMIO32((port) + 0x400)
 
#define GPIO_IS(port)   MMIO32((port) + 0x404)
 
#define GPIO_IBE(port)   MMIO32((port) + 0x408)
 
#define GPIO_IEV(port)   MMIO32((port) + 0x40c)
 
#define GPIO_IM(port)   MMIO32((port) + 0x410)
 
#define GPIO_RIS(port)   MMIO32((port) + 0x414)
 
#define GPIO_MIS(port)   MMIO32((port) + 0x418)
 
#define GPIO_ICR(port)   MMIO32((port) + 0x41c)
 
#define GPIO_AFSEL(port)   MMIO32((port) + 0x420)
 
#define GPIO_DR2R(port)   MMIO32((port) + 0x500)
 
#define GPIO_DR4R(port)   MMIO32((port) + 0x504)
 
#define GPIO_DR8R(port)   MMIO32((port) + 0x508)
 
#define GPIO_ODR(port)   MMIO32((port) + 0x50c)
 
#define GPIO_PUR(port)   MMIO32((port) + 0x510)
 
#define GPIO_PDR(port)   MMIO32((port) + 0x514)
 
#define GPIO_SLR(port)   MMIO32((port) + 0x518)
 
#define GPIO_DEN(port)   MMIO32((port) + 0x51c)
 
#define GPIO_LOCK(port)   MMIO32((port) + 0x520)
 
#define GPIO_CR(port)   MMIO32((port) + 0x524)
 
#define GPIO_AMSEL(port)   MMIO32((port) + 0x528)
 
#define GPIO_PCTL(port)   MMIO32((port) + 0x52C)
 
#define GPIO_ADCCTL(port)   MMIO32((port) + 0x530)
 
#define GPIO_DMACTL(port)   MMIO32((port) + 0x534)
 
#define GPIO_PERIPH_ID4(port)   MMIO32((port) + 0xFD0)
 
#define GPIO_PERIPH_ID5(port)   MMIO32((port) + 0xFD4)
 
#define GPIO_PERIPH_ID6(port)   MMIO32((port) + 0xFD8)
 
#define GPIO_PERIPH_ID7(port)   MMIO32((port) + 0xFDC)
 
#define GPIO_PERIPH_ID0(port)   MMIO32((port) + 0xFE0)
 
#define GPIO_PERIPH_ID1(port)   MMIO32((port) + 0xFE4)
 
#define GPIO_PERIPH_ID2(port)   MMIO32((port) + 0xFE8)
 
#define GPIO_PERIPH_ID3(port)   MMIO32((port) + 0xFEC)
 
#define GPIO_PCELL_ID0(port)   MMIO32((port) + 0xFF0)
 
#define GPIO_PCELL_ID1(port)   MMIO32((port) + 0xFF4)
 
#define GPIO_PCELL_ID2(port)   MMIO32((port) + 0xFF8)
 
#define GPIO_PCELL_ID3(port)   MMIO32((port) + 0xFFC)
 

Enumerations

enum  gpio_mode { GPIO_MODE_OUTPUT , GPIO_MODE_INPUT , GPIO_MODE_ANALOG }
 
enum  gpio_pullup { GPIO_PUPD_NONE , GPIO_PUPD_PULLUP , GPIO_PUPD_PULLDOWN }
 
enum  gpio_output_type { GPIO_OTYPE_PP , GPIO_OTYPE_OD }
 
enum  gpio_drive_strength { GPIO_DRIVE_2MA , GPIO_DRIVE_4MA , GPIO_DRIVE_8MA , GPIO_DRIVE_8MA_SLEW_CTL }
 
enum  gpio_trigger {
  GPIO_TRIG_LVL_LOW , GPIO_TRIG_LVL_HIGH , GPIO_TRIG_EDGE_FALL , GPIO_TRIG_EDGE_RISE ,
  GPIO_TRIG_EDGE_BOTH
}
 

Functions

void gpio_enable_ahb_aperture (void)
 Enable access to GPIO registers via the AHB aperture. More...
 
void gpio_mode_setup (uint32_t gpioport, enum gpio_mode mode, enum gpio_pullup pullup, uint8_t gpios)
 Configure a group of pins. More...
 
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. More...
 
void gpio_set_af (uint32_t gpioport, uint8_t alt_func_num, uint8_t gpios)
 Multiplex group of pins to the given alternate function. More...
 
void gpio_toggle (uint32_t gpioport, uint8_t gpios)
 Toggle a Group of Pins. More...
 
void gpio_unlock_commit (uint32_t gpioport, uint8_t gpios)
 Unlock the commit control of a special function pin. More...
 
void gpio_configure_trigger (uint32_t gpioport, enum gpio_trigger trigger, uint8_t gpios)
 Configure the interrupt trigger on the given GPIO pins. More...
 
void gpio_enable_interrupts (uint32_t gpioport, uint8_t gpios)
 Enable interrupts on specified GPIO pins. More...
 
void gpio_disable_interrupts (uint32_t gpioport, uint8_t gpios)
 Disable interrupts on specified GPIO pins. More...
 
static uint8_t gpio_read (uint32_t gpioport, uint8_t gpios)
 Get status of a Group of Pins (atomic) More...
 
static void gpio_write (uint32_t gpioport, uint8_t gpios, uint8_t data)
 Set level of a Group of Pins (atomic) More...
 
static void gpio_set (uint32_t gpioport, uint8_t gpios)
 Set a Group of Pins (atomic) More...
 
static void gpio_clear (uint32_t gpioport, uint8_t gpios)
 Clear a Group of Pins (atomic) More...
 
static uint8_t gpio_port_read (uint32_t gpioport)
 Read level of all pins from a port (atomic) More...
 
static void gpio_port_write (uint32_t gpioport, uint8_t data)
 Set level of of all pins from a port (atomic) More...
 
static bool gpio_is_interrupt_source (uint32_t gpioport, uint8_t srcpins)
 Determine if interrupt is generated by the given pin. More...
 
static void gpio_clear_interrupt_flag (uint32_t gpioport, uint8_t gpios)
 Mark interrupt as serviced. More...