/* "Block" until the queue of IOM transactions is over.  */
void am_hal_iom_sleeping_queue_flush(uint32_t ui32Module)
/* "Block" until the queue of IOM transactions is over.  */
void am_hal_iom_sleeping_queue_flush(uint32_t ui32Module)
{
    bool bWaiting = true;
    uint32_t ui32Critical;
    if ( ui32Module >= AM_REG_IOMSTR_NUM_MODULES )
    {
        return;
    }
    while ( bWaiting )
    {
        ui32Critical = am_hal_interrupt_master_disable();
        if ( (g_bIomBusy[ui32Module] == false) &&
            am_hal_queue_empty(&g_psIOMQueue[ui32Module]) )
        {
            bWaiting = false;
        }
        else
        {
            am_hal_sysctrl_sleep(AM_HAL_SYSCTRL_SLEEP_NORMAL);
        }
        am_hal_interrupt_master_set(ui32Critical);
    }
}