/* This function provides accurate delay (in microseconds) based on variable incremented.  */
__weak void ald_delay_us(__IO uint32_t delay)
/* This function provides accurate delay (in microseconds) based on variable incremented.  */
__weak void ald_delay_us(__IO uint32_t delay)
{
    uint32_t start, now, delta, reload, us_tick;
    start = SysTick->VAL;
    reload = SysTick->LOAD;
    us_tick = ald_cmu_get_sys_clock() / 1000000UL;
    do
    {
        now = SysTick->VAL;
        delta = (start > now) ? (start - now) : (reload + start - now);
    }
    while (delta <  (us_tick * delay));
}