/*
 * Copyright (C) 2020-2021 Aloysius Indrayanto
 *
 * This file is part of the eCxx library, see LICENSE file for the license details.
 */


#ifndef INCLUDE_ECXX_PLATFORM_NODEMCU_PIN_NAME_STD_H
#error "this file cannot be included directly"
#endif
#undef INCLUDE_ECXX_PLATFORM_NODEMCU_PIN_NAME_STD_H


#ifndef ECXX_PLATFORM_NODEMCU_PIN_NAME_STD_NODEMCU_H
#define ECXX_PLATFORM_NODEMCU_PIN_NAME_STD_NODEMCU_H


//
// NodeMCU (ESP-12E)
//

// Built-in LED pins
static constexpr uint8_t BuiltinLED1 =  2; // ESP-12  (active low) ; D4 on silkscreen
static constexpr uint8_t BuiltinLED2 = 16; // NodeMCU (active low) ; D0 on silkscreen

static constexpr uint8_t BuiltinLED  = BuiltinLED1;

// Digital pins
// NOTE : NodeMCU PCB's silkscreen uses a different numbering scheme than ESP-12E's GPIO pin numbering
static constexpr uint8_t D0   = 16;
static constexpr uint8_t D1   =  5;
static constexpr uint8_t D2   =  4;
static constexpr uint8_t D3   =  0;
static constexpr uint8_t D4   =  2;
static constexpr uint8_t D5   = 14;
static constexpr uint8_t D6   = 12;
static constexpr uint8_t D7   = 13;
static constexpr uint8_t D8   = 15;
static constexpr uint8_t D9   =  3;
static constexpr uint8_t D10  =  1;

// ADC pin
static constexpr uint8_t A0   = 17;

static constexpr uint8_t AMin = A0;
static constexpr uint8_t AMax = A0;

// PWM pins
static constexpr uint8_t PWM0  =  0; // D3  on silkscreen
static constexpr uint8_t PWM1  =  1; // D10 on silkscreen
static constexpr uint8_t PWM2  =  2; // D4  on silkscreen
static constexpr uint8_t PWM3  =  3; // D9  on silkscreen
static constexpr uint8_t PWM4  =  4; // D2  on silkscreen
static constexpr uint8_t PWM5  =  5; // D1  on silkscreen
static constexpr uint8_t PWM6  = 12; // D6  on silkscreen
static constexpr uint8_t PWM7  = 13; // D7  on silkscreen
static constexpr uint8_t PWM8  = 14; // D5  on silkscreen
static constexpr uint8_t PWM9  = 15; // D8  on silkscreen
static constexpr uint8_t PWM10 = 16; // D0  on silkscreen

// Interrupt pins
static constexpr uint8_t EINT0 =  0; // D3  on silkscreen
static constexpr uint8_t EINT1 =  1; // D10 on silkscreen
static constexpr uint8_t EINT2 =  2; // D4  on silkscreen
static constexpr uint8_t EINT3 =  3; // D9  on silkscreen
static constexpr uint8_t EINT4 =  4; // D2  on silkscreen
static constexpr uint8_t EINT5 =  5; // D1  on silkscreen
static constexpr uint8_t EINT6 = 12; // D6  on silkscreen
static constexpr uint8_t EINT7 = 13; // D7  on silkscreen
static constexpr uint8_t EINT8 = 14; // D5  on silkscreen
static constexpr uint8_t EINT9 = 15; // D8  on silkscreen

// Communication pins
static constexpr uint8_t UART0_RxDef =  3; // D9  on silkscreen
static constexpr uint8_t UART0_TxDef =  1; // D10 on silkscreen

static constexpr uint8_t UART0_RxAlt = 13; // D7  on silkscreen
static constexpr uint8_t UART0_TxAlt = 15; // D8  on silkscreen

static constexpr uint8_t UART1_Tx    =  2; // D4  on silkscreen

static constexpr uint8_t UART_Rx     = UART0_RxDef;
static constexpr uint8_t UART_Tx     = UART0_TxDef;

static constexpr uint8_t SPI_MISO    = 12; // D6  on silkscreen
static constexpr uint8_t SPI_MOSI    = 13; // D7  on silkscreen
static constexpr uint8_t SPI_SCK     = 14; // D5  on silkscreen
static constexpr uint8_t SPI_SS      = 15; // D8  on silkscreen

static constexpr uint8_t TWI_SDA     =  4; // D2  on silkscreen
static constexpr uint8_t TWI_SCL     =  5; // D1  on silkscreen

static constexpr uint8_t I2S_DATA    =  3; // D9  on silkscreen
static constexpr uint8_t I2S_BCK     = 15; // D8  on silkscreen
static constexpr uint8_t I2S_WS      =  2; // D4  on silkscreen


#endif
