#ifndef _ARENA_BOARD_CONFIG_F303_H_
#define _ARENA_BOARD_CONFIG_F303_H_
//-----------------------------------------------------------------------------
///
/// \brief  Libbiwak board description
///
///         Basic STM32F303 Nucleo board:
///            4 ADC Lines
///            1 CAN
///            1 Uart (Virtual Debug)
///            1 SPI
///            1 I2C
///            1 LED (native)
///
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//-----------------------------------------------------------------------------


#define ARENA_MIN(A, B) ( A < B ? A : B )

#define ARENA_HAS_ADC               2

#define ARENA_ADC_0                 eAdc1
#define ARENA_ADC_0_NAME            Adc1
#define ARENA_HAS_ADC_0_CHANNELS    3
#define ARENA_ADC_0_CHANNEL_0_GPIO  eGpioPeripheralA, eGpioPin0,  // CN4 A0 ADC1_IN1
#define ARENA_ADC_0_CHANNEL_1_GPIO  eGpioPeripheralA, eGpioPin1,  // CN4 A1 ADC1_IN2
#define ARENA_ADC_0_CHANNEL_2_GPIO  eGpioPeripheralA, eGpioPin3,  // CN4 A2 ADC1_IN4

#define ARENA_ADC_0_CHANNEL_0       (1+0) /* eAdcChannel0==1 */
#define ARENA_ADC_0_CHANNEL_1       (1+1) /* eAdcChannel0==1 */
#define ARENA_ADC_0_CHANNEL_2       (1+3) /* eAdcChannel0==1 */

#define ARENA_ADC_1                 eAdc2
#define ARENA_ADC_1_NAME            Adc2
#define ARENA_HAS_ADC_1_CHANNELS    2
#define ARENA_ADC_1_CHANNEL_0_GPIO  eGpioPeripheralA, eGpioPin4, // CN4 A3 ADC2_IN1
#define ARENA_ADC_1_CHANNEL_0       (1+0) /* eAdcChannel0==1 */
#define ARENA_ADC_1_CHANNEL_1       (1+3) /* eAdcChannel0==1 */

#define ARENA_ADC_LINE_0            ARENA_ADC_0_CHANNEL_0_GPIO
#define ARENA_ADC_LINE_0_PINS       A0
#define ARENA_ADC_LINE_1            ARENA_ADC_0_CHANNEL_1_GPIO
#define ARENA_ADC_LINE_1_PINS       A1
#define ARENA_ADC_LINE_2            ARENA_ADC_0_CHANNEL_2_GPIO
#define ARENA_ADC_LINE_2_PINS       A2
#define ARENA_ADC_LINE_3            ARENA_ADC_1_CHANNEL_0_GPIO
#define ARENA_ADC_LINE_3_PINS       A3

#define ARENA_HAS_LED            1
#define ARENA_LED_0              eGpioPeripheralB, eGpioPin3   // Pin D13, LD3
#define ARENA_LED_NATIVE         1

