Skip to content

Commit 0169567

Browse files
committed
Pre-merge upstream Arduino
2 parents 65e4fc6 + daef7cd commit 0169567

File tree

9 files changed

+52
-41
lines changed

9 files changed

+52
-41
lines changed

hardware/arduino/avr/cores/arduino/Arduino.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extern "C"{
2020

2121
#define INPUT 0x0
2222
#define OUTPUT 0x1
23+
#define INPUT_PULLUP 0x2
2324

2425
#define true 0x1
2526
#define false 0x0

hardware/arduino/avr/cores/arduino/HardwareSerial.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
struct ring_buffer
4747
{
4848
unsigned char buffer[SERIAL_BUFFER_SIZE];
49-
volatile int head;
50-
volatile int tail;
49+
volatile unsigned int head;
50+
volatile unsigned int tail;
5151
};
5252

5353
#if defined(USBCON)

hardware/arduino/avr/cores/arduino/Print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ size_t Print::write(const uint8_t *buffer, size_t size)
4141

4242
size_t Print::print(const __FlashStringHelper *ifsh)
4343
{
44-
const prog_char *p = (const prog_char *)ifsh;
44+
const char PROGMEM *p = (const char PROGMEM *)ifsh;
4545
size_t n = 0;
4646
while (1) {
4747
unsigned char c = pgm_read_byte(p++);

hardware/arduino/avr/cores/arduino/Stream.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,25 +99,27 @@ bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t
9999
size_t index = 0; // maximum target string length is 64k bytes!
100100
size_t termIndex = 0;
101101
int c;
102-
102+
103103
if( *target == 0)
104-
return true; // return true if target is a null string
104+
return true; // return true if target is a null string
105105
while( (c = timedRead()) > 0){
106+
107+
if(c != target[index])
108+
index = 0; // reset index if any char does not match
109+
106110
if( c == target[index]){
107-
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
111+
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
108112
if(++index >= targetLen){ // return true if all chars in the target match
109113
return true;
110114
}
111115
}
112-
else{
113-
index = 0; // reset index if any char does not match
114-
}
116+
115117
if(termLen > 0 && c == terminator[termIndex]){
116-
if(++termIndex >= termLen)
117-
return false; // return false if terminate string found before target string
118+
if(++termIndex >= termLen)
119+
return false; // return false if terminate string found before target string
118120
}
119121
else
120-
termIndex = 0;
122+
termIndex = 0;
121123
}
122124
return false;
123125
}

hardware/arduino/avr/cores/arduino/WInterrupts.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#include "wiring_private.h"
3434

35-
volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
35+
static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
3636
// volatile static voidFuncPtr twiIntFunc;
3737

3838
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
@@ -121,8 +121,6 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
121121
#elif defined(MCUCR) && defined(ISC20) && defined(GIMSK) && defined(GIMSK)
122122
MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
123123
GIMSK |= (1 << INT2);
124-
#else
125-
#warning attachInterrupt may need some more work for this cpu (case 1)
126124
#endif
127125
break;
128126
#endif

hardware/arduino/avr/cores/arduino/WString.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ int String::lastIndexOf( char theChar ) const
500500

501501
int String::lastIndexOf(char ch, unsigned int fromIndex) const
502502
{
503-
if (fromIndex >= len || fromIndex < 0) return -1;
503+
if (fromIndex >= len) return -1;
504504
char tempchar = buffer[fromIndex + 1];
505505
buffer[fromIndex + 1] = '\0';
506506
char* temp = strrchr( buffer, ch );
@@ -516,7 +516,7 @@ int String::lastIndexOf(const String &s2) const
516516

517517
int String::lastIndexOf(const String &s2, unsigned int fromIndex) const
518518
{
519-
if (s2.len == 0 || len == 0 || s2.len > len || fromIndex < 0) return -1;
519+
if (s2.len == 0 || len == 0 || s2.len > len) return -1;
520520
if (fromIndex >= len) fromIndex = len - 1;
521521
int found = -1;
522522
for (char *p = buffer; p <= buffer + fromIndex; p++) {

hardware/arduino/avr/cores/arduino/wiring_analog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ int analogRead(uint8_t pin)
4545
if (pin >= 54) pin -= 54; // allow for channel or pin numbers
4646
#elif defined(__AVR_ATmega32U4__)
4747
if (pin >= 18) pin -= 18; // allow for channel or pin numbers
48+
#elif defined(__AVR_ATmega1284__)
49+
if (pin >= 24) pin -= 24; // allow for channel or pin numbers
4850
#else
4951
if (pin >= 14) pin -= 14; // allow for channel or pin numbers
5052
#endif

hardware/arduino/avr/cores/arduino/wiring_digital.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,25 @@ void pinMode(uint8_t pin, uint8_t mode)
3232
{
3333
uint8_t bit = digitalPinToBitMask(pin);
3434
uint8_t port = digitalPinToPort(pin);
35-
volatile uint8_t *reg;
35+
volatile uint8_t *reg, *out;
3636

3737
if (port == NOT_A_PIN) return;
3838

3939
// JWS: can I let the optimizer do this?
4040
reg = portModeRegister(port);
41+
out = portOutputRegister(port);
4142

4243
if (mode == INPUT) {
4344
uint8_t oldSREG = SREG;
4445
cli();
4546
*reg &= ~bit;
47+
*out &= ~bit;
48+
SREG = oldSREG;
49+
} else if (mode == INPUT_PULLUP) {
50+
uint8_t oldSREG = SREG;
51+
cli();
52+
*reg &= ~bit;
53+
*out |= bit;
4654
SREG = oldSREG;
4755
} else {
4856
uint8_t oldSREG = SREG;

hardware/arduino/avr/variants/mega/pins_arduino.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,31 @@
3232
#define analogInputToDigitalPin(p) ((p < 16) ? (p) + 54 : -1)
3333
#define digitalPinHasPWM(p) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46))
3434

35-
const static uint8_t SS = 53;
36-
const static uint8_t MOSI = 51;
37-
const static uint8_t MISO = 50;
38-
const static uint8_t SCK = 52;
35+
static const uint8_t SS = 53;
36+
static const uint8_t MOSI = 51;
37+
static const uint8_t MISO = 50;
38+
static const uint8_t SCK = 52;
3939

40-
const static uint8_t SDA = 20;
41-
const static uint8_t SCL = 21;
42-
const static uint8_t LED_BUILTIN = 13;
40+
static const uint8_t SDA = 20;
41+
static const uint8_t SCL = 21;
42+
static const uint8_t LED_BUILTIN = 13;
4343

44-
const static uint8_t A0 = 54;
45-
const static uint8_t A1 = 55;
46-
const static uint8_t A2 = 56;
47-
const static uint8_t A3 = 57;
48-
const static uint8_t A4 = 58;
49-
const static uint8_t A5 = 59;
50-
const static uint8_t A6 = 60;
51-
const static uint8_t A7 = 61;
52-
const static uint8_t A8 = 62;
53-
const static uint8_t A9 = 63;
54-
const static uint8_t A10 = 64;
55-
const static uint8_t A11 = 65;
56-
const static uint8_t A12 = 66;
57-
const static uint8_t A13 = 67;
58-
const static uint8_t A14 = 68;
59-
const static uint8_t A15 = 69;
44+
static const uint8_t A0 = 54;
45+
static const uint8_t A1 = 55;
46+
static const uint8_t A2 = 56;
47+
static const uint8_t A3 = 57;
48+
static const uint8_t A4 = 58;
49+
static const uint8_t A5 = 59;
50+
static const uint8_t A6 = 60;
51+
static const uint8_t A7 = 61;
52+
static const uint8_t A8 = 62;
53+
static const uint8_t A9 = 63;
54+
static const uint8_t A10 = 64;
55+
static const uint8_t A11 = 65;
56+
static const uint8_t A12 = 66;
57+
static const uint8_t A13 = 67;
58+
static const uint8_t A14 = 68;
59+
static const uint8_t A15 = 69;
6060

6161
// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins)
6262
// Only pins available for RECEIVE (TRANSMIT can be on any pin):

0 commit comments

Comments
 (0)