std1.0.0-beta-7 SafeC docs

Module hal::gpio

#include <std/hal/gpio.h> source

GPIO HAL Memory-mapped GPIO pin abstraction. Freestanding-safe.

GpioPin<C> is generic over the chip's GPIO block, a compile-time type whose methods do the register work:

GpioGeneric   reference layout: DIR +0x00, OUT +0x04, IN +0x08,
              PULL_EN +0x0C, PULL_SEL +0x10 (1 = up), one bit per pin
Stm32F4Gpio   STM32F2/F4/F7/L4/G0/H7-style port: MODER, PUPDR, IDR,
              ODR, BSRR (atomic set/reset)

struct GpioPin<Stm32F4Gpio> led = std::GpioPin::new(gpioa, 5, GPIO_OUTPUT);
led.write(1);

Structs

GpioGeneric
Stm32F4Gpio
GpioPin

Traits

GpioChipWhat a GPIO block type provides (GpioGeneric, Stm32F4Gpio below, or your own): GpioPin<C> requires it, so a type missing one is rejected where the pin type is named.

Macros

GPIO_INPUTPin direction
GPIO_OUTPUT
GPIO_PULL_NONEPin pull configuration
GPIO_PULL_UP
GPIO_PULL_DOWN