@web-font-path: "roboto-debian.css";
Loading...
Searching...
No Matches
gpio.h File Reference
#include "pico.h"
#include "hardware/structs/sio.h"
#include "hardware/structs/pads_bank0.h"
#include "hardware/structs/io_bank0.h"
#include "hardware/irq.h"
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 PARAM_ASSERTIONS_ENABLED_HARDWARE_GPIO   0
#define GPIO_IRQ_CALLBACK_ORDER_PRIORITY   PICO_SHARED_IRQ_HANDLER_LOWEST_ORDER_PRIORITY
#define GPIO_RAW_IRQ_HANDLER_DEFAULT_ORDER_PRIORITY   PICO_SHARED_IRQ_HANDLER_DEFAULT_ORDER_PRIORITY
#define PICO_DEBUG_PIN_BASE   19u
#define PICO_DEBUG_PIN_COUNT   3u
#define CU_REGISTER_DEBUG_PINS(...)
#define CU_SELECT_DEBUG_PINS(x)
#define DEBUG_PINS_ENABLED(p)
#define DEBUG_PINS_SET(p, v)
#define DEBUG_PINS_CLR(p, v)
#define DEBUG_PINS_XOR(p, v)

Typedefs

typedef void(* gpio_irq_callback_t) (uint gpio, uint32_t event_mask)

Enumerations

enum  gpio_dir { GPIO_OUT = 1u , GPIO_IN = 0u }
enum  gpio_irq_level { GPIO_IRQ_LEVEL_LOW = 0x1u , GPIO_IRQ_LEVEL_HIGH = 0x2u , GPIO_IRQ_EDGE_FALL = 0x4u , GPIO_IRQ_EDGE_RISE = 0x8u }
 GPIO Interrupt level definitions (GPIO events). More...
enum  gpio_override { GPIO_OVERRIDE_NORMAL = 0 , GPIO_OVERRIDE_INVERT = 1 , GPIO_OVERRIDE_LOW = 2 , GPIO_OVERRIDE_HIGH = 3 }
 GPIO override modes. More...
enum  gpio_slew_rate { GPIO_SLEW_RATE_SLOW = 0 , GPIO_SLEW_RATE_FAST = 1 }
 Slew rate limiting levels for GPIO outputs. More...
enum  gpio_drive_strength { GPIO_DRIVE_STRENGTH_2MA = 0 , GPIO_DRIVE_STRENGTH_4MA = 1 , GPIO_DRIVE_STRENGTH_8MA = 2 , GPIO_DRIVE_STRENGTH_12MA = 3 }
 Drive strength levels for GPIO outputs. More...

Functions

static void check_gpio_param (__unused uint gpio)
void gpio_set_function (uint gpio, gpio_function_t fn)
 Select GPIO function.
void gpio_set_function_masked (uint32_t gpio_mask, gpio_function_t fn)
 Select the function for multiple GPIOs.
void gpio_set_function_masked64 (uint64_t gpio_mask, gpio_function_t fn)
 Select the function for multiple GPIOs.
gpio_function_t gpio_get_function (uint gpio)
 Determine current GPIO function.
void gpio_set_pulls (uint gpio, bool up, bool down)
 Select up and down pulls on specific GPIO.
static void gpio_pull_up (uint gpio)
 Set specified GPIO to be pulled up.
static bool gpio_is_pulled_up (uint gpio)
 Determine if the specified GPIO is pulled up.
static void gpio_pull_down (uint gpio)
 Set specified GPIO to be pulled down.
static bool gpio_is_pulled_down (uint gpio)
 Determine if the specified GPIO is pulled down.
static void gpio_disable_pulls (uint gpio)
 Disable pulls on specified GPIO.
void gpio_set_irqover (uint gpio, uint value)
 Set GPIO IRQ override.
void gpio_set_outover (uint gpio, uint value)
 Set GPIO output override.
void gpio_set_inover (uint gpio, uint value)
 Select GPIO input override.
void gpio_set_oeover (uint gpio, uint value)
 Select GPIO output enable override.
void gpio_set_input_enabled (uint gpio, bool enabled)
 Enable GPIO input.
void gpio_set_input_hysteresis_enabled (uint gpio, bool enabled)
 Enable/disable GPIO input hysteresis (Schmitt trigger).
bool gpio_is_input_hysteresis_enabled (uint gpio)
 Determine whether input hysteresis is enabled on a specified GPIO.
