aboutsummaryrefslogtreecommitdiff
path: root/cores
diff options
context:
space:
mode:
authorZach Eveland <zeveland@blacklabel-development.com>2012-01-10 12:02:27 -0500
committerZach Eveland <zeveland@blacklabel-development.com>2012-01-10 12:02:27 -0500
commit989f672d345c71478102d9778d551c4637e88ab5 (patch)
treea194b4c486bf7e66827c6a343206be72df503047 /cores
parent28e9e122af24e63e84d5bcd2c619b76c490970fc (diff)
parentdd5bae59df6f1ba63083361ba284f364bc62b401 (diff)
Merge branch 'master' of github.com:arduino/Arduino into new-extension
Diffstat (limited to 'cores')
-rwxr-xr-xcores/arduino/Arduino.h1
-rw-r--r--cores/arduino/Stream.cpp20
-rw-r--r--cores/arduino/WInterrupts.c2
-rw-r--r--cores/arduino/WString.cpp4
-rw-r--r--cores/arduino/wiring_digital.c10
5 files changed, 24 insertions, 13 deletions
diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h
index bfec943..830c995 100755
--- a/cores/arduino/Arduino.h
+++ b/cores/arduino/Arduino.h
@@ -20,6 +20,7 @@ extern "C"{
#define INPUT 0x0
#define OUTPUT 0x1
+#define INPUT_PULLUP 0x2
#define true 0x1
#define false 0x0
diff --git a/cores/arduino/Stream.cpp b/cores/arduino/Stream.cpp
index 5fad8dd..3d5b905 100644
--- a/cores/arduino/Stream.cpp
+++ b/cores/arduino/Stream.cpp
@@ -99,25 +99,27 @@ bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t
size_t index = 0; // maximum target string length is 64k bytes!
size_t termIndex = 0;
int c;
-
+
if( *target == 0)
- return true; // return true if target is a null string
+ return true; // return true if target is a null string
while( (c = timedRead()) > 0){
+
+ if(c != target[index])
+ index = 0; // reset index if any char does not match
+
if( c == target[index]){
- //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
+ //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
if(++index >= targetLen){ // return true if all chars in the target match
return true;
}
}
- else{
- index = 0; // reset index if any char does not match
- }
+
if(termLen > 0 && c == terminator[termIndex]){
- if(++termIndex >= termLen)
- return false; // return false if terminate string found before target string
+ if(++termIndex >= termLen)
+ return false; // return false if terminate string found before target string
}
else
- termIndex = 0;
+ termIndex = 0;
}
return false;
}
diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c
index 2ec72a5..3c852ed 100644
--- a/cores/arduino/WInterrupts.c
+++ b/cores/arduino/WInterrupts.c
@@ -32,7 +32,7 @@
#include "wiring_private.h"
-volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
+static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
// volatile static voidFuncPtr twiIntFunc;
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp
index 3e81331..c6839fc 100644
--- a/cores/arduino/WString.cpp
+++ b/cores/arduino/WString.cpp
@@ -500,7 +500,7 @@ int String::lastIndexOf( char theChar ) const
int String::lastIndexOf(char ch, unsigned int fromIndex) const
{
- if (fromIndex >= len || fromIndex < 0) return -1;
+ if (fromIndex >= len) return -1;
char tempchar = buffer[fromIndex + 1];
buffer[fromIndex + 1] = '\0';
char* temp = strrchr( buffer, ch );
@@ -516,7 +516,7 @@ int String::lastIndexOf(const String &s2) const
int String::lastIndexOf(const String &s2, unsigned int fromIndex) const
{
- if (s2.len == 0 || len == 0 || s2.len > len || fromIndex < 0) return -1;
+ if (s2.len == 0 || len == 0 || s2.len > len) return -1;
if (fromIndex >= len) fromIndex = len - 1;
int found = -1;
for (char *p = buffer; p <= buffer + fromIndex; p++) {
diff --git a/cores/arduino/wiring_digital.c b/cores/arduino/wiring_digital.c
index 75f850e..be323b1 100644
--- a/cores/arduino/wiring_digital.c
+++ b/cores/arduino/wiring_digital.c
@@ -32,17 +32,25 @@ void pinMode(uint8_t pin, uint8_t mode)
{
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
- volatile uint8_t *reg;
+ volatile uint8_t *reg, *out;
if (port == NOT_A_PIN) return;
// JWS: can I let the optimizer do this?
reg = portModeRegister(port);
+ out = portOutputRegister(port);
if (mode == INPUT) {
uint8_t oldSREG = SREG;
cli();
*reg &= ~bit;
+ *out &= ~bit;
+ SREG = oldSREG;
+ } else if (mode == INPUT_PULLUP) {
+ uint8_t oldSREG = SREG;
+ cli();
+ *reg &= ~bit;
+ *out |= bit;
SREG = oldSREG;
} else {
uint8_t oldSREG = SREG;