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


#include <eCxx/eCxx.h>

#include "AVR_Common.h"


//
// TWISlave address
//
static constexpr eCxx::uint8_t twiSlaveAddress = 0x7F;


//
// Include common source code for TWIMaster test application
//
#include "../CommonCode/TWIMaster_Common.h"


//
// The init function
//
void eCxx_user_init()
{
    // Initialize application
    initBasicAVRApp();

    // Initialize TWI in master mode and UART
    //
    // In case the slave has software TWI implementation with high latency, set
    // the flag below to 'true' so that the master will use low clock speed
#if 1
    // Use the default speed
    initTWIMasterAndUART(false);
#else
    // Use slow speed for NodeMCU TWI slave
    initTWIMasterAndUART(true);
#endif
}


//
// The task function
//
void eCxx_user_task()
{
    // Process event and send-receive data to slave
    eCxx_user_task_TWIMasterTxRx();
}