void gpio_set_slew_rate (uint gpio, enum gpio_slew_rate slew)
 Set slew rate for a specified GPIO.
enum gpio_slew_rate gpio_get_slew_rate (uint gpio)
 Determine current slew rate for a specified GPIO.
void gpio_set_drive_strength (uint gpio, enum gpio_drive_strength drive)
 Set drive strength for a specified GPIO.
enum gpio_drive_strength gpio_get_drive_strength (uint gpio)
 Determine current drive strength for a specified GPIO.
void gpio_set_irq_enabled (uint gpio, uint32_t event_mask, bool enabled)
 Enable or disable specific interrupt events for specified GPIO.
void gpio_set_irq_callback (gpio_irq_callback_t callback)
 Set the generic callback used for GPIO IRQ events for the current core.
void gpio_set_irq_enabled_with_callback (uint gpio, uint32_t event_mask, bool enabled, gpio_irq_callback_t callback)
 Convenience function which performs multiple GPIO IRQ related initializations.
void gpio_set_dormant_irq_enabled (uint gpio, uint32_t event_mask, bool enabled)
 Enable dormant wake up interrupt for specified GPIO and events.
static uint32_t gpio_get_irq_event_mask (uint gpio)
 Return the current interrupt status (pending events) for the given GPIO.
static void gpio_acknowledge_irq (uint gpio, uint32_t event_mask)
 Acknowledge a GPIO interrupt for the specified events on the calling core.
void gpio_add_raw_irq_handler_with_order_priority_masked (uint32_t gpio_mask, irq_handler_t handler, uint8_t order_priority)
 Adds a raw GPIO IRQ handler for the specified GPIOs on the current core.
void gpio_add_raw_irq_handler_with_order_priority_masked64 (uint64_t gpio_mask, irq_handler_t handler, uint8_t order_priority)
 Adds a raw GPIO IRQ handler for the specified GPIOs on the current core.
static void gpio_add_raw_irq_handler_with_order_priority (uint gpio, irq_handler_t handler, uint8_t order_priority)
 Adds a raw GPIO IRQ handler for a specific GPIO on the current core.
void gpio_add_raw_irq_handler_masked (uint32_t gpio_mask, irq_handler_t handler)
 Adds a raw GPIO IRQ handler for the specified GPIOs on the current core.
void gpio_add_raw_irq_handler_masked64 (uint64_t gpio_mask, irq_handler_t handler)
 Adds a raw GPIO IRQ handler for the specified GPIOs on the current core.
static void gpio_add_raw_irq_handler (uint gpio, irq_handler_t handler)
 Adds a raw GPIO IRQ handler for a specific GPIO on the current core.
void gpio_remove_raw_irq_handler_masked (uint32_t gpio_mask, irq_handler_t handler)
 Removes a raw GPIO IRQ handler for the specified GPIOs on the current core.
void gpio_remove_raw_irq_handler_masked64 (uint64_t gpio_mask, irq_handler_t handler)
 Removes a raw GPIO IRQ handler for the specified GPIOs on the current core.
static void gpio_remove_raw_irq_handler (uint gpio, irq_handler_t handler)
 Removes a raw GPIO IRQ handler for the specified GPIO on the current core.
void gpio_init (uint gpio)
 Initialise a GPIO for (enabled I/O and set func to GPIO_FUNC_SIO).
void gpio_deinit (uint gpio)
 Resets a GPIO back to the NULL function, i.e. disables it.
void gpio_init_mask (uint gpio_mask)
 Initialise multiple GPIOs (enabled I/O and set func to GPIO_FUNC_SIO).
static bool gpio_get (uint gpio)
 Get state of a single specified GPIO.
static uint32_t gpio_get_all (void)
 Get raw value of all GPIOs.
static uint64_t gpio_get_all64 (void)
 Get raw value of all GPIOs.
static void gpio_set_mask (uint32_t mask)
 Drive high every GPIO appearing in mask.
static void gpio_set_mask64 (uint64_t mask)
 Drive high every GPIO appearing in mask.
static void gpio_set_mask_n (uint n, uint32_t mask)
 Drive high every GPIO appearing in mask.
static void gpio_clr_mask (uint32_t mask)
 Drive low every GPIO appearing in mask.
static void gpio_clr_mask64 (uint64_t mask)
 Drive low every GPIO appearing in mask.
