/* This function provides accurate delay (in milliseconds) based on variable incremented.  */
__weak void ald_delay_1ms(__IO uint32_t delay)
/* This function provides accurate delay (in milliseconds) based on variable incremented.  */
__weak void ald_delay_1ms(__IO uint32_t delay)
{
    uint32_t tick, __delay;
    switch (__systick_interval) {
    case ALD_SYSTICK_INTERVAL_1MS:
        __delay = delay;
        break;
    case ALD_SYSTICK_INTERVAL_10MS:
        __delay = delay / 10;
        break;
    case ALD_SYSTICK_INTERVAL_100MS:
        __delay = delay / 100;
        break;
    case ALD_SYSTICK_INTERVAL_1000MS:
        __delay = delay / 1000;
        break;
    default:
        __delay = delay;
        break;
    }
    tick    = ald_get_tick();
    __delay = __delay == 0 ? 1 : __delay;
    while ((ald_get_tick() - tick) < __delay)
        ;
}