Skip to content

Commit 4cca5de

Browse files
committed
Merge remote-tracking branch 'adafruit/master'
2 parents c7c1748 + 516cec5 commit 4cca5de

File tree

25 files changed

+133
-21
lines changed

25 files changed

+133
-21
lines changed

cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_CDC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ size_t Adafruit_USBD_CDC::write(const uint8_t *buffer, size_t size)
126126
return size - remain;
127127
}
128128

129-
int Adafruit_USBD_CDC::availableForWrite(void)
129+
size_t Adafruit_USBD_CDC::availableForWrite(void)
130130
{
131131
return tud_cdc_write_available();
132132
}

cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_CDC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Adafruit_USBD_CDC : public Stream, Adafruit_USBD_Interface
5151
size_t write(const char *buffer, size_t size) {
5252
return write((const uint8_t *)buffer, size);
5353
}
54-
virtual int availableForWrite(void);
54+
virtual size_t availableForWrite(void);
5555
operator bool();
5656
};
5757

cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static int strcpy_uni16(const char *s, uint16_t *buf, int bufsize) {
254254
int i = 0;
255255
int buflen = 0;
256256

257-
while (i < bufsize) {
257+
while (s[i] != 0 && i < bufsize) {
258258
int unichar;
259259
int utf8len = utf8_to_unichar(s + i, &unichar);
260260

@@ -271,7 +271,6 @@ static int strcpy_uni16(const char *s, uint16_t *buf, int bufsize) {
271271
buf[buflen++] = unichar;
272272
}
273273

274-
buf[buflen] = '\0';
275274
return buflen;
276275
}
277276

cores/arduino/Print.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Print
5858

5959
// default to zero, meaning "a single write may block"
6060
// should be overriden by subclasses with buffering
61-
virtual int availableForWrite() { return 0; }
61+
virtual size_t availableForWrite() { return 0; }
6262

6363
size_t print(const __FlashStringHelper *);
6464
size_t print(const String &);

cores/arduino/USB/CDC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ int Serial_::available(void)
160160
return usb.available(CDC_ENDPOINT_OUT);
161161
}
162162

163-
int Serial_::availableForWrite(void)
163+
size_t Serial_::availableForWrite(void)
164164
{
165165
// return the number of bytes left in the current bank,
166166
// always EP size - 1, because bank is flushed on every write

cores/arduino/USB/USBAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Serial_ : public Stream
129129
void end(void);
130130

131131
virtual int available(void);
132-
virtual int availableForWrite(void);
132+
virtual size_t availableForWrite(void);
133133
virtual int peek(void);
134134
virtual int read(void);
135135
virtual void flush(void);

cores/arduino/Uart.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ int Uart::available()
131131
return rxBuffer.available();
132132
}
133133

134-
int Uart::availableForWrite()
134+
size_t Uart::availableForWrite()
135135
{
136136
return txBuffer.availableForStore();
137137
}

cores/arduino/Uart.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Uart : public HardwareSerial
3333
void begin(unsigned long baudrate, uint16_t config);
3434
void end();
3535
int available();
36-
int availableForWrite();
36+
size_t availableForWrite();
3737
int peek();
3838
int read();
3939
void flush();

libraries/SPI/SPI.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@
5252
// The datasheet specifies a typical SPI SCK period (tSCK) of 42 ns,
5353
// see "Table 36-48. SPI Timing Characteristics and Requirements",
5454
// which translates into a maximum SPI clock of 23.8 MHz.
55-
// Conservatively, the divider is set for a 12 MHz maximum SPI clock.
55+
// We'll permit use of 24 MHz SPI even though this is slightly out
56+
// of spec. Given how clock dividers work, the next "sensible"
57+
// threshold would be a substantial drop down to 12 MHz.
5658
#if !defined(MAX_SPI)
57-
#define MAX_SPI 12000000
59+
#define MAX_SPI 24000000
5860
#endif
5961
#define SPI_MIN_CLOCK_DIVIDER (uint8_t)(1 + ((F_CPU - 1) / MAX_SPI))
6062
#endif
@@ -81,7 +83,7 @@ class SPISettings {
8183
#if defined(__SAMD51__)
8284
this->clockFreq = clock; // Clipping handled in SERCOM.cpp
8385
#else
84-
this->clockFreq = (clock >= (MAX_SPI * 2 / SPI_MIN_CLOCK_DIVIDER) ? MAX_SPI * 2 / SPI_MIN_CLOCK_DIVIDER : clock);
86+
this->clockFreq = clock >= MAX_SPI ? MAX_SPI : clock;
8587
#endif
8688

8789
this->bitOrder = (bitOrder == MSBFIRST ? MSB_FIRST : LSB_FIRST);

libraries/Wire/Wire.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ void TwoWire::onService(void)
287287
void WIRE_IT_HANDLER(void) {
288288
Wire.onService();
289289
}
290+
291+
#if defined(__SAMD51__)
292+
void WIRE_IT_HANDLER_0(void) { Wire.onService(); }
293+
void WIRE_IT_HANDLER_1(void) { Wire.onService(); }
294+
void WIRE_IT_HANDLER_2(void) { Wire.onService(); }
295+
void WIRE_IT_HANDLER_3(void) { Wire.onService(); }
296+
#endif // __SAMD51__
290297
#endif
291298

292299
#if WIRE_INTERFACES_COUNT > 1
@@ -295,6 +302,13 @@ void TwoWire::onService(void)
295302
void WIRE1_IT_HANDLER(void) {
296303
Wire1.onService();
297304
}
305+
306+
#if defined(__SAMD51__)
307+
void WIRE1_IT_HANDLER_0(void) { Wire1.onService(); }
308+
void WIRE1_IT_HANDLER_1(void) { Wire1.onService(); }
309+
void WIRE1_IT_HANDLER_2(void) { Wire1.onService(); }
310+
void WIRE1_IT_HANDLER_3(void) { Wire1.onService(); }
311+
#endif // __SAMD51__
298312
#endif
299313

300314
#if WIRE_INTERFACES_COUNT > 2
@@ -303,6 +317,13 @@ void TwoWire::onService(void)
303317
void WIRE2_IT_HANDLER(void) {
304318
Wire2.onService();
305319
}
320+
321+
#if defined(__SAMD51__)
322+
void WIRE2_IT_HANDLER_0(void) { Wire2.onService(); }
323+
void WIRE2_IT_HANDLER_1(void) { Wire2.onService(); }
324+
void WIRE2_IT_HANDLER_2(void) { Wire2.onService(); }
325+
void WIRE2_IT_HANDLER_3(void) { Wire2.onService(); }
326+
#endif // __SAMD51__
306327
#endif
307328

308329
#if WIRE_INTERFACES_COUNT > 3
@@ -311,6 +332,13 @@ void TwoWire::onService(void)
311332
void WIRE3_IT_HANDLER(void) {
312333
Wire3.onService();
313334
}
335+
336+
#if defined(__SAMD51__)
337+
void WIRE3_IT_HANDLER_0(void) { Wire3.onService(); }
338+
void WIRE3_IT_HANDLER_1(void) { Wire3.onService(); }
339+
void WIRE3_IT_HANDLER_2(void) { Wire3.onService(); }
340+
void WIRE3_IT_HANDLER_3(void) { Wire3.onService(); }
341+
#endif // __SAMD51__
314342
#endif
315343

316344
#if WIRE_INTERFACES_COUNT > 4
@@ -319,6 +347,13 @@ void TwoWire::onService(void)
319347
void WIRE4_IT_HANDLER(void) {
320348
Wire4.onService();
321349
}
350+
351+
#if defined(__SAMD51__)
352+
void WIRE4_IT_HANDLER_0(void) { Wire4.onService(); }
353+
void WIRE4_IT_HANDLER_1(void) { Wire4.onService(); }
354+
void WIRE4_IT_HANDLER_2(void) { Wire4.onService(); }
355+
void WIRE4_IT_HANDLER_3(void) { Wire4.onService(); }
356+
#endif // __SAMD51__
322357
#endif
323358

324359
#if WIRE_INTERFACES_COUNT > 5
@@ -327,5 +362,12 @@ void TwoWire::onService(void)
327362
void WIRE5_IT_HANDLER(void) {
328363
Wire5.onService();
329364
}
365+
366+
#if defined(__SAMD51__)
367+
void WIRE5_IT_HANDLER_0(void) { Wire5.onService(); }
368+
void WIRE5_IT_HANDLER_1(void) { Wire5.onService(); }
369+
void WIRE5_IT_HANDLER_2(void) { Wire5.onService(); }
370+
void WIRE5_IT_HANDLER_3(void) { Wire5.onService(); }
371+
#endif // __SAMD51__
330372
#endif
331373

0 commit comments

Comments
 (0)