// TODO 11.01
#include <stdarg.h>


// TODO 11.02
#define SYS_CONSOLE_PRINT_BUFFER_SIZE	200
static char consolePrintBuffer[SYS_CONSOLE_PRINT_BUFFER_SIZE];
volatile uint8_t TC3_HasExpired = 0;
volatile uint8_t TC4_HasExpired = 0;


// TODO 11.03
        TC3_HasExpired = 1;


// TODO 11.04
        TC4_HasExpired = 1;


// TODO 11.05
void myprintf(const char *format, ...)
{
    size_t len = 0;
    va_list args = {0};

    va_start(args, format);
    len = vsnprintf(consolePrintBuffer, SYS_CONSOLE_PRINT_BUFFER_SIZE, format, args);
    va_end(args);

    if ((len > 0) && (len < SYS_CONSOLE_PRINT_BUFFER_SIZE))
    {
        consolePrintBuffer[len] = '\0';
        SERCOM5_USART_Write(consolePrintBuffer, len);
        while (SERCOM5_USART_WriteIsBusy());
    }
}


// TODO 11.06
        if (TC3_HasExpired)
        {
            TC3_HasExpired = 0;
            LED1_Toggle();
            myprintf( "Hello World!\r\n" );
        }

        if (TC4_HasExpired)
        {
            TC4_HasExpired = 0;
            LED2_Toggle();
        }


// TODO 11.07
            myprintf( "\r\nReceived Data : %1c\r\n", USART5_ReceiveData[0] );
