PebbleOS v4.47.0
Loading...
Searching...
No Matches
gpio.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <pbl/device.h>
#include <pbl/drivers/intc.h>

Data Structures

struct  pbl_gpio_port_ops
 Port driver operations. More...
 
struct  pbl_gpio_port
 A GPIO controller. More...
 
struct  pbl_gpio
 A pin as wired on the board. More...
 

Macros

#define PBL_GPIO_PORT_INIT(sym, _name, _init, _parent, _ops, _num_pins, _intc)
 Initializer for a struct pbl_gpio_port.
 
#define PBL_GPIO_DT_FLAGS(f)
 Pin flags from the flags cell of a devicetree GPIO specifier.
 
#define PBL_GPIO(_port, _pin, _flags)   {.port = (_port), .pin = (_pin), .flags = (_flags)}
 Initializer for a struct pbl_gpio.
 
Wiring flags

Describe the pin as routed on the board, stored in struct pbl_gpio.

#define PBL_GPIO_ACTIVE_LOW   (1U << 0)
 The pin is active when low.
 
#define PBL_GPIO_PULL_UP   (1U << 1)
 Enable the pull-up.
 
#define PBL_GPIO_PULL_DOWN   (1U << 2)
 Enable the pull-down.
 
#define PBL_GPIO_OPEN_DRAIN   (1U << 3)
 Drive the output low only.
 
Configuration flags

Passed to pbl_gpio_configure(), OR'ed with the wiring flags.

#define PBL_GPIO_INPUT   (1U << 4)
 Input.
 
#define PBL_GPIO_OUTPUT   (1U << 5)
 Output, keeping the current level.
 
#define PBL_GPIO_OUTPUT_INIT_LOW   (1U << 6)
 Physical initial level low.
 
#define PBL_GPIO_OUTPUT_INIT_HIGH   (1U << 7)
 Physical initial level high.
 
#define PBL_GPIO_OUTPUT_INIT_LOGICAL   (1U << 8)
 The initial level is logical: inverted on an active-low pin.
 
#define PBL_GPIO_OUTPUT_LOW   (PBL_GPIO_OUTPUT | PBL_GPIO_OUTPUT_INIT_LOW)
 Output, physically low.
 
#define PBL_GPIO_OUTPUT_HIGH   (PBL_GPIO_OUTPUT | PBL_GPIO_OUTPUT_INIT_HIGH)
 Output, physically high.
 
#define PBL_GPIO_OUTPUT_INACTIVE   (PBL_GPIO_OUTPUT_LOW | PBL_GPIO_OUTPUT_INIT_LOGICAL)
 Output, inactive.
 
#define PBL_GPIO_OUTPUT_ACTIVE   (PBL_GPIO_OUTPUT_HIGH | PBL_GPIO_OUTPUT_INIT_LOGICAL)
 Output, active.
 

Functions

static bool pbl_gpio_is_connected (const struct pbl_gpio *gpio)
 Check whether a pin is connected.
 
int pbl_gpio_configure (const struct pbl_gpio *gpio, uint32_t flags)
 Configure a pin.
 
int pbl_gpio_get (const struct pbl_gpio *gpio)
 Read the logical level of a pin.
 
int pbl_gpio_set (const struct pbl_gpio *gpio, bool active)
 Drive the logical level of a pin.
 
int pbl_gpio_get_raw (const struct pbl_gpio *gpio)
 Read the physical level of a pin.
 
int pbl_gpio_set_raw (const struct pbl_gpio *gpio, bool level)
 Drive the physical level of a pin.
 
int pbl_gpio_to_irq (const struct pbl_gpio *gpio, uint32_t type, struct pbl_irq_spec *spec)
 Get the interrupt line of a pin.
 

Variables

const struct pbl_device_class pbl_gpio_port_class
 Class of the GPIO ports.