/**
 **************************************************
 *
 * @file        pins.h
 * @brief       Pin definitions for Inkplate 6FLICK
 *
 *
 * @copyright   GNU General Public License v3.0
 * @authors     Soldered
 ***************************************************/

#ifndef __INKPLATE6FLICK_PINS_H__
#define __INKPLATE6FLICK_PINS_H__
#ifdef ARDUINO_INKPLATE6FLICK
#include "soc/gpio_reg.h"
#include "soc/gpio_struct.h"
#define IO_INT_ADDR 0x20
#define IO_EXT_ADDR 0x21

// Pin on the internal io expander which controls MOSFET for turning on and off the SD card
#define SD_PMOS_PIN IO_PIN_B2 // 10

// Touchscreen defines
#define TOUCHSCREEN_EN          IO_PIN_B4
#define TOUCHSCREEN_RST         IO_PIN_B2
#define TOUCHSCREEN_INT         36
#define TOUCHSCREEN_IO_EXPANDER IO_INT_ADDR
#define TOUCHSCREEN_IO_REGS     ioRegsInt

// Frontlight
#define FRONTLIGHT_EN 11

#define WAKEUP 3
#define WAKEUP_SET                                                                                                     \
    {                                                                                                                  \
        expander1.digitalWrite(WAKEUP, HIGH);                                                                          \
    }
#define WAKEUP_CLEAR                                                                                                   \
    {                                                                                                                  \
        expander1.digitalWrite(WAKEUP, LOW);                                                                           \
    }
#define PWRUP 4
#define PWRUP_SET                                                                                                      \
    {                                                                                                                  \
        expander1.digitalWrite(PWRUP, HIGH);                                                                           \
    }
#define PWRUP_CLEAR                                                                                                    \
    {                                                                                                                  \
        expander1.digitalWrite(PWRUP, LOW);                                                                            \
    }
#define VCOM 5
#define VCOM_SET                                                                                                       \
    {                                                                                                                  \
        expander1.digitalWrite(VCOM, HIGH);                                                                            \
    }
#define VCOM_CLEAR                                                                                                     \
    {                                                                                                                  \
        expander1.digitalWrite(VCOM, LOW);                                                                             \
    }
#define OE 0
#define OE_SET                                                                                                         \
    {                                                                                                                  \
        expander1.digitalWrite(OE, HIGH);                                                                              \
    }
#define OE_CLEAR                                                                                                       \
    {                                                                                                                  \
        expander1.digitalWrite(OE, LOW);                                                                               \
    }
#define GMOD 1
#define GMOD_SET                                                                                                       \
    {                                                                                                                  \
        expander1.digitalWrite(GMOD, HIGH);                                                                            \
    }
#define GMOD_CLEAR                                                                                                     \
    {                                                                                                                  \
        expander1.digitalWrite(GMOD, LOW);                                                                             \
    }
#define SPV 2
#define SPV_SET                                                                                                        \
    {                                                                                                                  \
        expander1.digitalWrite(SPV, HIGH);                                                                             \
    }
#define SPV_CLEAR                                                                                                      \
    {                                                                                                                  \
        expander1.digitalWrite(SPV, LOW);                                                                              \
    }
#define CL 0x01
#define CL_SET                                                                                                         \
    {                                                                                                                  \
        GPIO.out_w1ts = CL;                                                                                            \
    }
#define CL_CLEAR                                                                                                       \
    {                                                                                                                  \
        GPIO.out_w1tc = CL;                                                                                            \
    }
#define CKV 0x01
#define CKV_SET                                                                                                        \
    {                                                                                                                  \
        GPIO.out1_w1ts.val = CKV;                                                                                      \
    }
#define CKV_CLEAR                                                                                                      \
    {                                                                                                                  \
        GPIO.out1_w1tc.val = CKV;                                                                                      \
    }
#define SPH 0x02
#define SPH_SET                                                                                                        \
    {                                                                                                                  \
        GPIO.out1_w1ts.val = SPH;                                                                                      \
    }
#define SPH_CLEAR                                                                                                      \
    {                                                                                                                  \
        GPIO.out1_w1tc.val = SPH;                                                                                      \
    }
#define LE 0x04
#define LE_SET                                                                                                         \
    {                                                                                                                  \
        GPIO.out_w1ts = LE;                                                                                            \
    }
#define LE_CLEAR                                                                                                       \
    {                                                                                                                  \
        GPIO.out_w1tc = LE;                                                                                            \
    }

#endif
#endif