enum AD_STATES check_ad_status(void)
{
    data U8 buff_ad_status;
    data enum AD_STATES status;

    // Get copy so status doesn't change on us in mid-compare.
    buff_ad_status = s_ad_status;

    // Develop the true state of the A/D based on BUSY and VALUE_LOCKED which
    // are mutually exclusive.
    if (buff_ad_status & BUSY) {
        // Still converting.
        status = AD_BUSY;
    }
    else if (buff_ad_status & VALUE_LOCKED) {
        // Value should be read from the current channel.
        status = AD_VALUE;
    }
    else {
        // Okay to start another conversion in this case.
        status = AD_READY;
    }

    return(status);
}