// TODO 16-4.01
volatile uint8_t TC5_IsCaptureReady = 0;
uint16_t TC5_Period = 0;
uint16_t TC5_Duty = 0;

void TC5_CaptureReady(TC_CAPTURE_STATUS status, uintptr_t context)
{   
    if( (status & TC_CAPTURE_STATUS_CAPTURE0_READY) == TC_CAPTURE_STATUS_CAPTURE0_READY )
    {
        TC5_IsCaptureReady = 1;
    }
}


// TODO 16-4.02
    TC5_CaptureCallbackRegister( TC5_CaptureReady, (uintptr_t)NULL );
    TC5_CaptureStart();


// TODO 16-4.03
        if( TC5_IsCaptureReady )
        {
            TC5_IsCaptureReady = 0;
            TC5_Period = TC5_Capture16bitChannel0Get();
            TC5_Duty = TC5_Capture16bitChannel1Get();

            myprintf("\033[5;1H"); // Set cursor to (1,5)
            myprintf( "Capture Duty   = %3d%%", (int)(TC5_Duty*100/TC5_Period) );
            myprintf("\033[6;1H"); // Set cursor to (1,6)
            myprintf( "Capture Period = %3d ms", (int)(TC5_Period*1000/TC5_CaptureFrequencyGet()) );
        }
