Skip to content

Commit 0f17a97

Browse files
committed
Merge branch 'new-extension' of github.com:arduino/Arduino into diskloader_reboot
Conflicts: hardware/arduino/variants/mega/pins_arduino.h libraries/Ethernet/examples/PachubeClient/PachubeClient.ino libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino
2 parents e97d3ad + a7ce446 commit 0f17a97

File tree

6 files changed

+77
-167
lines changed

6 files changed

+77
-167
lines changed

hardware/arduino/cores/arduino/Arduino.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ extern "C"{
4040
#define FALLING 2
4141
#define RISING 3
4242

43+
#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
44+
#define DEFAULT 0
45+
#define EXTERNAL 1
46+
#define INTERNAL 2
47+
#else
4348
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
4449
#define INTERNAL1V1 2
4550
#define INTERNAL2V56 3
@@ -48,6 +53,7 @@ extern "C"{
4853
#endif
4954
#define DEFAULT 1
5055
#define EXTERNAL 0
56+
#endif
5157

5258
// undefine stdlib's abs if encountered
5359
#ifdef abs
@@ -142,6 +148,7 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
142148
#define NOT_A_PIN 0
143149
#define NOT_A_PORT 0
144150

151+
#ifdef ARDUINO_MAIN
145152
#define PA 1
146153
#define PB 2
147154
#define PC 3
@@ -153,6 +160,7 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
153160
#define PJ 10
154161
#define PK 11
155162
#define PL 12
163+
#endif
156164

157165
#define NOT_ON_TIMER 0
158166
#define TIMER0A 1

hardware/arduino/cores/arduino/WString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ void String::replace(const String& find, const String& replace)
593593
if (size == len) return;
594594
if (size > capacity && !changeBuffer(size)) return; // XXX: tell user!
595595
int index = len - 1;
596-
while ((index = lastIndexOf(find, index)) >= 0) {
596+
while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
597597
readFrom = buffer + index + find.len;
598598
memmove(readFrom + diff, readFrom, len - (readFrom - buffer));
599599
len += diff;

hardware/arduino/cores/arduino/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define ARDUINO_MAIN
21
#include <Arduino.h>
32

43
int main(void)

hardware/arduino/cores/arduino/wiring.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,14 @@ void init()
221221

222222
// set timer 1 prescale factor to 64
223223
sbi(TCCR1B, CS11);
224+
#if F_CPU >= 8000000L
224225
sbi(TCCR1B, CS10);
226+
#endif
225227
#elif defined(TCCR1) && defined(CS11) && defined(CS10)
226228
sbi(TCCR1, CS11);
229+
#if F_CPU >= 8000000L
227230
sbi(TCCR1, CS10);
231+
#endif
228232
#endif
229233
// put timer 1 in 8-bit phase correct pwm mode
230234
#if defined(TCCR1A) && defined(WGM10)

hardware/arduino/cores/arduino/wiring_digital.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
2525
*/
2626

27+
#define ARDUINO_MAIN
2728
#include "wiring_private.h"
2829
#include "pins_arduino.h"
2930

hardware/arduino/variants/mega/pins_arduino.h

100755100644
Lines changed: 63 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
pins_arduino.c - pin definitions for the Arduino board
3-
Part of Arduino / Wiring Lite
2+
pins_arduino.h - Pin definition functions for Arduino
3+
Part of Arduino - http://www.arduino.cc/
44
5-
Copyright (c) 2005 David A. Mellis
5+
Copyright (c) 2007 David A. Mellis
66
77
This library is free software; you can redistribute it and/or
88
modify it under the terms of the GNU Lesser General Public
@@ -19,66 +19,72 @@
1919
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
2020
Boston, MA 02111-1307 USA
2121
22-
$Id$
22+
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
2323
*/
2424

25-
#include <avr/io.h>
26-
#include "wiring_private.h"
27-
#include "pins_arduino.h"
25+
#ifndef Pins_Arduino_h
26+
#define Pins_Arduino_h
2827

29-
// On the Arduino board, digital pins are also used
30-
// for the analog output (software PWM). Analog input
31-
// pins are a separate set.
28+
#include <avr/pgmspace.h>
3229

33-
// ATMEL ATMEGA8 & 168 / ARDUINO
34-
//
35-
// +-\/-+
36-
// PC6 1| |28 PC5 (AI 5)
37-
// (D 0) PD0 2| |27 PC4 (AI 4)
38-
// (D 1) PD1 3| |26 PC3 (AI 3)
39-
// (D 2) PD2 4| |25 PC2 (AI 2)
40-
// PWM+ (D 3) PD3 5| |24 PC1 (AI 1)
41-
// (D 4) PD4 6| |23 PC0 (AI 0)
42-
// VCC 7| |22 GND
43-
// GND 8| |21 AREF
44-
// PB6 9| |20 AVCC
45-
// PB7 10| |19 PB5 (D 13)
46-
// PWM+ (D 5) PD5 11| |18 PB4 (D 12)
47-
// PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM
48-
// (D 7) PD7 13| |16 PB2 (D 10) PWM
49-
// (D 8) PB0 14| |15 PB1 (D 9) PWM
50-
// +----+
51-
//
52-
// (PWM+ indicates the additional PWM pins on the ATmega168.)
30+
#define NUM_DIGITAL_PINS 70
31+
#define NUM_ANALOG_INPUTS 16
32+
#define analogInputToDigitalPin(p) ((p < 16) ? (p) + 54 : -1)
33+
#define digitalPinHasPWM(p) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46))
5334

54-
// ATMEL ATMEGA1280 / ARDUINO
55-
//
56-
// 0-7 PE0-PE7 works
57-
// 8-13 PB0-PB5 works
58-
// 14-21 PA0-PA7 works
59-
// 22-29 PH0-PH7 works
60-
// 30-35 PG5-PG0 works
61-
// 36-43 PC7-PC0 works
62-
// 44-51 PJ7-PJ0 works
63-
// 52-59 PL7-PL0 works
64-
// 60-67 PD7-PD0 works
65-
// A0-A7 PF0-PF7
66-
// A8-A15 PK0-PK7
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;
6739

68-
#define PA 1
69-
#define PB 2
70-
#define PC 3
71-
#define PD 4
72-
#define PE 5
73-
#define PF 6
74-
#define PG 7
75-
#define PH 8
76-
#define PJ 10
77-
#define PK 11
78-
#define PL 12
40+
const static uint8_t SDA = 20;
41+
const static uint8_t SCL = 21;
42+
const static uint8_t LED_BUILTIN = 13;
7943

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;
60+
61+
// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins)
62+
// Only pins available for RECEIVE (TRANSMIT can be on any pin):
63+
// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me)
64+
// Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
65+
66+
#define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \
67+
(((p) >= 50) && ((p) <= 53)) || \
68+
(((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )
69+
70+
#define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \
71+
( (((p) >= 62) && ((p) <= 69)) ? 2 : \
72+
0 ) )
73+
74+
#define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \
75+
( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \
76+
((uint8_t *)0) ) )
77+
78+
#define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \
79+
( ((p) == 50) ? 3 : \
80+
( ((p) == 51) ? 2 : \
81+
( ((p) == 52) ? 1 : \
82+
( ((p) == 53) ? 0 : \
83+
( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \
84+
0 ) ) ) ) ) )
85+
86+
#ifdef ARDUINO_MAIN
8087

81-
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
8288
const uint16_t PROGMEM port_to_mode_PGM[] = {
8389
NOT_A_PORT,
8490
(uint16_t) &DDRA,
@@ -351,115 +357,7 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
351357
NOT_ON_TIMER , // PK 6 ** 68 ** A14
352358
NOT_ON_TIMER , // PK 7 ** 69 ** A15
353359
};
354-
#else
355-
// these arrays map port names (e.g. port B) to the
356-
// appropriate addresses for various functions (e.g. reading
357-
// and writing)
358-
const uint16_t PROGMEM port_to_mode_PGM[] = {
359-
NOT_A_PORT,
360-
NOT_A_PORT,
361-
(uint16_t) &DDRB,
362-
(uint16_t) &DDRC,
363-
(uint16_t) &DDRD,
364-
};
365-
366-
const uint16_t PROGMEM port_to_output_PGM[] = {
367-
NOT_A_PORT,
368-
NOT_A_PORT,
369-
(uint16_t) &PORTB,
370-
(uint16_t) &PORTC,
371-
(uint16_t) &PORTD,
372-
};
373360

374-
const uint16_t PROGMEM port_to_input_PGM[] = {
375-
NOT_A_PORT,
376-
NOT_A_PORT,
377-
(uint16_t) &PINB,
378-
(uint16_t) &PINC,
379-
(uint16_t) &PIND,
380-
};
381-
382-
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
383-
PD, /* 0 */
384-
PD,
385-
PD,
386-
PD,
387-
PD,
388-
PD,
389-
PD,
390-
PD,
391-
PB, /* 8 */
392-
PB,
393-
PB,
394-
PB,
395-
PB,
396-
PB,
397-
PC, /* 14 */
398-
PC,
399-
PC,
400-
PC,
401-
PC,
402-
PC,
403-
};
404-
405-
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
406-
_BV(0), /* 0, port D */
407-
_BV(1),
408-
_BV(2),
409-
_BV(3),
410-
_BV(4),
411-
_BV(5),
412-
_BV(6),
413-
_BV(7),
414-
_BV(0), /* 8, port B */
415-
_BV(1),
416-
_BV(2),
417-
_BV(3),
418-
_BV(4),
419-
_BV(5),
420-
_BV(0), /* 14, port C */
421-
_BV(1),
422-
_BV(2),
423-
_BV(3),
424-
_BV(4),
425-
_BV(5),
426-
};
427-
428-
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
429-
NOT_ON_TIMER, /* 0 - port D */
430-
NOT_ON_TIMER,
431-
NOT_ON_TIMER,
432-
// on the ATmega168, digital pin 3 has hardware pwm
433-
#if defined(__AVR_ATmega8__)
434-
NOT_ON_TIMER,
435-
#else
436-
TIMER2B,
437-
#endif
438-
NOT_ON_TIMER,
439-
// on the ATmega168, digital pins 5 and 6 have hardware pwm
440-
#if defined(__AVR_ATmega8__)
441-
NOT_ON_TIMER,
442-
NOT_ON_TIMER,
443-
#else
444-
TIMER0B,
445-
TIMER0A,
446-
#endif
447-
NOT_ON_TIMER,
448-
NOT_ON_TIMER, /* 8 - port B */
449-
TIMER1A,
450-
TIMER1B,
451-
#if defined(__AVR_ATmega8__)
452-
TIMER2,
453-
#else
454-
TIMER2A,
455-
#endif
456-
NOT_ON_TIMER,
457-
NOT_ON_TIMER,
458-
NOT_ON_TIMER,
459-
NOT_ON_TIMER, /* 14 - port C */
460-
NOT_ON_TIMER,
461-
NOT_ON_TIMER,
462-
NOT_ON_TIMER,
463-
NOT_ON_TIMER,
464-
};
465361
#endif
362+
363+
#endif

0 commit comments

Comments
 (0)