#ifndef _arena_CONFIG_SUPPLEMENTS_H_
#define _arena_CONFIG_SUPPLEMENTS_H_
//----------------------------------------------------------------------------
///
/// \file   config_supplements.h
///
/// \brief  Set missing defines
///
/// \date   20170309
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//----------------------------------------------------------------------------


//---Includes-----------------------------------------------------------------


#if 0

#define ARENA_GPIO_TABLE
#define ARENA_CONSUME_GPIO \
      eGpioPeripheralF, eGpioPin0

#else


#define ARENA_CONSUME_GPIO \
   arenaGpioTable[index]._eGpioPeripheral, \
   arenaGpioTable[index<(sizeof(arenaGpioTable)/sizeof(arenaGpioTable[0]))? \
         index:exception("Consume Gpio OOR", index)]._eGpioPin ); \
   index+=1; void(

#undef ARENA_CONSUME_GPIO

#define ARENA_CONSUME_GPIO \
   arenaGpioTable[index]._eGpioPeripheral, \
   arenaGpioTable[index<(sizeof(arenaGpioTable)/sizeof(arenaGpioTable[0]))? \
         index++:exception("Consume Gpio OOR", index)]._eGpioPin

#endif // ? 0


#if ( ARENA_USE_LED >= 2) && ( ARENA_HAS_LED < 2) && ! defined ( ARENA_LED_1 )
   #define ARENA_LED_1     ARENA_CONSUME_GPIO
#if ( ARENA_USE_LED >= 3) && ( ARENA_HAS_LED < 3) && ! defined ( ARENA_LED_2 )
   #define ARENA_LED_2     ARENA_CONSUME_GPIO
#if ( ARENA_USE_LED >= 4) && ( ARENA_HAS_LED < 4) && ! defined ( ARENA_LED_3 )
   #define ARENA_LED_3     ARENA_CONSUME_GPIO
#if ( ARENA_USE_LED >= 5) && ( ARENA_HAS_LED < 5) && ! defined ( ARENA_LED_4 )
   #define ARENA_LED_4     ARENA_CONSUME_GPIO
#endif
#endif
#endif
#endif


#if ( ARENA_USE_OUTPUT >= 1)
   #if ! defined ( ARENA_OUTPUT_0 )
      #define ARENA_OUTPUT_0     ARENA_CONSUME_GPIO
   #endif
#if ( ARENA_USE_OUTPUT >= 2)
   #if ! defined ( ARENA_OUTPUT_1 )
      #define ARENA_OUTPUT_1     ARENA_CONSUME_GPIO
   #endif
#if ( ARENA_USE_OUTPUT >= 3)
   #if ! defined ( ARENA_OUTPUT_2 )
      #define ARENA_OUTPUT_2     ARENA_CONSUME_GPIO
   #endif
#if ( ARENA_USE_OUTPUT >= 4)
   #if ! defined ( ARENA_OUTPUT_3 )
      #define ARENA_OUTPUT_3     ARENA_CONSUME_GPIO
   #endif
#if ( ARENA_USE_OUTPUT >= 5)
   #if ! defined ( ARENA_OUTPUT_4 )
      #define ARENA_OUTPUT_4     ARENA_CONSUME_GPIO
   #endif
#endif
#endif
#endif
#endif
#endif

#define ARENA_GPIO_11 eGpioPeripheralB, eGpioPin4
#define COMMA ","
#undef ARENA_GPIO_11
#define ARENA_GPIO_11

#define ARENA_GPIO_12

#define tschusch( a )   a,
#define tschusch2(b,a,c)  b##,

#if ! defined ( ARENA_HAS_GPIO )
   #error "ARENA_HAS_GPIO was not set. Please adjust your arena board config file."
   #define ARENA_GPIOS fooo
#elif ARENA_HAS_GPIO >= 11
   #define ARENA_GPIOS \
               ARENA_GPIO_0, \
               ARENA_GPIO_1, \
               ARENA_GPIO_2, \
               ARENA_GPIO_3, \
               ARENA_GPIO_4, \
               ARENA_GPIO_5, \
               ARENA_GPIO_6, \
               ARENA_GPIO_7, \
               ARENA_GPIO_8, \
               ARENA_GPIO_9, \
               ARENA_GPIO_10
#elif ARENA_HAS_GPIO == 10
   #define ARENA_GPIOS \
               ARENA_GPIO_0, \
               ARENA_GPIO_1, \
               ARENA_GPIO_2, \
               ARENA_GPIO_3, \
               ARENA_GPIO_4, \
               ARENA_GPIO_5, \
               ARENA_GPIO_6, \
               ARENA_GPIO_7, \
               ARENA_GPIO_8, \
               ARENA_GPIO_9
#elif ARENA_HAS_GPIO == 9
   #define ARENA_GPIOS \
               ARENA_GPIO_0, \
               ARENA_GPIO_1, \
               ARENA_GPIO_2, \
               ARENA_GPIO_3, \
               ARENA_GPIO_4, \
               ARENA_GPIO_5, \
               ARENA_GPIO_6, \
               ARENA_GPIO_7, \
               ARENA_GPIO_8
#elif ARENA_HAS_GPIO == 8
   #define ARENA_GPIOS \
               ARENA_GPIO_0, \
               ARENA_GPIO_1, \
               ARENA_GPIO_2, \
               ARENA_GPIO_3, \
               ARENA_GPIO_4, \
               ARENA_GPIO_5, \
               ARENA_GPIO_6, \
               ARENA_GPIO_7
#elif ARENA_HAS_GPIO == 7
   #define ARENA_GPIOS \
               ARENA_GPIO_0, \
               ARENA_GPIO_1, \
               ARENA_GPIO_2, \
               ARENA_GPIO_3, \
               ARENA_GPIO_4, \
               ARENA_GPIO_5, \
               ARENA_GPIO_6
#elif ARENA_HAS_GPIO == 6
   #define ARENA_GPIOS \
               ARENA_GPIO_0, \
               ARENA_GPIO_1, \
               ARENA_GPIO_2, \
               ARENA_GPIO_3, \
               ARENA_GPIO_4, \
               ARENA_GPIO_5
#elif ARENA_HAS_GPIO == 5
   #define ARENA_GPIOS \
               ARENA_GPIO_0, \
               ARENA_GPIO_1, \
               ARENA_GPIO_2, \
               ARENA_GPIO_3, \
               ARENA_GPIO_4
#elif ARENA_HAS_GPIO == 4
   #define ARENA_GPIOS \
               ARENA_GPIO_0, \
               ARENA_GPIO_1, \
               ARENA_GPIO_2, \
               ARENA_GPIO_3
#elif ARENA_HAS_GPIO == 3
   #define ARENA_GPIOS \
               ARENA_GPIO_0, \
               ARENA_GPIO_1, \
               ARENA_GPIO_2
#elif ARENA_HAS_GPIO == 2
   #define ARENA_GPIOS \
               ARENA_GPIO_0, \
               ARENA_GPIO_1
#elif ARENA_HAS_GPIO == 1
   #define ARENA_GPIOS \
               ARENA_GPIO_0
#elif ARENA_HAS_GPIO == 0
   #define ARENA_GPIOS fffooo;
#else
   WTF!
#endif


#ifndef ARENA_LED_0_NAME
#define ARENA_LED_0_NAME      eLedIndex0
#endif

#ifndef ARENA_LED_1_NAME
#define ARENA_LED_1_NAME      eLedIndex1
#endif

#ifndef ARENA_LED_2_NAME
#define ARENA_LED_2_NAME      eLedIndex2
#endif

#ifndef ARENA_LED_3_NAME
#define ARENA_LED_3_NAME      eLedIndex3
#endif

#if defined(ARENA_USE_ADC_LINES) && ( ARENA_USE_ADC_LINES > 0 )
   #if ( ARENA_USE_ADC_LINES > ( ARENA_HAS_ADC_0_CHANNELS + ARENA_HAS_ADC_1_CHANNELS ) )
      #error "Arena: You want to much adc channels"
   #elif ( ARENA_USE_ADC_LINES > ARENA_HAS_ADC_0_CHANNELS )
      #undef ARENA_USE_ADC
      #define ARENA_USE_ADC 2
   #else
      #undef ARENA_USE_ADC
      #define ARENA_USE_ADC 1
   #endif
#endif

#if 0
#if ( ARENA_USE_ADC_LINES >= 1 ) && ( ARENA_HAS_ADC_0_CHANNELS >= 1)
   #define ARENA_ADC_LINE_0 ARENA_ADC_0_CHANNEL_0_GPIO
#endif
#if ( ARENA_USE_ADC_LINES >= 2 ) && ( ARENA_HAS_ADC_0_CHANNELS >= 2)
   #define ARENA_ADC_LINE_0 ARENA_ADC_0_CHANNEL_1_GPIO
#endif
#if ( ARENA_USE_ADC_LINES >= 3 ) && ( ARENA_HAS_ADC_0_CHANNELS >= 3)
   #define ARENA_ADC_LINE_0 ARENA_ADC_0_CHANNEL_2_GPIO
#endif
#if ( ARENA_USE_ADC_LINES >= 4 ) && ( ARENA_HAS_ADC_0_CHANNELS >= 4)
   #define ARENA_ADC_LINE_0 ARENA_ADC_0_CHANNEL_3_GPIO
#endif
#endif

// #define ARENA_HAS_ADC_0_CHANNELS_P1 ARENA_HAS_ADC_0_CHANNELS+1
#define ARENA_ADC_1_LINE_TO_GPIO(channel) ARENA_ADC_1_CHANNEL_ ## channel ## _GPIO

#define ARENA_GPIO_TABLE static struct { \
   EGpioPeripheral _eGpioPeripheral; EGpioPin _eGpioPin; \
   } arenaGpioTable[] __attribute__ ( ( unused) ) = \
   { \
      ARENA_GPIOS \
   };\
   unsigned int index __attribute__ ( ( unused) ) =0;


//---fin----------------------------------------------------------------------
#endif // ? ! _ARENA_CONFIG_SUPPLEMENTS_H_
