#ifndef _TEMP_TSIC_H_
#define _TEMP_TSIC_H_
//----------------------------------------------------------------------------
///
/// \brief  an TSIC digital temperature sensor
///
///         See implementation for further information.
///
//----------------------------------------------------------------------------


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


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

#include <biwak/input.h>
#include <biwak/input_decoder.h>
#include <biwak/temperature.h>
#include <lepto/ring.h>


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


enum ETsicError
{
   eTsicErrorNone,
   eTsicErrorDecodeBit,
   eTsicErrorParrity,
   eTsicErrorAssume,
};


class CTempTsicDecoder
      :public CInputDecoderRecorder
{
   ETsicError eTsicError;

public:
   CTempTsicDecoder();
   virtual void decodeFrame();
   void dumpSlopes();
   ETsicError getError();
   virtual void sink(int32_t temperature);
};

/// \brief  an TSIC digital temperature sensor
///
///         CInput already is an interrupt (Exti), so we just have to overload
///         the interrupt handler.
class CTempTsic
         :public CTemperature
         ,public CInput
         ,public CTempTsicDecoder
{
         int32_t m_temperature;

    public:
         CRing <int32_t> equalRing;

        CTempTsic(EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin);
        ~CTempTsic();
        virtual void sink(int32_t temperature) override
        {
            m_temperature=temperature;
            equalRing.putEntry( m_temperature );
        }

        virtual int32_t getTemperature();

};


//---fin----------------------------------------------------------------------
#endif // ? ! _TEMP_TSIC_H_
