diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2012-06-02 21:15:17 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2012-06-02 21:15:17 -0400 |
commit | 7943836c4a967e70ced14a2f4accf21a0469b238 (patch) | |
tree | 048250c46cc6d996232917baf36bef012beaabe0 /wirish/pwm.cpp | |
parent | 54e139760a22040535b879ce6537af49ea9b31a5 (diff) | |
download | librambutan-7943836c4a967e70ced14a2f4accf21a0469b238.tar.gz librambutan-7943836c4a967e70ced14a2f4accf21a0469b238.zip |
Bring back/tweak pwmWrite().
Works on F1, doesn't on F2. Will figure that out next.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'wirish/pwm.cpp')
-rw-r--r-- | wirish/pwm.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/wirish/pwm.cpp b/wirish/pwm.cpp index a55f245..44884cd 100644 --- a/wirish/pwm.cpp +++ b/wirish/pwm.cpp @@ -2,6 +2,7 @@ * The MIT License * * Copyright (c) 2010 Perry Hung. + * Copyright (c) 2011, 2012 LeafLabs, LLC. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -25,7 +26,8 @@ *****************************************************************************/ /** - * @brief Arduino-style PWM implementation. + * @file wirish/pwm.cpp + * @brief Wiring-style pwmWrite(). */ #include <wirish/pwm.h> @@ -36,10 +38,11 @@ #include <wirish/boards.h> void pwmWrite(uint8 pin, uint16 duty_cycle) { - timer_dev *dev = PIN_MAP[pin].timer_device; - if (pin >= BOARD_NR_GPIO_PINS || dev == NULL || dev->type == TIMER_BASIC) { + if (pin >= BOARD_NR_GPIO_PINS) { return; } - - timer_set_compare(dev, PIN_MAP[pin].timer_channel, duty_cycle); + timer_dev *dev = PIN_MAP[pin].timer_device; + uint8 cc_channel = PIN_MAP[pin].timer_channel; + ASSERT(dev && cc_channel); + timer_set_compare(dev, cc_channel, duty_cycle); } |