#ifndef BIWAK_PWM_LINE_HPP
#define BIWAK_PWM_LINE_HPP
//----------------------------------------------------------------------------
///
/// \brief  Class for PWM output line
///
///         See implementation for further information.
///
/// \date   20141204
/// \author Maximilian Seesslen <mes.seesslen.net>
///
//----------------------------------------------------------------------------


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


///---General-------------------------


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

#include <biwak/output.hpp>
#include <biwak/timer.hpp>


//---Defines------------------------------------------------------------------


//---Declaration--------------------------------------------------------------


class CPwmDimpl;
class CDma;

struct SPwmLineConfig;

#if IS_ENABLED( CONFIG_BIWAK_PWM_BARREL_ORGAN )
   #error Biwak: BIWAK_PWM_BARREL_ORGAN not supported any more
#endif

class CPwmLine
{
   public:

   private:
      #if ! defined( STM32 )
             CPwmDimpl *m_pDimpl;
      #endif
       
      CTimer &m_timer;
      ETimerChannel m_eTimerChannel;
      #if IS_ENABLED( CONFIG_BIWAK_HOLD_PWM_VALUE )
      int m_pwmValue=0;
      #endif

   public:
      //CPwmLine(const char* label, const SPwmLineConfig &configData, CTimer &timer );
      CPwmLine( const SPwmLineConfig &configData, CTimer &timer );
      ~CPwmLine();

        void setPwmValue(int permilliValue);
        #if IS_ENABLED( CONFIG_BIWAK_HOLD_PWM_VALUE )
        int getPwmValue()
        {
           return(m_pwmValue);
        }
        #endif
        void setPwmDmaValues(const uint32_t *buffer, int size);
        void restartPwmDmaValues(const uint32_t *buffer, int size);
        CTimer &getTimer()
        {
           return(m_timer);
        }
        ETimerChannel timerChannel() const
        {
           return(m_eTimerChannel);
        }

        void setDmaChannel(CDmaChannel *dmaChannel);
};


//---fin-----------------------------------------------------------------------
#endif // ? ! BIWAK_PWM_LINE_HPP
