[gnoduino: 139/237] added support for TIMER4D used for PWM on Leonardo and Micro D6



commit 3c24bc1b011ce99f6fc9bd3989b6aea200f943de
Author: Zach Eveland <zeveland blacklabel-development com>
Date:   Fri Sep 16 16:36:42 2011 -0400

    added support for TIMER4D used for PWM on Leonardo and Micro D6

 arduino/cores/arduino/Arduino.h       |    7 ++++---
 arduino/cores/arduino/wiring_analog.c |    8 ++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/arduino/cores/arduino/Arduino.h b/arduino/cores/arduino/Arduino.h
index ebdbe9a..7f2fc05 100755
--- a/arduino/cores/arduino/Arduino.h
+++ b/arduino/cores/arduino/Arduino.h
@@ -169,9 +169,10 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
 #define TIMER4A 11
 #define TIMER4B 12
 #define TIMER4C 13
-#define TIMER5A 14
-#define TIMER5B 15
-#define TIMER5C 16
+#define TIMER4D 14	
+#define TIMER5A 15
+#define TIMER5B 16
+#define TIMER5C 17
 
 #ifdef __cplusplus
 } // extern "C"
diff --git a/arduino/cores/arduino/wiring_analog.c b/arduino/cores/arduino/wiring_analog.c
index 62b91cf..2b1f3a0 100644
--- a/arduino/cores/arduino/wiring_analog.c
+++ b/arduino/cores/arduino/wiring_analog.c
@@ -225,6 +225,14 @@ void analogWrite(uint8_t pin, int val)
 				OCR4C = val; // set pwm duty
 				break;
 			#endif
+				
+			#if defined(TCCR4A) && defined(COM4D1)
+			case TIMER4D:
+				// connect pwm to pin on timer 4, channel D
+				sbi(TCCR4A, COM4D1);
+				OCR4D = val; // set pwm duty
+				break;
+			#endif
 
 			#if defined(TCCR5A) && defined(COM5A1)
 			case TIMER5A:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]