aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/pwm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'wirish/pwm.cpp')
-rw-r--r--wirish/pwm.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/wirish/pwm.cpp b/wirish/pwm.cpp
index 7e8a535..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,21 +26,23 @@
*****************************************************************************/
/**
- * @brief Arduino-style PWM implementation.
+ * @file wirish/pwm.cpp
+ * @brief Wiring-style pwmWrite().
*/
-#include "pwm.h"
+#include <wirish/pwm.h>
-#include "libmaple_types.h"
-#include "timer.h"
+#include <libmaple/libmaple_types.h>
+#include <libmaple/timer.h>
-#include "boards.h"
+#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);
}