/* This function provides accurate delay (in milliseconds) based on variable incremented.  */
__weak void ald_delay_ms(__IO uint32_t delay)
/* This function provides accurate delay (in milliseconds) based on variable incremented.  */
__weak void ald_delay_ms(__IO uint32_t delay)
{
	uint32_t tick, __delay;
	switch (__systick_interval) {
	case SYSTICK_INTERVAL_1MS:
		__delay = delay;
		break;
	case SYSTICK_INTERVAL_10MS:
		__delay = delay / 10;
		break;
	case SYSTICK_INTERVAL_100MS:
		__delay = delay / 100;
		break;
	case 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)
		;
}