//-----------------------------------------------------------------------------
///
/// \brief  LCD Common pin
///
/// \date   20230102
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//-----------------------------------------------------------------------------


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


//---Own------------------------------

#include <biwak/lcd.hpp>
#include <biwak/exception.h>
#include <HALWrapper/stm32_rcc.h>
#include <HALWrapper/stm32_lcd.h>


//---Implementation------------------------------------------------------------


CLcd::CLcd()
{
    RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

    PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LCD;
    PeriphClkInit.LCDClockSelection = RCC_RTCCLKSOURCE_LSI;

    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
    {
      exception( );
    }

   m_LCDHandle.Instance              = LCD;
   m_LCDHandle.Init.Prescaler        = LCD_PRESCALER_1;
   m_LCDHandle.Init.Divider          = LCD_DIVIDER_16;
   m_LCDHandle.Init.Duty             = LCD_DUTY_STATIC;
   m_LCDHandle.Init.Bias             = LCD_BIAS_1_4;
   m_LCDHandle.Init.VoltageSource    = LCD_VOLTAGESOURCE_EXTERNAL;
   m_LCDHandle.Init.Contrast         = LCD_CONTRASTLEVEL_4;
   m_LCDHandle.Init.DeadTime         = LCD_DEADTIME_0;
   m_LCDHandle.Init.PulseOnDuration  = LCD_PULSEONDURATION_0;
   m_LCDHandle.Init.MuxSegment       = LCD_MUXSEGMENT_DISABLE;
   m_LCDHandle.Init.BlinkMode        = LCD_BLINKMODE_OFF;
   m_LCDHandle.Init.BlinkFrequency   = LCD_BLINKFREQUENCY_DIV8;

   /* Initialize the LCD */
   HAL_LCD_Init(&m_LCDHandle);
}


CLcd::~CLcd()
{

}


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