From d3fa070d10331727b9094b4976a94a8143dcba30 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 21 Oct 2011 11:54:11 -0400 Subject: Lowering timer 1 prescale factor (to 8 from 64) for F_CPU less than 8 MHz. Otherwise, you can see flicker on an LED. --- cores/arduino/wiring.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cores/arduino/wiring.c b/cores/arduino/wiring.c index 1b3fd44..bc01949 100755 --- a/cores/arduino/wiring.c +++ b/cores/arduino/wiring.c @@ -221,10 +221,14 @@ void init() // set timer 1 prescale factor to 64 sbi(TCCR1B, CS11); +#if F_CPU >= 8000000L sbi(TCCR1B, CS10); +#endif #elif defined(TCCR1) && defined(CS11) && defined(CS10) sbi(TCCR1, CS11); +#if F_CPU >= 8000000L sbi(TCCR1, CS10); +#endif #endif // put timer 1 in 8-bit phase correct pwm mode #if defined(TCCR1A) && defined(WGM10) -- cgit v1.2.3-18-g5258 From 85f10a7150726e58a4e24358edf978241a777048 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Mon, 24 Oct 2011 15:44:01 -0400 Subject: Correcting analogReference() constants for ATtiny24/44/84 and 25/45/85. DEFAULT, EXTERNAL, and INTERNAL have different values on those processors. --- cores/arduino/Arduino.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index 7f2fc05..07216f9 100755 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -40,6 +40,11 @@ extern "C"{ #define FALLING 2 #define RISING 3 +#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) +#define DEFAULT 0 +#define EXTERNAL 1 +#define INTERNAL 2 +#else #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define INTERNAL1V1 2 #define INTERNAL2V56 3 @@ -48,6 +53,7 @@ extern "C"{ #endif #define DEFAULT 1 #define EXTERNAL 0 +#endif // undefine stdlib's abs if encountered #ifdef abs -- cgit v1.2.3-18-g5258 From 85d70c4314bc38b736b6d88adcec6dadf43a0dba Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Mon, 24 Oct 2011 16:45:44 -0400 Subject: Renaming LED to LED_BUILTIN. http://code.google.com/p/arduino/issues/detail?id=651 --- variants/mega/pins_arduino.h | 2 +- variants/standard/pins_arduino.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/variants/mega/pins_arduino.h b/variants/mega/pins_arduino.h index 237173a..57ec97f 100644 --- a/variants/mega/pins_arduino.h +++ b/variants/mega/pins_arduino.h @@ -39,7 +39,7 @@ const static uint8_t SCK = 52; const static uint8_t SDA = 20; const static uint8_t SCL = 21; -const static uint8_t LED = 13; +const static uint8_t LED_BUILTIN = 13; const static uint8_t A0 = 54; const static uint8_t A1 = 55; diff --git a/variants/standard/pins_arduino.h b/variants/standard/pins_arduino.h index 3999d1f..6e774d4 100644 --- a/variants/standard/pins_arduino.h +++ b/variants/standard/pins_arduino.h @@ -44,7 +44,7 @@ const static uint8_t SCK = 13; const static uint8_t SDA = 18; const static uint8_t SCL = 19; -const static uint8_t LED = 13; +const static uint8_t LED_BUILTIN = 13; const static uint8_t A0 = 14; const static uint8_t A1 = 15; -- cgit v1.2.3-18-g5258 From 8d48010edfd3a031045bc510c7bcd651cf30c6f8 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Mon, 24 Oct 2011 16:50:15 -0400 Subject: Moving ARDUINO_MAIN from main.cpp to wiring_digital.c and hiding PA, PB, etc. http://code.google.com/p/arduino/issues/detail?id=677 http://code.google.com/p/arduino/issues/detail?id=691 --- cores/arduino/Arduino.h | 2 ++ cores/arduino/main.cpp | 1 - cores/arduino/wiring_digital.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index 07216f9..ebd374a 100755 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -148,6 +148,7 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[]; #define NOT_A_PIN 0 #define NOT_A_PORT 0 +#ifdef ARDUINO_MAIN #define PA 1 #define PB 2 #define PC 3 @@ -159,6 +160,7 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[]; #define PJ 10 #define PK 11 #define PL 12 +#endif #define NOT_ON_TIMER 0 #define TIMER0A 1 diff --git a/cores/arduino/main.cpp b/cores/arduino/main.cpp index 0ef5256..34450f4 100755 --- a/cores/arduino/main.cpp +++ b/cores/arduino/main.cpp @@ -1,4 +1,3 @@ -#define ARDUINO_MAIN #include int main(void) diff --git a/cores/arduino/wiring_digital.c b/cores/arduino/wiring_digital.c index dd1b949..97ef134 100755 --- a/cores/arduino/wiring_digital.c +++ b/cores/arduino/wiring_digital.c @@ -24,6 +24,7 @@ $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ */ +#define ARDUINO_MAIN #include "wiring_private.h" #include "pins_arduino.h" -- cgit v1.2.3-18-g5258 From 5c9d10ad9484c26eb94d2030628b676f8d0d5fc7 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Tue, 25 Oct 2011 11:15:14 -0400 Subject: Bug fix in replace(). http://code.google.com/p/arduino/issues/detail?id=694 --- cores/arduino/WString.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index ad8d828..3e81331 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -593,7 +593,7 @@ void String::replace(const String& find, const String& replace) if (size == len) return; if (size > capacity && !changeBuffer(size)) return; // XXX: tell user! int index = len - 1; - while ((index = lastIndexOf(find, index)) >= 0) { + while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) { readFrom = buffer + index + find.len; memmove(readFrom + diff, readFrom, len - (readFrom - buffer)); len += diff; -- cgit v1.2.3-18-g5258