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


#ifndef INCLUDE_ECXX_PLATFORM_PLATFORM_H
#error "this file cannot be included directly"
#endif
#undef INCLUDE_ECXX_PLATFORM_PLATFORM_H


#ifndef ECXX_PLATFORM_PLATFORM__H
#define ECXX_PLATFORM_PLATFORM__H


//
// Include the platform-specific header files
//

// AVR
#ifdef __AVR_ARCH__
    // Include the header files
    #ifdef ECXX_BUILDING_ECXX_LIBRARY
        #include <avr/eeprom.h>
        #include <avr/wdt.h>
        #include <util/atomic.h>
    #endif
    #include <avr/pgmspace.h>
    // Undefine these macros because they are interfering with eCxx
    #ifndef ECXX_PLATFORM_NODEMCU_CONFIG_H
        #undef PROGMEM
    #endif
    #undef PSTR
    #undef PGM_P
    #undef PGM_VOID_P
    #undef pgm_get_far_address
    // Workaround for incorrect macro definition in AVRX platform
    #ifdef __AVR_ARCH_X__
        #undef  eeprom_is_ready
        #define eeprom_is_ready() ( !(NVMCTRL.STATUS & NVMCTRL_EEBUSY_bm) )
    #endif
#endif

// NodeMCU-ESP8266
#ifdef __XTENSA__
    // Include the header files
    #include <c_types.h>
    #include <time.h>
    #include <sys/pgmspace.h>
    #include <cctype>
    #include <cstdio>
    #include <algorithm>
    #include <functional>
    #include <memory>
    #include <new>
    // Undefine this macro because it is interfering with eCxx
    #ifndef ECXX_PLATFORM_NODEMCU_CONFIG_H
        #undef PROGMEM
    #endif
    #undef F
    #undef PSTR
    #undef PSTR4
    #undef PGM_P
    #undef PGM_VOID_P
#endif


#endif
