// TODO 13.01
// uint16_t ADC_Result;
uint16_t ADC_Result[2];
volatile uint8_t ADC_IsCompleted = 0;
volatile int8_t  ADC_ChannelIdx = 0;


// TODO 13.02
void ADC_Complete( ADC_STATUS status, uintptr_t context )
{
    if( status & ADC_INTFLAG_RESRDY_Msk )
    {
        ADC_Result[ADC_ChannelIdx] = ADC_ConversionResultGet();
        ADC_ChannelIdx = ( ADC_ChannelIdx + 1 ) % 2;
        if( ADC_ChannelIdx == 0 )
        {
            ADC_IsCompleted = 1;
        }
    }
}


// TODO 13.03
    ADC_CallbackRegister( ADC_Complete, (uintptr_t )NULL );
    ADC_Enable();


// TODO 13.04
            ADC_ConversionStart();
            // while( !ADC_ConversionStatusGet() );
            // ADC_Result = ADC_ConversionResultGet();
            // myprintf("\033[2;1HVR : %4d", ADC_Result );
    
    
// TODO 13.05
        if( ADC_IsCompleted )
        {
            ADC_IsCompleted = 0;

            myprintf( "\033[2;1HVR1 Value : %4d", ADC_Result[0] );
            myprintf( "\033[3;1HTemperature Value : %4d", ADC_Result[1] );
        }