#define ARENA_HAS_GPIO           9
//#define ARENA_HAS_GPIO           7
#define ARENA_GPIO_0             eGpioPeripheralA, eGpioPin9      // CN3 D1
#define ARENA_GPIO_0_EXTI_IRQ    EXTI9_5_IRQHandler
#define ARENA_GPIO_0_PINS        D1
#define ARENA_GPIO_1             eGpioPeripheralA, eGpioPin10     // CN3 D0
#define ARENA_GPIO_1_EXTI_IRQ    EXTI10_IRQHandler
#define ARENA_GPIO_1_PINS        D0
#define ARENA_GPIO_2             eGpioPeripheralB, eGpioPin0      // CN3 D3
#define ARENA_GPIO_2_EXTI_IRQ    EXTI0_IRQHandler
#define ARENA_GPIO_2_PINS        D3
#define ARENA_GPIO_3             eGpioPeripheralB, eGpioPin1      // CN3 D6
#define ARENA_GPIO_3_EXTI_IRQ    EXTI1_IRQHandler
#define ARENA_GPIO_3_PINS        D6
#define ARENA_GPIO_4             eGpioPeripheralF, eGpioPin0      // CN3 D7
#define ARENA_GPIO_4_EXTI_IRQ    EXTI0_IRQHandler
#define ARENA_GPIO_4_PINS        D7
#define ARENA_GPIO_5             eGpioPeripheralF, eGpioPin1      // CN3 D8
#define ARENA_GPIO_5_EXTI_IRQ    EXTI1_IRQHandler
#define ARENA_GPIO_5_PINS        D8
#define ARENA_GPIO_6             eGpioPeripheralA, eGpioPin8      // CN3 D9
#define ARENA_GPIO_6_EXTI_IRQ    EXTI9_5_IRQHandler
#define ARENA_GPIO_6_PINS        D9
#define ARENA_GPIO_7             eGpioPeripheralB, eGpioPin5      // CN3 D11
#define ARENA_GPIO_7_PINS        D11
#define ARENA_GPIO_8             eGpioPeripheralB, eGpioPin4      // CN3 D12
#define ARENA_GPIO_8_PINS        D12
#define ARENA_GPIO_9             eGpioPeripheralB, eGpioPin0      // CN3 D4
#define ARENA_GPIO_9_EXTI_IRQ    EXTI0_IRQHandler
#define ARENA_GPIO_9_PINS        D3
#define ARENA_GPIO_10            eGpioPeripheralB, eGpioPin0      // CN3 D4
#define ARENA_GPIO_10_EXTI_IRQ   EXTI0_IRQHandler
#define ARENA_GPIO_10_PINS       D3

// D4 is connected to A4 via solder bridge
// D5 is connected to A5 via solder bridge


#define ARENA_BUTON_0            eGpioPeripheralF, eGpioPin0
#define ARENA_BUTTON_0_EXTI_IRQ  EXTI0_IRQHandler


#define ARENA_HAS_WATCHDOG       1
#define ARENA_WATCHDOG_0         yes


#define ARENA_RETAIN_1              1
#define ARENA_RETAIN_2              2

#define ARENA_HAS_SPI            5
   #if 0
   // PB3 is user LED; we dont want that there
   #define ARENA_SPI_0           eSpi1, \
                                 eGpioPeripheralB, eGpioPin3, /* Pin D13 SCK  */ \
                                 eGpioPeripheralB, eGpioPin5, /* Pin D11 MOSI */ \
                                 eGpioPeripheralB, eGpioPin4  /* Pin D12 MISO */
   #endif
   #if 1
   #define ARENA_SPI_0        eSpi1, \
                              eGpioPeripheralA, eGpioPin5, /* Pin A4  SCK  */ \
                              eGpioPeripheralA, eGpioPin7, /* Pin A6  MOSI */ \
                              eGpioPeripheralA, eGpioPin6  /* Pin A5  MISO */
   #define ARENA_SPI_0_PINS   SCK->A4, MOSI->A6, MISO->A5
   #endif
   #if 0
   #define ARENA_SPI_0        eSpi1, \
                              eGpioPeripheralA, eGpioPin5, /* Pin A4  SCK  */ \
                              eGpioPeripheralB, eGpioPin5, /* Pin D11 MOSI */ \
                              eGpioPeripheralA, eGpioPin6  /* Pin A5  MISO */
   #endif

#define ARENA_HAS_UART           1
#define ARENA_UART_0          eUsart2, \
                              eGpioPeripheralA, eGpioPin2,     /* Tx */ \
                              eGpioPeripheralA, eGpioPin15     /* RX */
#define ARENA_UART_0_PINS     TX->A7, RX->--
#define ARENA_UART_0_IRQ      USART2_IRQHandler


#define ARENA_HAS_RTC         1
#define ARENA_RTC_0           yep

#define ARENA_HAS_I2C         1
#define ARENA_I2C_0           eI2c1, \
                              eGpioPeripheralB, eGpioPin6,      /* SCL */ \
                              eGpioPeripheralB, eGpioPin7      /* SDA */

#define ARENA_HAS_CAN            1
#define ARENA_CAN_0           eCan1, \
                              eGpioPeripheralA, eGpioPin12, /* Pin D2  Tx  */ \
                              eGpioPeripheralA, eGpioPin11  /* Pin D10 Rx */
#define ARENA_CAN_0_PINS      TX_>D2, \
                              RX->D10

//---fin-----------------------------------------------------------------------
#endif // ? ! _ARENA_BOARD_CONFIG_F303_H_
