/* Delays for a desired amount of cycles while also waiting for a status change.  */
uint32_t am_hal_flash_delay_status_change(uint32_t ui32usMaxDelay, uint32_t ui32Address, uint32_t ui32Mask, uint32_t ui32Value)
/* Delays for a desired amount of cycles while also waiting for a status change.  */
uint32_t am_hal_flash_delay_status_change(uint32_t ui32usMaxDelay, uint32_t ui32Address, uint32_t ui32Mask, uint32_t ui32Value)
{
    while ( ui32usMaxDelay-- )
    {
        if ( ( AM_REGVAL(ui32Address) & ui32Mask ) == ui32Value )
        {
            return 1;
        }
        am_hal_flash_delay( FLASH_CYCLES_US(1) );
    }
    return 0;
}