aboutsummaryrefslogtreecommitdiff
path: root/lib/stm32
diff options
context:
space:
mode:
authorGareth McMullin2012-04-08 14:12:21 +1200
committerGareth McMullin2012-04-08 14:12:21 +1200
commit8820277f091d46e9376daca6b08b9e909023fc24 (patch)
tree6dcb1e5d05ed4284cc440418dcde592b8f22a7a0 /lib/stm32
parenta8ec86a52767b7d90bc1467d4557e2148ad5ce9e (diff)
Added functions for configuring timers in slave mode.
Diffstat (limited to 'lib/stm32')
-rw-r--r--lib/stm32/f1/timer.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/stm32/f1/timer.c b/lib/stm32/f1/timer.c
index e1095f2..cf5b411 100644
--- a/lib/stm32/f1/timer.c
+++ b/lib/stm32/f1/timer.c
@@ -1007,3 +1007,35 @@ void timer_ic_disable(u32 timer, enum tim_ic_id ic)
TIM_CCER(timer) &= ~(0x1 << (ic * 4));
}
+void timer_slave_set_filter(u32 timer, enum tim_ic_filter flt)
+{
+ TIM_SMCR(timer) &= ~TIM_SMCR_ETF_MASK;
+ TIM_SMCR(timer) |= flt << 8;
+}
+
+void timer_slave_set_prescaler(u32 timer, enum tim_ic_psc psc)
+{
+ TIM_SMCR(timer) &= ~TIM_SMCR_ETPS_MASK;
+ TIM_SMCR(timer) |= psc << 12;
+}
+
+void timer_slave_set_polarity(u32 timer, enum tim_ic_pol pol)
+{
+ if (pol)
+ TIM_SMCR(timer) |= TIM_SMCR_ETP;
+ else
+ TIM_SMCR(timer) &= ~TIM_SMCR_ETP;
+}
+
+void timer_slave_set_mode(u32 timer, u8 mode)
+{
+ TIM_SMCR(timer) &= ~TIM_SMCR_SMS_MASK;
+ TIM_SMCR(timer) |= mode;
+}
+
+void timer_slave_set_trigger(u32 timer, u8 trigger)
+{
+ TIM_SMCR(timer) &= ~TIM_SMCR_TS_MASK;
+ TIM_SMCR(timer) |= trigger;
+}
+