Skip to content

Commit 516cec5

Browse files
committed
Merge branch 'master' of github.com:adafruit/ArduinoCore-samd
2 parents 6630fe7 + 5f68c65 commit 516cec5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

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);

0 commit comments

Comments
 (0)