Ejemplo n.º 1
0
void TM_DELAY_TIM_IRQ_HANDLER(void) {
	TIM_ClearITPendingBit(TM_DELAY_TIM, TIM_IT_Update);
#elif defined(KEIL_IDE)
void TimingDelay_Decrement(void) {
#else
void SysTick_Handler(void) {
#endif
	TM_Time++;
	if (TM_Time2 != 0x00) {
		TM_Time2--;
	}
	
	/* Call user function */
	TM_DELAY_1msHandler();
}
Ejemplo n.º 2
0
void TM_DELAY_TIM_IRQ_HANDLER(void) {
	TIM_ClearITPendingBit(TM_DELAY_TIM, TIM_IT_Update);
#elif defined(KEIL_IDE)
void TimingDelay_Decrement(void) {
#else
void SysTick_Handler(void) {
#endif
	uint8_t i;
	
	TM_Time++;
	if (TM_Time2 != 0x00) {
		TM_Time2--;
	}
	
	/* Call user function */
	TM_DELAY_1msHandler();
	
	/* Check custom timers */
	for (i = 0; i < CustomTimers.Count; i++) {
		/* Check if timer is enabled */
		if (
			CustomTimers.Timers[i] && 
			CustomTimers.Timers[i]->Enabled && 
			CustomTimers.Timers[i]->CNT > 0
		) {
			/* Decrease counter */
			CustomTimers.Timers[i]->CNT--;
			
			/* Check if count is zero */
			if (CustomTimers.Timers[i]->CNT == 0) {
				/* Call user callback function */
				CustomTimers.Timers[i]->Callback();
				
				/* Set new counter value */
				CustomTimers.Timers[i]->CNT = CustomTimers.Timers[i]->ARR;
				
				/* Set count value if we want to */
				if (!CustomTimers.Timers[i]->AutoReload) {
					/* Disable counter */
					CustomTimers.Timers[i]->Enabled = 0;
				}
			}
		}
	}
}
Ejemplo n.º 3
0
void TM_DELAY_TIM_IRQ_HANDLER(void) {
	TM_DELAY_TIM->SR = ~TIM_IT_Update;
#elif defined(KEIL_IDE)
void TimingDelay_Decrement(void) {
#else
void SysTick_Handler(void) {
#endif
	uint8_t i;
	
	TM_Time++;
	if (TM_Time2 != 0x00) {
		TM_Time2--;
	}
	
	/* Call user function */
	TM_DELAY_1msHandler();
	
	/* Check custom timers */
	for (i = 0; i < CustomTimers.Count; i++) {
		/* Check if timer is enabled */
		if (
			CustomTimers.Timers[i] &&          /*!< Pointer exists */
			CustomTimers.Timers[i]->Enabled && /*!< Timer is enabled */
			CustomTimers.Timers[i]->CNT > 0    /*!< Counter is not NULL */
		) {
			/* Decrease counter */
			CustomTimers.Timers[i]->CNT--;
			
			/* Check if count is zero */
			if (CustomTimers.Timers[i]->CNT == 0) {
				/* Call user callback function */
				CustomTimers.Timers[i]->Callback(CustomTimers.Timers[i]->UserParameters);
				
				/* Set new counter value */
				CustomTimers.Timers[i]->CNT = CustomTimers.Timers[i]->ARR;
				
				/* Disable timer if auto reload feature is not used */
				if (!CustomTimers.Timers[i]->AutoReload) {
					/* Disable counter */
					CustomTimers.Timers[i]->Enabled = 0;
				}
			}
		}
	}
}
/* Called from Systick handler */
void HAL_IncTick(void) {
	uint8_t i;
	
	/* Increase system time */
	TM_Time++;
	
	/* Decrease other system time */
	if (TM_Time2) {
		TM_Time2--;
	}
	
	/* Check for timers */
	/* Check custom timers */
	for (i = 0; i < CustomTimers.Count; i++) {
		/* Check if timer is enabled */
		if (
			CustomTimers.Timers[i] &&             /*!< Pointer exists */
			CustomTimers.Timers[i]->Flags.F.CNTEN /*!< Timer is enabled */
		) {
			/* Decrease counter if needed */
			if (CustomTimers.Timers[i]->CNT) {
				CustomTimers.Timers[i]->CNT--;
			}

			/* Check if count is zero */
			if (CustomTimers.Timers[i]->CNT == 0) {
				/* Call user callback function */
				CustomTimers.Timers[i]->Callback(CustomTimers.Timers[i], CustomTimers.Timers[i]->UserParameters);

				/* Set new counter value */
				CustomTimers.Timers[i]->CNT = CustomTimers.Timers[i]->ARR;

				/* Disable timer if auto reload feature is not used */
				if (!CustomTimers.Timers[i]->Flags.F.AREN) {
					/* Disable counter */
					CustomTimers.Timers[i]->Flags.F.CNTEN = 0;
				}
			}
		}
	}
	
	/* Call 1ms interrupt handler function */
	TM_DELAY_1msHandler();
}