#ifndef _BIWAK_CRC_H_
#define _BIWAK_CRC_H_
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------


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


#include <lepto/lepto.h>

//---Forward declarations-----------------------------------------------------


#if defined (MCU_PLATFORM_STM32)
   #define CRC_HANDLE_TYPE    CRC_HandleTypeDef
   #include <HALWrapper/stm32_crc.h>
#else
   #define CRC_HandleTypeDef    void
#endif


//---Declarations-------------------------------------------------------------

class CCrc;
extern CCrc *pCrc;

class CCrc
{

   private:
      CRC_HandleTypeDef *m_pHandler;

   private:

   public:
      CCrc( );
      ~CCrc();
      void init();
      uint32_t calculateCrc32( const void *_buf, uint32_t len );
      
      uint32_t crc32Init( );
      uint32_t crc32Update( uint32_t crc, const void *_buf, uint32_t len );
      uint32_t crc32Finalize( uint32_t crc );
};


// Make them "C" to avoid name mangeling. Arena may map lepto symbols to those
// functions.
extern "C"
{
   uint32_t calcCrc32Biwak( const void *_buf, uint32_t len );
   uint32_t crc32InitBiwak( );
   uint32_t crc32UpdateBiwak( uint32_t crc, const void *_buf, uint32_t len );
   uint32_t crc32FinalizeBiwak( uint32_t crc );
}


//---fin-----------------------------------------------------------------------
#endif // ? ! _BIWAK_CRC_H_
