Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 28, 2012
Paul Brook External interrupt hacks for atmega32u2
Apply 32u4 external interrput hacks to 32u2

Signed-off-by: Paul Brook <paul@codesourcery.com>
eeeec21
Paul Brook PWM Timer support
Implement digitalPinToTimer for PWM output pins.

Signed-off-by: Paul Brook <paul@codesourcery.com>
70c4a46
Showing with 29 additions and 30 deletions.
  1. +3 −3 cores/minimus/WInterrupts.c
  2. +26 −27 variants/minimus32/pins_arduino.h
View
6 cores/minimus/WInterrupts.c
@@ -47,7 +47,7 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
// Enable the interrupt.
switch (interruptNum) {
-#if defined(__AVR_ATmega32U4__)
+#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__)
// I hate doing this, but the register assignment differs between the 1280/2560
// and the 32U4. Since avrlib defines registers PCMSK1 and PCMSK2 that aren't
// even present on the 32U4 this is the only way to distinguish between them.
@@ -146,7 +146,7 @@ void detachInterrupt(uint8_t interruptNum) {
// to the number of the EIMSK bit to clear, as this isn't true on the
// ATmega8. There, INT0 is 6 and INT1 is 7.)
switch (interruptNum) {
-#if defined(__AVR_ATmega32U4__)
+#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__)
case 0:
EIMSK &= ~(1<<INT0);
break;
@@ -215,7 +215,7 @@ void attachInterruptTwi(void (*userFunc)(void) ) {
}
*/
-#if defined(__AVR_ATmega32U4__)
+#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__)
SIGNAL(INT0_vect) {
if(intFunc[EXTERNAL_INT_0])
intFunc[EXTERNAL_INT_0]();
View
53 variants/minimus32/pins_arduino.h
@@ -55,10 +55,6 @@ extern const uint8_t PROGMEM pin_to_pcint_PGM[24];
#define analogPinToChannel(P) ( -1 )
-// FIXME We do have timers for some pins
-#undef digitalPinToTimer
-#define digitalPinToTimer(P) (NOT_ON_TIMER)
-
#ifdef ARDUINO_MAIN
// On the Arduino board, digital pins are also used
@@ -70,7 +66,7 @@ extern const uint8_t PROGMEM pin_to_pcint_PGM[24];
// Pins numbered counter-clockwise starting from USB connector
//
// D0 PC2 PCINT11
-// D1 PD0
+// D1# PD0 OC0B
// D2 PD1
// D3 PD2 RX
// D4 PD3 TX
@@ -87,11 +83,11 @@ extern const uint8_t PROGMEM pin_to_pcint_PGM[24];
// D14 PB4 PCINT4
// D15 PB5 PCINT5
// D16 PB6 PCINT6
-// D17 PB7 PCINT7
+// D17# PB7 PCINT7/OC0A/OC1C
// D18 PC7
-// D19 PC6 PCINT8
+// D19# PC6 PCINT8/OC1A
// [D20] !RESET
-// D21 PC5 PCINT9
+// D21# PC5 PCINT9/OC1B
// D22 PC4 PCINT10
// [D23] VCC
@@ -203,30 +199,33 @@ const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[24] = {
0, // VCC
};
-#if 0
-// FIXME: needs updating
-const uint8_t PROGMEM digital_pin_to_timer_PGM[16] = {
- NOT_ON_TIMER,
+const uint8_t PROGMEM digital_pin_to_timer_PGM[24] = {
+ NOT_ON_TIMER,
+ TIMER0B, /* 1 */
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ TIMER0A, /* 17 */
NOT_ON_TIMER,
+ TIMER1A, /* 18 */
NOT_ON_TIMER,
- TIMER0B, /* 3 */
+ TIMER1B, /* 19 */
NOT_ON_TIMER,
- TIMER3A, /* 5 */
- TIMER4D, /* 6 */
- NOT_ON_TIMER,
-
- NOT_ON_TIMER,
- TIMER1A, /* 9 */
- TIMER1B, /* 10 */
- TIMER0A, /* 11 */
-
- NOT_ON_TIMER,
- TIMER4A, /* 13 */
-
- NOT_ON_TIMER,
NOT_ON_TIMER,
};
-#endif
#endif /* ARDUINO_MAIN */
#endif /* Pins_Arduino_h */

No commit comments for this range

Something went wrong with that request. Please try again.