/* Wait for normal group conversion to be completed.  */
ald_status_t ald_adc_normal_poll_for_conversion(ald_adc_handle_t *hperh, uint32_t timeout)
/* Wait for normal group conversion to be completed.  */
ald_status_t ald_adc_normal_poll_for_conversion(ald_adc_handle_t *hperh, uint32_t timeout)
{
    uint32_t _tick;
    assert_param(IS_ADC_TYPE(hperh->perh));
    _tick = ald_get_tick();
    while (!(READ_BIT(hperh->perh->STAT, ADC_STAT_NCHE_MSK))) {
        if (timeout != ALD_MAX_DELAY ) {
            if ((timeout == 0) || ((ald_get_tick() - _tick) > timeout)) {
                hperh->state = ALD_ADC_STATE_TIMEOUT;
                return ALD_TIMEOUT;
            }
        }
    }
    WRITE_REG(hperh->perh->CLR, ALD_ADC_FLAG_NCHS | ALD_ADC_FLAG_NCH);
    return ALD_OK;
}