#ifndef _LEPTO_CRC32_H_
#define _LEPTO_CRC32_H_
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------


#include <cstdint>
#include <lepto/lepto.h>

// For regular linux builds 'LEPTO_CONFIGURABLE_CRC32' should be enabled by
// default. The 'hwdata' tool is using it.
#if ! defined (STM32)
   #if ! defined CONFIG_LEPTO_CONFIGURABLE_CRC32
      #define CONFIG_LEPTO_CONFIGURABLE_CRC32          1
   #endif
#endif

typedef uint32_t crc32_t;

// Make them "C" to avoid name mangeling. Arena may map the symbols to biwak
// functions.
extern "C"
{
   #if IS_ENABLED( CONFIG_LEPTO_CONFIGURABLE_CRC32 )
   extern crc32_t (*crc32Init)( );
   extern crc32_t (*crc32Update)( crc32_t crc, const void *buf, uint32_t len );
   extern crc32_t (*crc32Finalize)( crc32_t crc );
   extern crc32_t (*calcCrc32)( const void *buf, uint32_t len );

   enum ECrc32Mode {
      Default,
      Mpeg,
   };

   void configCrc32( ECrc32Mode mode);
   #else
   crc32_t crc32Init( );
   crc32_t crc32Update( crc32_t crc, const void *buf, uint32_t len );
   crc32_t crc32Finalize( crc32_t crc );
   crc32_t calcCrc32( const void *buf, uint32_t len );
   #endif // ! ? LEPTO_CONFIGURABLE_CRC32

   crc32_t crc32DefaultInit( );
   crc32_t crc32DefaultUpdate( crc32_t crc, const void *buf, uint32_t len );
   crc32_t crc32DefaultFinalize( crc32_t crc );
   crc32_t calcCrc32Default( const void *buf, uint32_t len );

   crc32_t crc32MpegInit( );
   crc32_t crc32MpegUpdate( crc32_t crc, const void *buf, uint32_t len );
   crc32_t crc32MpegFinalize( crc32_t crc );
   crc32_t calcCrc32Mpeg( const void *buf, uint32_t len );
}


//---fin-----------------------------------------------------------------------
#endif // ? ! _LEPTO_CRC32_H_
