aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/stm32f2
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-06-03 00:02:10 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-06-03 00:04:01 -0400
commitff56b76d41a390ed193da180316690f6e2dcbb75 (patch)
tree5ae29c96a64602882cb09b77052e936d3107d623 /wirish/stm32f2
parentcc40b48edacdee58e56e443993aa3c1f22c9374e (diff)
downloadlibrambutan-ff56b76d41a390ed193da180316690f6e2dcbb75.tar.gz
librambutan-ff56b76d41a390ed193da180316690f6e2dcbb75.zip
STM32F2: Add timer_get_af().
Pull some code out of the F2 pinMode() into a utility function. This feels generally useful enough to be exposed to the users (it will, for example, make it easier to implement input capture in a clean way). Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'wirish/stm32f2')
-rw-r--r--wirish/stm32f2/wirish_digital.cpp32
1 files changed, 1 insertions, 31 deletions
diff --git a/wirish/stm32f2/wirish_digital.cpp b/wirish/stm32f2/wirish_digital.cpp
index bf9dcf5..4d46f1c 100644
--- a/wirish/stm32f2/wirish_digital.cpp
+++ b/wirish/stm32f2/wirish_digital.cpp
@@ -91,37 +91,7 @@ void pinMode(uint8 pin, WiringPinMode w_mode) {
if (info->timer_device == NULL) {
return;
}
- gpio_af timer_af;
- /* TODO make this code a <libmaple/timer.h> convenience
- * routine for series that support GPIO alternate
- * functions. */
- switch(info->timer_device->clk_id) {
- case RCC_TIMER1: // fall-through
- case RCC_TIMER2:
- timer_af = GPIO_AF_TIM_1_2;
- break;
- case RCC_TIMER3: // fall-through
- case RCC_TIMER4: // ...
- case RCC_TIMER5:
- timer_af = GPIO_AF_TIM_3_4_5;
- break;
- /* Timers 6 and 7 don't have any capture/compare, so they
- * can't do PWM (and in fact have no AF values). */
- case RCC_TIMER8: // fall-through
- case RCC_TIMER9: // ...
- case RCC_TIMER10: // ...
- case RCC_TIMER11:
- timer_af = GPIO_AF_TIM_8_9_10_11;
- break;
- case RCC_TIMER12: // fall-through
- case RCC_TIMER13: // ...
- case RCC_TIMER14:
- timer_af = GPIO_AF_CAN_1_2_TIM_12_13_14;
- break;
- default:
- ASSERT(0); // Can't happen
- return;
- }
+ gpio_af timer_af = timer_get_af(info->timer_device);
timer_set_mode(info->timer_device, info->timer_channel, TIMER_PWM);
gpio_set_af(info->gpio_device, info->gpio_bit, timer_af);
}