Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
Esp8266Gpio.hxx File Reference
#include "os/Gpio.hxx"
#include <gpio.h>
#include <eagle_soc.h>

Go to the source code of this file.

Classes

class  Esp8266StaticGpio< PIN_NUM, MUXREG, FUNC_GPIO >
 Defines a GPIO output pin. More...
 
struct  GpioOutputPin< Base, SAFE_VALUE, INVERT >
 Parametric GPIO output class. More...
 
struct  GpioPullOutPin< Base >
 Output pin that switches between high and low state by turning on pullup and pulldowns. More...
 
struct  GpioOutputSafeLow< Defs >
 Defines a GPIO output pin, initialized to be an output pin with low level. More...
 
struct  GpioOutputSafeLowInvert< Defs >
 Defines a GPIO output pin, initialized to be an output pin with low level. More...
 
struct  GpioOutputSafeHigh< Defs >
 Defines a GPIO output pin, initialized to be an output pin with high level. More...
 
struct  GpioOutputSafeHighInvert< Defs >
 Defines a GPIO output pin, initialized to be an output pin with high level. More...
 
struct  GpioInputPar< Base, PUEN >
 Parametric GPIO input class. More...
 
struct  GpioInputNP< Defs >
 Defines a GPIO input pin. More...
 
struct  GpioInputPU< Defs >
 Defines a GPIO input pin with pull-up. More...
 

Macros

#define GPIO_PIN(NAME, BaseClass, NUM)
 Helper macro for defining GPIO pins on the ESP8266 microcontroller.
 

Functions

void gpio16_output_conf (void)
 Enable GPIO16 pin output.
 
void gpio16_output_set (uint8 value)
 Set GPIO16 output level.
 
void gpio16_input_conf (void)
 Enable GPIO16 pin intput.
 
uint8 gpio16_input_get (void)
 Sample the value of GPIO16 input.
 
constexpr uint32_t gpio_num_to_pinmux_reg (int gpio_pin_num)
 Constexpr function that takes a GPIO number and converts it to the pinmux register address.
 

Variables

constexpr uint32_t pinmux_to_gpio_arr []
 Static map from gpio number to pinmux register address.
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Helper declarations for using GPIO pins on the Esp8266 MCU.

Author
Balazs Racz
Date
16 May 2016

Definition in file Esp8266Gpio.hxx.

Macro Definition Documentation

◆ GPIO_PIN

#define GPIO_PIN (   NAME,
  BaseClass,
  NUM 
)
Value:
typedef BaseClass<Esp8266StaticGpio<NUM, gpio_num_to_pinmux_reg(NUM), \
FUNC_GPIO##NUM>> NAME##_Pin
constexpr uint32_t gpio_num_to_pinmux_reg(int gpio_pin_num)
Constexpr function that takes a GPIO number and converts it to the pinmux register address.
Defines a GPIO output pin.

Helper macro for defining GPIO pins on the ESP8266 microcontroller.

Parameters
NAMEis the basename of the declaration. For NAME==FOO the macro declared FOO_Pin as a structure on which the read-write functions will be available.
BaseClassis the initialization structure, such as LedPin, or GpioOutputSafeHigh or GpioOutputSafeLow.
NUMis the pin number, such as 3 (range: 0..15; GPIO16 is not supported)

Example: GPIO_PIN(FOO, GpioOutputSafeLow, 3); ... FOO_Pin::set(true);

Definition at line 375 of file Esp8266Gpio.hxx.

Function Documentation

◆ gpio16_input_get()

uint8 gpio16_input_get ( void  )

Sample the value of GPIO16 input.

Returns
the level of GPIO16 input.

◆ gpio16_output_set()

void gpio16_output_set ( uint8  value)

Set GPIO16 output level.

Parameters
value: GPIO16 output level.

◆ gpio_num_to_pinmux_reg()

constexpr uint32_t gpio_num_to_pinmux_reg ( int  gpio_pin_num)
constexpr

Constexpr function that takes a GPIO number and converts it to the pinmux register address.

Parameters
gpio_pin_numthe number of the pin (0..15).
Returns
the pinmux register address, e.g. PERIPHS_IO_MUX_U0RXD_U for pin 3.

Definition at line 96 of file Esp8266Gpio.hxx.

Variable Documentation

◆ pinmux_to_gpio_arr

constexpr uint32_t pinmux_to_gpio_arr[]
constexpr
Initial value:
= {
PERIPHS_IO_MUX_GPIO0_U,
PERIPHS_IO_MUX_U0TXD_U,
PERIPHS_IO_MUX_GPIO2_U,
PERIPHS_IO_MUX_U0RXD_U,
PERIPHS_IO_MUX_GPIO4_U,
PERIPHS_IO_MUX_GPIO5_U,
PERIPHS_IO_MUX_SD_CLK_U,
PERIPHS_IO_MUX_SD_DATA0_U,
PERIPHS_IO_MUX_SD_DATA1_U,
PERIPHS_IO_MUX_SD_DATA2_U,
PERIPHS_IO_MUX_SD_DATA3_U,
PERIPHS_IO_MUX_SD_CMD_U,
PERIPHS_IO_MUX_MTDI_U,
PERIPHS_IO_MUX_MTCK_U,
PERIPHS_IO_MUX_MTMS_U,
PERIPHS_IO_MUX_MTDO_U,
}

Static map from gpio number to pinmux register address.

Definition at line 72 of file Esp8266Gpio.hxx.