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 | |
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>
-rw-r--r-- | wirish/pwm.cpp | 13 | ||||
-rw-r--r-- | wirish/rules.mk | 2 |
2 files changed, 9 insertions, 6 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); } diff --git a/wirish/rules.mk b/wirish/rules.mk index 54c9180..176ba6a 100644 --- a/wirish/rules.mk +++ b/wirish/rules.mk @@ -25,6 +25,7 @@ cppSRCS_$(d) += cxxabi-compat.cpp cppSRCS_$(d) += HardwareSerial.cpp cppSRCS_$(d) += HardwareTimer.cpp cppSRCS_$(d) += Print.cpp +cppSRCS_$(d) += pwm.cpp cppSRCS_$(d) += wirish_analog.cpp cppSRCS_$(d) += wirish_digital.cpp cppSRCS_$(d) += wirish_math.cpp @@ -36,7 +37,6 @@ cppSRCS_$(d) += $(WIRISH_BOARD_PATH)/board.cpp # TODO: revise these appropriately F2 and put them back in: # HardwareSPI.cpp # usb_serial.cpp -# pwm.cpp # ext_interrupts.cpp sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) |