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


//
// Pin numbers
//
#ifndef __AVR_ARCH_X__

#ifdef __AVR_ATmega2560__

    /*
     * ATmega2560 : these eCxx pin numbers are the same as the pin numbers on the
     *              silkscreen of Arduino and compatible boards
     *
     *   61    60    59    58    57    56    55    54
     * ┌─────┬─────┬─────┮═════╤═════┭─────┬─────┬─────┐
     * │ OE  │ CLK │ C   │ A   │ B1  │ R1  │ B0  │ R0  │
     * ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
     * │ GND │ LE  │ D   │ B   │ GND │ G1  │ GND │ G0  │
     * └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
     *         65    66    67          68          69
     */

    static constexpr eCxx::uint8_t PIN_CLK = 60;
    static constexpr eCxx::uint8_t PIN_LE  = 65;
    static constexpr eCxx::uint8_t PIN_OE  = 61;

    static constexpr eCxx::uint8_t PIN_R0  = 54;
    static constexpr eCxx::uint8_t PIN_R1  = 56;
    static constexpr eCxx::uint8_t PIN_G0  = 69;
    static constexpr eCxx::uint8_t PIN_G1  = 68;
    static constexpr eCxx::uint8_t PIN_B0  = 55;
    static constexpr eCxx::uint8_t PIN_B1  = 57;

    static constexpr eCxx::uint8_t PIN_A   = 58;
    static constexpr eCxx::uint8_t PIN_B   = 67;
    static constexpr eCxx::uint8_t PIN_C   = 59;
    static constexpr eCxx::uint8_t PIN_D   = 66;

#else

    #warning "this firmware is meant for ATmega2560"
    #define DISABLE_TEST_APPLICATION_BUILD

    static constexpr eCxx::uint8_t PIN_CLK = 0;
    static constexpr eCxx::uint8_t PIN_LE  = 0;
    static constexpr eCxx::uint8_t PIN_OE  = 0;

    static constexpr eCxx::uint8_t PIN_R0  = 0;
    static constexpr eCxx::uint8_t PIN_R1  = 0;
    static constexpr eCxx::uint8_t PIN_G0  = 0;
    static constexpr eCxx::uint8_t PIN_G1  = 0;
    static constexpr eCxx::uint8_t PIN_B0  = 0;
    static constexpr eCxx::uint8_t PIN_B1  = 0;

    static constexpr eCxx::uint8_t PIN_A   = 0;
    static constexpr eCxx::uint8_t PIN_B   = 0;
    static constexpr eCxx::uint8_t PIN_C   = 0;
    static constexpr eCxx::uint8_t PIN_D   = 0;

#endif // __AVR_ATmega2560__

#else

    /*
     * ATmega4808
     *
     *   2     3     4     5     6      7     8     9
     * ┌─────┬─────┬─────┮═════╤═════┭─────┬─────┬─────┐
     * │ OE  │ CLK │ C   │ A   │ B1  │ R1  │ B0  │ R0  │
     * ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
     * │ GND │ LE  │ D   │ B   │ GND │ G1  │ GND │ G0  │
     * └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
     *         21    20    19          18          17
     *         A7    A6    A5          A4          A3    (according to the silkscreen of Thinary ATmega4808 board)
     */

    static constexpr eCxx::uint8_t PIN_CLK =  3;
    static constexpr eCxx::uint8_t PIN_LE  = 21;
    static constexpr eCxx::uint8_t PIN_OE  =  2;

    static constexpr eCxx::uint8_t PIN_R0  =  9;
    static constexpr eCxx::uint8_t PIN_R1  =  7;
    static constexpr eCxx::uint8_t PIN_G0  = 17;
    static constexpr eCxx::uint8_t PIN_G1  = 18;
    static constexpr eCxx::uint8_t PIN_B0  =  8;
    static constexpr eCxx::uint8_t PIN_B1  =  6;

    static constexpr eCxx::uint8_t PIN_A   =  5;
    static constexpr eCxx::uint8_t PIN_B   = 19;
    static constexpr eCxx::uint8_t PIN_C   =  4;
    static constexpr eCxx::uint8_t PIN_D   = 20;

#endif
