/* Read the captured value from Capture Compare unit.  */
uint32_t ald_timer_read_capture_value(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
/* Read the captured value from Capture Compare unit.  */
uint32_t ald_timer_read_capture_value(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
{
    uint32_t tmp;
    __LOCK(hperh);
    hperh->state = ALD_TIMER_STATE_BUSY;
    switch (ch) {
    case ALD_TIMER_CHANNEL_1:
        tmp = hperh->perh->CCVAL1;
        break;
    case ALD_TIMER_CHANNEL_2:
        tmp = hperh->perh->CCVAL2;
        break;
    case ALD_TIMER_CHANNEL_3:
        tmp = hperh->perh->CCVAL3;
        break;
    case ALD_TIMER_CHANNEL_4:
        tmp = hperh->perh->CCVAL4;
        break;
    default:
        tmp = hperh->perh->CCVAL1;
        break;
    }
    hperh->state = ALD_TIMER_STATE_READY;
    __UNLOCK(hperh);
    return tmp;
}