diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-10-14 23:31:33 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-10-14 23:31:33 -0400 |
commit | 8bcd7de4fff752f173a253026e6c671bdad03505 (patch) | |
tree | 61adef4ade428dec8597ed9dc48d1591532bda04 /wirish/wirish_digital.c | |
parent | d8ec48c9312d87d8c358e32550f950fa851c0599 (diff) | |
parent | aa7a43efce35fa41d57f9858ee41be0c33e84709 (diff) | |
download | librambutan-8bcd7de4fff752f173a253026e6c671bdad03505.tar.gz librambutan-8bcd7de4fff752f173a253026e6c671bdad03505.zip |
Merge branch 'master' of github.com:leaflabs/libmaple
Diffstat (limited to 'wirish/wirish_digital.c')
-rw-r--r-- | wirish/wirish_digital.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/wirish/wirish_digital.c b/wirish/wirish_digital.c index f4868da..9298b60 100644 --- a/wirish/wirish_digital.c +++ b/wirish/wirish_digital.c @@ -31,6 +31,7 @@ void pinMode(uint8 pin, WiringPinMode mode) { uint8 outputMode; + uint32 pwm = 0; if (pin >= NR_GPIO_PINS) { return; @@ -58,9 +59,11 @@ void pinMode(uint8 pin, WiringPinMode mode) { break; case PWM: outputMode = GPIO_MODE_AF_OUTPUT_PP; + pwm = 1; break; case PWM_OPEN_DRAIN: outputMode = GPIO_MODE_AF_OUTPUT_OD; + pwm = 1; break; default: ASSERT(0); @@ -68,6 +71,19 @@ void pinMode(uint8 pin, WiringPinMode mode) { } gpio_set_mode(PIN_MAP[pin].port, PIN_MAP[pin].pin, outputMode); + + if (PIN_MAP[pin].timer_num != TIMER_INVALID) { + /* enable/disable timer channels if we're switching into or out of pwm */ + if (pwm) { + timer_set_mode(PIN_MAP[pin].timer_num, + PIN_MAP[pin].timer_chan, + TIMER_PWM); + } else { + timer_set_mode(PIN_MAP[pin].timer_num, + PIN_MAP[pin].timer_chan, + TIMER_DISABLED); + } + } } |