31 #define TM_DELAY_H 240
155 #include "stm32f4xx.h"
156 #include "stm32f4xx_rcc.h"
158 #include "attributes.h"
160 #if defined(TM_DELAY_TIM)
162 #include "stm32f4xx_tim.h"
163 #include "tm_stm32f4_timer_properties.h"
181 void (*Callback)(
void *);
199 #ifndef DELAY_MAX_CUSTOM_TIMERS
200 #define DELAY_MAX_CUSTOM_TIMERS 5
204 #ifndef LIB_ALLOC_FUNC
205 #define LIB_ALLOC_FUNC malloc
209 #ifndef LIB_FREE_FUNC
210 #define LIB_FREE_FUNC free
228 extern __IO uint32_t TM_Time2;
229 extern __IO uint32_t mult;
247 static __INLINE
void Delay(uint32_t micros) {
248 #if defined(TM_DELAY_TIM)
249 volatile uint32_t timer = TM_DELAY_TIM->CNT;
253 while ((TM_DELAY_TIM->CNT - timer) == 0);
256 timer = TM_DELAY_TIM->CNT;
264 amicros = (micros) * (mult);
267 if (SystemCoreClock == 180000000 || SystemCoreClock == 100000000) {
274 #if defined(STM32F411xE)
289 static __INLINE
void Delayms(uint32_t millis) {
290 volatile uint32_t timer =
TM_Time;
295 while ((
TM_Time - timer) < millis) {
304 if (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) {
324 #define TM_DELAY_Time() (TM_Time)
331 #define TM_DELAY_SetTime(time) (TM_Time = (time))
355 #define TM_DELAY_Time2() (TM_Time2)
363 #define TM_DELAY_SetTime2(time) (TM_Time2 = (time))
void TM_DELAY_Init(void)
Initializes timer settings for delay.
TM_DELAY_Timer_t * TM_DELAY_TimerAutoReload(TM_DELAY_Timer_t *Timer, uint8_t AutoReload)
Sets auto reload feature for timer.
TM_DELAY_Timer_t * TM_DELAY_TimerReset(TM_DELAY_Timer_t *Timer)
Resets custom timer counter value.
uint32_t CNT
Definition: tm_stm32f4_delay.h:179
TM_DELAY_Timer_t * TM_DELAY_TimerCreate(uint32_t ReloadValue, uint8_t AutoReload, uint8_t StartTimer, void(*TM_DELAY_CustomTimerCallback)(void *), void *UserParameters)
Creates a new custom timer which has 1ms resolution.
__weak void TM_DELAY_1msHandler(void)
User function, called each 1ms when interrupt from timer happen.
static __INLINE void Delay(uint32_t micros)
Definition: tm_stm32f4_delay.h:247
uint8_t Enabled
Definition: tm_stm32f4_delay.h:180
TM_DELAY_Timer_t * TM_DELAY_TimerStop(TM_DELAY_Timer_t *Timer)
Stops custom timer from counting.
Custom timer structure.
Definition: tm_stm32f4_delay.h:176
uint32_t ARR
Definition: tm_stm32f4_delay.h:177
void TM_DELAY_TimerDelete(TM_DELAY_Timer_t *Timer)
Deletes already allocated timer.
void TM_DELAY_DisableDelayTimer(void)
Disables delay timer.
void TM_DELAY_EnableDelayTimer(void)
Re-enables delay timer It has to be configured before with TM_DELAY_Init()
TM_DELAY_Timer_t * TM_DELAY_TimerStart(TM_DELAY_Timer_t *Timer)
Starts custom timer counting.
TM_DELAY_Timer_t * TM_DELAY_TimerAutoReloadValue(TM_DELAY_Timer_t *Timer, uint32_t AutoReloadValue)
Sets auto reload value for timer.
void * UserParameters
Definition: tm_stm32f4_delay.h:182
uint32_t AutoReload
Definition: tm_stm32f4_delay.h:178
static __INLINE void Delayms(uint32_t millis)
Definition: tm_stm32f4_delay.h:289