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


//
// For convenience
//
using App = eCxx::Application;


//
// Basic initialization for all AVR applications
//
static inline void initBasicAVRApp(bool delayStartupForMCUWithHardwareUSB = false, bool delayStartupForAll = false)
{
    // Initialize application
    const App::Config config( true, App::Config::WDTO::_250mS );

    App::initialize(config);

#ifndef ECXX_AVR_HAVE_HARDWARE_USB
    // Reset this variable if the MCU does not have hardware USB
    delayStartupForMCUWithHardwareUSB = false;
#endif

    // Delay for a while blinking the activity indicator LED
    if(!delayStartupForMCUWithHardwareUSB && !delayStartupForAll) return;

    App::setActivityIndicatorLED(false);
    App::delayMS(500);

    for(eCxx::uint8_t i = 0; i < 5; ++i) {
        App::setActivityIndicatorLED(true ); App::delayMS( 25);
        App::setActivityIndicatorLED(false); App::delayMS( 25);
        App::setActivityIndicatorLED(true ); App::delayMS( 25);
        App::setActivityIndicatorLED(false); App::delayMS( 25);
        App::setActivityIndicatorLED(true ); App::delayMS( 25);
        App::setActivityIndicatorLED(false); App::delayMS( 25);
                                             App::delayMS(350);
    }

    App::setActivityIndicatorLED(false);
    App::delayMS(500);
}
