Skip to content

Commit 037020e

Browse files
committed
Merged latest changes in AVR arduino core
1 parent 6a45ba4 commit 037020e

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

Diff for: cores/arduino/CDC.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,22 @@ void Serial_::end(void)
141141
void Serial_::accept(void)
142142
{
143143
ring_buffer *buffer = &cdc_rx_buffer;
144-
int c = USB_Recv(CDC_RX);
145144
int i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE;
146145

147146
// if we should be storing the received character into the location
148147
// just before the tail (meaning that the head would advance to the
149148
// current location of the tail), we're about to overflow the buffer
150149
// and so we don't write the character or advance the head.
151-
if (i != buffer->tail) {
150+
151+
// while we have room to store a byte
152+
while (i != buffer->tail) {
153+
int c = USB_Recv(CDC_RX);
154+
if (c == -1)
155+
break; // no more data
152156
buffer->buffer[buffer->head] = c;
153157
buffer->head = i;
158+
159+
i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE;
154160
}
155161
}
156162

Diff for: cores/arduino/Print.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ size_t Print::printFloat(double number, uint8_t digits)
228228

229229
if (isnan(number)) return print("nan");
230230
if (isinf(number)) return print("inf");
231+
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
232+
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
231233

232234
// Handle negative numbers
233235
if (number < 0.0)

Diff for: cores/arduino/Tone.cpp

+23-8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Version Modified By Date Comments
2929
09/11/25 Fixed timer0 from being excluded
3030
0006 D Mellis 09/12/29 Replaced objects with functions
3131
0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register
32+
0008 S Kanemoto 12/06/22 Fixed for Leonardo by @maris_HY
3233
*************************************************/
3334

3435
#include <avr/interrupt.h>
@@ -85,24 +86,34 @@ volatile uint8_t timer5_pin_mask;
8586
#endif
8687

8788

88-
// MLS: This does not make sense, the 3 options are the same
8989
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
9090

9191
#define AVAILABLE_TONE_PINS 1
92+
#define USE_TIMER2
9293

9394
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
9495
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
9596

9697
#elif defined(__AVR_ATmega8__)
9798

9899
#define AVAILABLE_TONE_PINS 1
100+
#define USE_TIMER2
99101

100102
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
101103
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
102104

105+
#elif defined(__AVR_ATmega32U4__)
106+
107+
#define AVAILABLE_TONE_PINS 1
108+
#define USE_TIMER3
109+
110+
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 3 /*, 1 */ };
111+
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
112+
103113
#else
104114

105115
#define AVAILABLE_TONE_PINS 1
116+
#define USE_TIMER2
106117

107118
// Leave timer 0 to last.
108119
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
@@ -480,8 +491,7 @@ void noTone(uint8_t _pin)
480491
digitalWrite(_pin, 0);
481492
}
482493

483-
#if 0
484-
#if !defined(__AVR_ATmega8__)
494+
#ifdef USE_TIMER0
485495
ISR(TIMER0_COMPA_vect)
486496
{
487497
if (timer0_toggle_count != 0)
@@ -501,6 +511,7 @@ ISR(TIMER0_COMPA_vect)
501511
#endif
502512

503513

514+
#ifdef USE_TIMER1
504515
ISR(TIMER1_COMPA_vect)
505516
{
506517
if (timer1_toggle_count != 0)
@@ -520,6 +531,7 @@ ISR(TIMER1_COMPA_vect)
520531
#endif
521532

522533

534+
#ifdef USE_TIMER2
523535
ISR(TIMER2_COMPA_vect)
524536
{
525537

@@ -541,12 +553,10 @@ ISR(TIMER2_COMPA_vect)
541553
// *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop
542554
}
543555
}
556+
#endif
544557

545558

546-
547-
//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
548-
#if 0
549-
559+
#ifdef USE_TIMER3
550560
ISR(TIMER3_COMPA_vect)
551561
{
552562
if (timer3_toggle_count != 0)
@@ -563,7 +573,10 @@ ISR(TIMER3_COMPA_vect)
563573
*timer3_pin_port &= ~(timer3_pin_mask); // keep pin low after stop
564574
}
565575
}
576+
#endif
577+
566578

579+
#ifdef USE_TIMER4
567580
ISR(TIMER4_COMPA_vect)
568581
{
569582
if (timer4_toggle_count != 0)
@@ -580,7 +593,10 @@ ISR(TIMER4_COMPA_vect)
580593
*timer4_pin_port &= ~(timer4_pin_mask); // keep pin low after stop
581594
}
582595
}
596+
#endif
583597

598+
599+
#ifdef USE_TIMER5
584600
ISR(TIMER5_COMPA_vect)
585601
{
586602
if (timer5_toggle_count != 0)
@@ -597,5 +613,4 @@ ISR(TIMER5_COMPA_vect)
597613
*timer5_pin_port &= ~(timer5_pin_mask); // keep pin low after stop
598614
}
599615
}
600-
601616
#endif

Diff for: cores/arduino/WString.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
// -std=c++0x
3636

3737
class __FlashStringHelper;
38-
#define F(string_literal) (reinterpret_cast<__FlashStringHelper *>(PSTR(string_literal)))
38+
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
3939

4040
// An inherited class for holding the result of a concatenation. These
4141
// result objects are assumed to be writable by subsequent concatenations.

0 commit comments

Comments
 (0)