Added get flag and get counter functions to timer. Allow proper interrupt handling and recording timer counter values.

This commit is contained in:
Piotr Esden-Tempski
2011-02-01 22:43:18 -08:00
parent d40fb96fcf
commit c7587f11ec
2 changed files with 17 additions and 0 deletions

View File

@@ -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);
}