/*
 * Copyright (C) 2020-2021 Aloysius Indrayanto
 *
 * This file is part of the eCxx library, see LICENSE file for the license details.
 */


#ifndef ECXX_PLATFORM_COMMON_TWIMASTER_H
#define ECXX_PLATFORM_COMMON_TWIMASTER_H


#ifdef ECXX_BUILDING_ECXX_LIBRARY
    #include <eCxx/CTL/HaveMemberCheck.h>
#endif

#include <eCxx/CTL/BasicOutputWriter.h>
#include <eCxx/CTL/RingBuffer.h>

#include <eCxx/Platform/Common/TWIConstant.h>


//
// Include the platform-specific's implementation
//
#define INCLUDE_ECXX_PLATFORM_SPECIFIC_TWIMASTER_H

// AVR
#ifdef __AVR_ARCH__
    #include "../AVRCommon/TWIMaster.h"
#endif

// NodeMCU-ESP8266
#ifdef __XTENSA__
    #include "../NodeMCU/TWIMaster.h"
#endif

// Dummy (for testing the eCxx library in the host PC)
#ifdef INCLUDE_ECXX_PLATFORM_SPECIFIC_TWIMASTER_H
    #include "../Dummy/TWIMaster.h"
#endif


//
// Check if the platform-specific's implementation provides the necessary member types/constants/variables/functions/etc.
//
#ifdef ECXX_BUILDING_ECXX_LIBRARY

namespace eCxx {

    namespace internal_twimaster_check {

        // Member constants/variables/functions
        ECXX_CHECK_HAVE_MEMBER(TWIMaster, DefaultTWIFrequency);
        ECXX_CHECK_HAVE_MEMBER(TWIMaster, TWIResultCode);

        ECXX_CHECK_HAVE_MEMBER(TWIMaster, begin);
        ECXX_CHECK_HAVE_MEMBER(TWIMaster, end);

        ECXX_CHECK_HAVE_MEMBER(TWIMaster, beginTransmission);
        ECXX_CHECK_HAVE_MEMBER(TWIMaster, write);
        ECXX_CHECK_HAVE_MEMBER(TWIMaster, endTransmission);

        ECXX_CHECK_HAVE_MEMBER(TWIMaster, requestFrom);
        ECXX_CHECK_HAVE_MEMBER(TWIMaster, canRead);
        ECXX_CHECK_HAVE_MEMBER(TWIMaster, read);
        ECXX_CHECK_HAVE_MEMBER(TWIMaster, peek);

    } // namespace internal

} // namespace eCxx

#endif


#endif
