Added get flag and get counter functions to timer. Allow proper interrupt handling and recording timer counter values.
This commit is contained in:
@@ -104,6 +104,16 @@ void timer_disable_irq(u32 timer_peripheral, u32 irq)
|
||||
TIM_DIER(timer_peripheral) &= ~irq;
|
||||
}
|
||||
|
||||
bool timer_get_flag(u32 timer_peripheral, u32 flag)
|
||||
{
|
||||
if (((TIM_SR(timer_peripheral) & flag) != 0) &&
|
||||
((TIM_DIER(timer_peripheral) & flag) != 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void timer_clear_flag(u32 timer_peripheral, u32 flag)
|
||||
{
|
||||
TIM_SR(timer_peripheral) &= ~flag;
|
||||
@@ -929,3 +939,8 @@ void timer_generate_event(u32 timer_peripheral, u32 event)
|
||||
{
|
||||
TIM_EGR(timer_peripheral) |= event;
|
||||
}
|
||||
|
||||
u32 timer_get_counter(u32 timer_peripheral)
|
||||
{
|
||||
return TIM_CNT(timer_peripheral);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user