void TM_DELAY_Init(void) {
	/* If already initialized */
	if (TM_DELAY_Initialized) {
		return;
	}

	/* Enable External HSE clock */
	RCC_HSEConfig(RCC_HSE_ON);

	/* Wait for stable clock */
	while (!RCC_WaitForHSEStartUp());

#if defined(TM_DELAY_TIM)
	TM_DELAY_INT_InitTIM();
#else
	/* Set Systick interrupt every 1ms */
	if (SysTick_Config(SystemCoreClock / 1000)) {
		/* Capture error */
		while (1);
	}

	#ifdef __GNUC__
		/* Set multiplier for delay under 1us with pooling mode = not so accurate */
		mult = SystemCoreClock / 7000000;
	#else
		/* Set multiplier for delay under 1us with pooling mode = not so accurate */
		mult = SystemCoreClock / 3000000;
	#endif
#endif

	/* Set initialized flag */
	TM_DELAY_Initialized = 1;
}
void TM_DELAY_Init(void) {	
#if defined(TM_DELAY_TIM)
	TM_DELAY_INT_InitTIM();
#else
	/* Set Systick interrupt every 1ms */
	if (SysTick_Config(SystemCoreClock / 1000)) {
		/* Capture error */
		while (1);
	}
	
	#ifdef __GNUC__
		/* Set multiplier for delay under 1us with pooling mode = not so accurate */
		mult = SystemCoreClock / 7000000;
	#else
		/* Set multiplier for delay under 1us with pooling mode = not so accurate */
		mult = SystemCoreClock / 3000000;
	#endif
#endif
	
	/* Set initialized flag */
	TM_DELAY_Initialized = 1;
}