GPIO functions

Provides general purpose input and output (GPIO) functions. More...

Functions

DigitalHookssetDigitalHooks (DigitalHooks *hooks)
 Replace (or remove) existing hooks. More...
 
void pinMode (uint16_t pin, uint8_t mode)
 Set the mode of a GPIO pin. More...
 
void digitalWrite (uint16_t pin, uint8_t val)
 Set a digital output. More...
 
uint8_t digitalRead (uint16_t pin)
 Get the value of a digital input. More...
 
void pullup (uint16_t pin)
 Enable pull-up on digital input. More...
 
void noPullup (uint16_t pin)
 Disable pull-up on digital input. More...
 
bool isInputPin (uint16_t pin)
 Check if GPIO is an input. More...
 
unsigned long pulseIn (uint16_t pin, uint8_t state, unsigned long timeout=1000000L)
 Measures duration of pulse on GPIO. More...
 
uint16_t analogRead (uint16_t pin)
 

Variables

const EspDigitalPin EspDigitalPins []
 ESP GPIO pin configuration. More...
 

Detailed Description

Provides general purpose input and output (GPIO) functions.

See also
pwm

Function Documentation

◆ analogRead()

uint16_t analogRead ( uint16_t  pin)
inline

◆ digitalRead()

uint8_t digitalRead ( uint16_t  pin)

Get the value of a digital input.

Parameters
pinGPIO pin to read
Return values
uint8_tValue of GPIO

◆ digitalWrite()

void digitalWrite ( uint16_t  pin,
uint8_t  val 
)

Set a digital output.

Parameters
pinGPIO pin to set
valValue to set [0 | 1]

◆ isInputPin()

bool isInputPin ( uint16_t  pin)

Check if GPIO is an input.

Parameters
pinGPIO to check
Return values
boolTrue if GPIO is an input

◆ noPullup()

void noPullup ( uint16_t  pin)

Disable pull-up on digital input.

Parameters
pinGPIO to disable pull-up resistor

◆ pinMode()

void pinMode ( uint16_t  pin,
uint8_t  mode 
)

Set the mode of a GPIO pin.

Parameters
pinGPIO pin to configure
modeMode of pin [INPUT | INPUT_PULLUP | OUTPUT]
Todo:
ESP8266 supports pull-down on GPIO 0-15

◆ pullup()

void pullup ( uint16_t  pin)

Enable pull-up on digital input.

Parameters
pinGPIO to enable pull-up resistor

◆ pulseIn()

unsigned long pulseIn ( uint16_t  pin,
uint8_t  state,
unsigned long  timeout = 1000000L 
)

Measures duration of pulse on GPIO.

Parameters
pinGPIO to measure
stateState of pulse to measure [HIGH | LOW]
timeoutMaximum duration of pulse
Return values
unsigned longPulse duration in microseconds
Note
Works on pulses from 2-3 microseconds to 3 minutes in length.
Must be called at least a few dozen microseconds before the start of the pulse.

◆ setDigitalHooks()

DigitalHooks* setDigitalHooks ( DigitalHooks hooks)

Replace (or remove) existing hooks.

Parameters
hooksThe new hooks, or nullptr to remove
Return values
DigitalHooks*The previous hooks

Variable Documentation

◆ EspDigitalPins

const EspDigitalPin EspDigitalPins[]

ESP GPIO pin configuration.