//-----------------------------------------------------------------------------
///
/// \brief  Low level tool functions
///
///         Pure C standalone functions. But we make it a cpp file because we
///         want to use boolean.
///         We keep them as C (via extern "C").
///
/// \date   20121107
/// \author Maximilian Seesslen <development.seesslen.net>
///
//-----------------------------------------------------------------------------


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


#include <stdint.h>

#if defined STM32F0
   #include <stm/stm32f0xx_hal_gpio.h>
   #include <stm/stm32f0xx_hal_rcc.h>      // IS_RCC_AHB1_PERIPH
   #include <stm/stm32f0xx_hal_dma.h>
   #include <stm/stm32f0xx_hal_usart.h>    // USART_InitTypeDef
   #include <stm/stm32f0xx_hal_adc.h>      // ADC_InitTypeDef
#elif defined STM32F3
   #include <stm/stm32f3xx_hal_gpio.h>
   #include <stm/stm32f3xx_hal_rcc.h>      // IS_RCC_AHB1_PERIPH
   #include <stm/stm32f3xx_hal_dma.h>
   #include <stm/stm32f3xx_hal_usart.h>    // USART_InitTypeDef
   #include <stm/stm32f3xx_hal_adc.h>      // ADC_InitTypeDef
#elif defined STM32F4
   #include <stm/stm32f4xx_hal_gpio.h>
   #include <stm/stm32f4xx_hal_rcc.h>      // IS_RCC_AHB1_PERIPH
   #include <stm/stm32f4xx_hal_dma.h>
   #include <stm/stm32f4xx_hal_usart.h>    // USART_InitTypeDef
   #include <stm/stm32f4xx_hal_adc.h>      // ADC_InitTypeDef
#endif

#include <biwak/biwak.h>            // exception
#include <biwak/lltools.h>          // extern "C"


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


/*
int peripherialToPortSource(GPIO_TypeDef* peripheral)
{
   int portSource=-1;

   // We can not use pointers in switch statements. we use the BASE conterparts.
   // For example, GPIOA == ((GPIO_TypeDef*)GPIOA_BASE)
   switch((__UINTPTR_TYPE__)peripheral)
   {
      case (GPIOA_BASE):
            portSource=EXTI_PortSourceGPIOA;
            break;
      case (GPIOB_BASE):
            portSource=EXTI_PortSourceGPIOB;
            break;
      case (GPIOC_BASE):
            portSource=EXTI_PortSourceGPIOC;
            break;
      case (GPIOD_BASE):
            portSource=EXTI_PortSourceGPIOD;
            break;
      case (GPIOE_BASE):
            portSource=EXTI_PortSourceGPIOE;
            break;
      case (GPIOF_BASE):
            portSource=EXTI_PortSourceGPIOF;
            break;
      case (GPIOG_BASE):
            portSource=EXTI_PortSourceGPIOG;
            break;
      case (GPIOH_BASE):
            portSource=EXTI_PortSourceGPIOH;
            break;
      case (GPIOI_BASE):
            portSource=EXTI_PortSourceGPIOI;
            break;
      default:
            exception("unknown GPIO_Typedef", (int)peripheral);
            break;
   }

   return(portSource);
}
*/


//---fin-----------------------------------------------------------------------
