aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
Diffstat (limited to 'cores/arduino')
-rwxr-xr-xcores/arduino/Arduino.h8
-rw-r--r--cores/arduino/WString.cpp2
-rwxr-xr-xcores/arduino/main.cpp1
-rwxr-xr-xcores/arduino/wiring.c4
-rwxr-xr-xcores/arduino/wiring_digital.c1
5 files changed, 14 insertions, 2 deletions
diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h
index 7f2fc05..ebd374a 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
@@ -142,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
@@ -153,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/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;
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 <Arduino.h>
int main(void)
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,11 +221,15 @@ 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)
sbi(TCCR1A, WGM10);
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"