static void gpio_clr_mask_n (uint n, uint32_t mask)
 Drive low every GPIO appearing in mask.
static void gpio_xor_mask (uint32_t mask)
 Toggle every GPIO appearing in mask.
static void gpio_xor_mask64 (uint64_t mask)
 Toggle every GPIO appearing in mask.
static void gpio_xor_mask_n (uint n, uint32_t mask)
 Toggle every GPIO appearing in mask.
static void gpio_put_masked (uint32_t mask, uint32_t value)
 Drive GPIOs high/low depending on parameters.
static void gpio_put_masked64 (uint64_t mask, uint64_t value)
 Drive GPIOs high/low depending on parameters.
static void gpio_put_masked_n (uint n, uint32_t mask, uint32_t value)
 Drive GPIOs high/low depending on parameters.
static void gpio_put_all (uint32_t value)
 Drive all pins simultaneously.
static void gpio_put_all64 (uint64_t value)
 Drive all pins simultaneously.
static void gpio_put (uint gpio, bool value)
 Drive a single GPIO high/low.
static bool gpio_get_out_level (uint gpio)
 Determine whether a GPIO is currently driven high or low.
static void gpio_set_dir_out_masked (uint32_t mask)
 Set a number of GPIOs to output.
static void gpio_set_dir_out_masked64 (uint64_t mask)
 Set a number of GPIOs to output.
static void gpio_set_dir_in_masked (uint32_t mask)
 Set a number of GPIOs to input.
static void gpio_set_dir_in_masked64 (uint64_t mask)
 Set a number of GPIOs to input.
static void gpio_set_dir_masked (uint32_t mask, uint32_t value)
 Set multiple GPIO directions.
static void gpio_set_dir_masked64 (uint64_t mask, uint64_t value)
 Set multiple GPIO directions.
static void gpio_set_dir_all_bits (uint32_t values)
 Set direction of all pins simultaneously.
static void gpio_set_dir_all_bits64 (uint64_t values)
 Set direction of all pins simultaneously.
static void gpio_set_dir (uint gpio, bool out)
 Set a single GPIO direction.
static bool gpio_is_dir_out (uint gpio)
 Check if a specific GPIO direction is OUT.
static uint gpio_get_dir (uint gpio)
 Get a specific GPIO direction.
void gpio_debug_pins_init (void)

Macro Definition Documentation

◆ CU_REGISTER_DEBUG_PINS

#define CU_REGISTER_DEBUG_PINS ( ...)
Value:
enum __unused DEBUG_PIN_TYPE { _none = 0, __VA_ARGS__ }; static enum DEBUG_PIN_TYPE __selected_debug_pins;

◆ CU_SELECT_DEBUG_PINS

#define CU_SELECT_DEBUG_PINS ( x)
Value:
static enum DEBUG_PIN_TYPE __selected_debug_pins = (x);

◆ DEBUG_PINS_CLR

#define DEBUG_PINS_CLR ( p,
v )
Value:
if (DEBUG_PINS_ENABLED(p)) gpio_clr_mask((unsigned)(v)<<PICO_DEBUG_PIN_BASE)
static void gpio_clr_mask(uint32_t mask)
Drive low every GPIO appearing in mask.
Definition gpio.h:965

◆ DEBUG_PINS_ENABLED

#define DEBUG_PINS_ENABLED ( p)
Value:
(__selected_debug_pins == (p))

◆ DEBUG_PINS_SET

#define DEBUG_PINS_SET ( p,
v )
Value:
if (DEBUG_PINS_ENABLED(p)) gpio_set_mask((unsigned)(v)<<PICO_DEBUG_PIN_BASE)
static void gpio_set_mask(uint32_t mask)
Drive high every GPIO appearing in mask.
Definition gpio.h:918

◆ DEBUG_PINS_XOR

#define DEBUG_PINS_XOR ( p,
v )
Value:
if (DEBUG_PINS_ENABLED(p)) gpio_xor_mask((unsigned)(v)<<PICO_DEBUG_PIN_BASE)
static void gpio_xor_mask(uint32_t mask)
Toggle every GPIO appearing in mask.
Definition gpio.h:1013

Enumeration Type Documentation

◆ gpio_dir

enum gpio_dir
Enumerator
GPIO_OUT 

set GPIO to output

GPIO_IN 

set GPIO to input