ESPectro32 Library
Library for using ESPectro32 board
 All Classes Functions Variables Enumerations Enumerator Pages
Static Public Member Functions | List of all members
ESP32CPP::GPIO Class Reference

Interface to GPIO functions. More...

#include <GPIO.h>

Static Public Member Functions

static void addISRHandler (gpio_num_t pin, gpio_isr_t handler, void *pArgs)
 Add an ISR handler to the pin. More...
 
static void high (gpio_num_t pin)
 Set the pin high. More...
 
static void interruptDisable (gpio_num_t pin)
 Disable interrupts on the named pin. More...
 
static void interruptEnable (gpio_num_t pin)
 Enable interrupts on the named pin. More...
 
static bool inRange (gpio_num_t pin)
 Determine if the pin is a valid pin for an ESP32 (i.e. is it in range). More...
 
static void low (gpio_num_t pin)
 Set the pin low. More...
 
static bool read (gpio_num_t pin)
 Read a value from the given pin. More...
 
static void setInput (gpio_num_t pin)
 Set the pin as input. More...
 
static void setInterruptType (gpio_num_t pin, gpio_int_type_t intrType)
 Set the interrupt type. The type of interrupt can be one of: More...
 
static void setOutput (gpio_num_t pin)
 Set the pin as output. More...
 
static void write (gpio_num_t pin, bool value)
 Write a value to the given pin. More...
 
static void writeByte (gpio_num_t pins[], uint8_t value, int bits)
 Write up to 8 bits of data to a set of pins. More...
 

Detailed Description

Interface to GPIO functions.

The GPIO functions encapsulate the GPIO access. The GPIOs available to us are 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,21,23,25,26,27,32,33,34,35,36,37,38,39.

The GPIOs of 34,35,36,37,38 and 39 are input only.

Note that we must not use int values for the pin numbers but instead use the gpio_num_t. There are constants defined for these of the form GPIO_NUM_xx.

To toggle a pin we might code:

Member Function Documentation

void ESP32CPP::GPIO::addISRHandler ( gpio_num_t  pin,
gpio_isr_t  handler,
void *  pArgs 
)
static

Add an ISR handler to the pin.

Parameters
[in]pinThe pin to have the ISR associated with it.
[in]handlerThe function to be invoked when the interrupt is detected.
[in]pArgsOptional arguments to pass to the handler.
void ESP32CPP::GPIO::high ( gpio_num_t  pin)
static

Set the pin high.

Ensure that the pin is set to be output prior to calling this method.

Parameters
[in]pinThe pin to be set high.
Returns
N/A.
bool ESP32CPP::GPIO::inRange ( gpio_num_t  pin)
static

Determine if the pin is a valid pin for an ESP32 (i.e. is it in range).

Parameters
[in]pinThe pin number to validate.
Returns
The value of true if the pin is valid and false otherwise.
void ESP32CPP::GPIO::interruptDisable ( gpio_num_t  pin)
static

Disable interrupts on the named pin.

Parameters
[in]pinThe pin to disable interrupts upon.
Returns
N/A.
void ESP32CPP::GPIO::interruptEnable ( gpio_num_t  pin)
static

Enable interrupts on the named pin.

Parameters
[in]pinThe pin to enable interrupts upon.
Returns
N/A.
void ESP32CPP::GPIO::low ( gpio_num_t  pin)
static

Set the pin low.

Ensure that the pin is set to be output prior to calling this method.

Parameters
[in]pinThe pin to be set low.
Returns
N/A.
bool ESP32CPP::GPIO::read ( gpio_num_t  pin)
static

Read a value from the given pin.

Ensure the pin is set as input before calling this method.

Parameters
[in]pinThe pin to read from.
Returns
True if the pin is high, false if the pin is low.
void ESP32CPP::GPIO::setInput ( gpio_num_t  pin)
static

Set the pin as input.

Set the direction of the pin as input.

Parameters
[in]pinThe pin to set as input.
Returns
N/A.
void ESP32CPP::GPIO::setInterruptType ( gpio_num_t  pin,
gpio_int_type_t  intrType 
)
static

Set the interrupt type. The type of interrupt can be one of:

  • GPIO_INTR_ANYEDGE
  • GPIO_INTR_DISABLE
  • GPIO_INTR_NEGEDGE
  • GPIO_INTR_POSEDGE
  • GPIO_INTR_LOW_LEVEL
  • GPIO_INTR_HIGH_LEVEL
Parameters
[in]pinThe pin to set the interrupt upon.
[in]intrTypeThe type of interrupt.
Returns
N/A.
void ESP32CPP::GPIO::setOutput ( gpio_num_t  pin)
static

Set the pin as output.

Set the direction of the pin as output. Note that pins 34 through 39 are input only and can not be set as output.

Parameters
[in]pinThe pin to set as output.
Returns
N/A.
void ESP32CPP::GPIO::write ( gpio_num_t  pin,
bool  value 
)
static

Write a value to the given pin.

Ensure that the pin is set as output before calling this method.

Parameters
[in]pinThe gpio pin to change.
[out]valueThe value to be written to the pin.
Returns
N/A.
void ESP32CPP::GPIO::writeByte ( gpio_num_t  pins[],
uint8_t  value,
int  bits 
)
static

Write up to 8 bits of data to a set of pins.

Parameters
[in]pinsAn array of pins to set their values.
[in]valueThe data value to write.
[in]bitsThe number of bits to write.

The documentation for this class was generated from the following files: