Skip to content

Commit f166b56

Browse files
authored
Teensyduino 1.58 Compatibility (#31)
* Teensyduino 1.58 Compatibility * Update CI software versions Avoiding the 2.0 IDE until it's more stable * Update Teensyduino version in README
1 parent 5fdfedf commit f166b56

File tree

9 files changed

+54
-23
lines changed

9 files changed

+54
-23
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request, workflow_dispatch]
44

55
env:
66
IDE_VERSION: 1.8.19
7-
TEENSY_VERSION: 157
7+
TEENSY_VERSION: 158
88
IDE_LOCATION: /usr/local/share/arduino
99

1010
jobs:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This is meant to be used in conjunction with the [ArduinoXInput library](https:/
66

77
## Installation
88

9-
You must have both [Arduino](https://www.arduino.cc/en/main/software) and [Teensyduino](https://www.pjrc.com/teensy/td_download.html) installed before proceeding. Double-check that your installed Teensyduino version matches the files provided in this repository. This repository is currently using version [**1.57**](https://www.pjrc.com/teensy/td_157). If you don't know your Teensyduino version, compile a blank sketch with a Teensy board selected and the Teensy Loader will open. In the Teensy Loader window select `Help -> About` and it will tell you the version number. If your version does not match you will have to reinstall or update the Teensyduino software.
9+
You must have both [Arduino](https://www.arduino.cc/en/main/software) and [Teensyduino](https://www.pjrc.com/teensy/td_download.html) installed before proceeding. Double-check that your installed Teensyduino version matches the files provided in this repository. This repository is currently using version [**1.58**](https://www.pjrc.com/teensy/td_158). If you don't know your Teensyduino version, compile a blank sketch with a Teensy board selected and the Teensy Loader will open. In the Teensy Loader window select `Help -> About` and it will tell you the version number. If your version does not match you will have to reinstall or update the Teensyduino software.
1010

1111
Navigate to your Arduino installation directory and open up the 'hardware' folder. It is recommended that you make a backup of this folder before proceeding in case something goes wrong or if you want to revert the installation.
1212

teensy/avr/boards.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ teensy41.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
4141
teensy41.build.flags.dep=-MMD
4242
teensy41.build.flags.optimize=-Os
4343
teensy41.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
44-
teensy41.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=157
44+
teensy41.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=158
4545
teensy41.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
4646
teensy41.build.flags.c=
4747
teensy41.build.flags.S=-x assembler-with-cpp
@@ -271,7 +271,7 @@ teensyMM.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
271271
teensyMM.build.flags.dep=-MMD
272272
teensyMM.build.flags.optimize=-Os
273273
teensyMM.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
274-
teensyMM.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=157
274+
teensyMM.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=158
275275
teensyMM.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
276276
teensyMM.build.flags.c=
277277
teensyMM.build.flags.S=-x assembler-with-cpp
@@ -501,7 +501,7 @@ teensy40.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
501501
teensy40.build.flags.dep=-MMD
502502
teensy40.build.flags.optimize=-Os
503503
teensy40.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
504-
teensy40.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=157
504+
teensy40.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=158
505505
teensy40.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
506506
teensy40.build.flags.c=
507507
teensy40.build.flags.S=-x assembler-with-cpp
@@ -727,7 +727,7 @@ teensy36.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
727727
teensy36.build.flags.dep=-MMD
728728
teensy36.build.flags.optimize=-Os
729729
teensy36.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
730-
teensy36.build.flags.defs=-D__MK66FX1M0__ -DTEENSYDUINO=157
730+
teensy36.build.flags.defs=-D__MK66FX1M0__ -DTEENSYDUINO=158
731731
teensy36.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
732732
teensy36.build.flags.c=
733733
teensy36.build.flags.S=-x assembler-with-cpp
@@ -967,7 +967,7 @@ teensy35.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
967967
teensy35.build.flags.dep=-MMD
968968
teensy35.build.flags.optimize=-Os
969969
teensy35.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
970-
teensy35.build.flags.defs=-D__MK64FX512__ -DTEENSYDUINO=157
970+
teensy35.build.flags.defs=-D__MK64FX512__ -DTEENSYDUINO=158
971971
teensy35.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
972972
teensy35.build.flags.c=
973973
teensy35.build.flags.S=-x assembler-with-cpp
@@ -1198,7 +1198,7 @@ teensy31.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
11981198
teensy31.build.flags.dep=-MMD
11991199
teensy31.build.flags.optimize=-Os
12001200
teensy31.build.flags.cpu=-mthumb -mcpu=cortex-m4 -fsingle-precision-constant
1201-
teensy31.build.flags.defs=-D__MK20DX256__ -DTEENSYDUINO=157
1201+
teensy31.build.flags.defs=-D__MK20DX256__ -DTEENSYDUINO=158
12021202
teensy31.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
12031203
teensy31.build.flags.c=
12041204
teensy31.build.flags.S=-x assembler-with-cpp
@@ -1439,7 +1439,7 @@ teensy30.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
14391439
teensy30.build.flags.dep=-MMD
14401440
teensy30.build.flags.optimize=-Os
14411441
teensy30.build.flags.cpu=-mthumb -mcpu=cortex-m4 -fsingle-precision-constant
1442-
teensy30.build.flags.defs=-D__MK20DX128__ -DTEENSYDUINO=157
1442+
teensy30.build.flags.defs=-D__MK20DX128__ -DTEENSYDUINO=158
14431443
teensy30.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
14441444
teensy30.build.flags.c=
14451445
teensy30.build.flags.S=-x assembler-with-cpp
@@ -1615,7 +1615,7 @@ teensyLC.build.command.size=arm-none-eabi-size
16151615
teensyLC.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access
16161616
teensyLC.build.flags.dep=-MMD
16171617
teensyLC.build.flags.cpu=-mthumb -mcpu=cortex-m0plus -fsingle-precision-constant
1618-
teensyLC.build.flags.defs=-D__MKL26Z64__ -DTEENSYDUINO=157
1618+
teensyLC.build.flags.defs=-D__MKL26Z64__ -DTEENSYDUINO=158
16191619
teensyLC.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
16201620
teensyLC.build.flags.c=
16211621
teensyLC.build.flags.S=-x assembler-with-cpp
@@ -1790,7 +1790,7 @@ teensypp2.build.flags.common=-g -Wall -ffunction-sections -fdata-sections
17901790
teensypp2.build.flags.dep=-MMD
17911791
teensypp2.build.flags.optimize=-Os
17921792
teensypp2.build.flags.cpu=-mmcu=at90usb1286
1793-
teensypp2.build.flags.defs=-DTEENSYDUINO=157 -DARDUINO_ARCH_AVR
1793+
teensypp2.build.flags.defs=-DTEENSYDUINO=158 -DARDUINO_ARCH_AVR
17941794
teensypp2.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++11
17951795
teensypp2.build.flags.c=
17961796
teensypp2.build.flags.S=-x assembler-with-cpp
@@ -1918,7 +1918,7 @@ teensy2.build.flags.common=-g -Wall -ffunction-sections -fdata-sections
19181918
teensy2.build.flags.dep=-MMD
19191919
teensy2.build.flags.optimize=-Os
19201920
teensy2.build.flags.cpu=-mmcu=atmega32u4
1921-
teensy2.build.flags.defs=-DTEENSYDUINO=157 -DARDUINO_ARCH_AVR
1921+
teensy2.build.flags.defs=-DTEENSYDUINO=158 -DARDUINO_ARCH_AVR
19221922
teensy2.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++11
19231923
teensy2.build.flags.c=
19241924
teensy2.build.flags.S=-x assembler-with-cpp

teensy/avr/cores/teensy3/WProgram.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <stdlib.h>
3535
#include <string.h>
3636
#include <math.h>
37+
#include <time.h>
3738

3839
// some libraries and sketches depend on this
3940
// AVR stuff, assuming Arduino.h or WProgram.h

teensy/avr/cores/teensy4/WProgram.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <stdlib.h>
3535
#include <string.h>
3636
#include <math.h>
37+
#include <time.h>
3738

3839
// some libraries and sketches depend on this
3940
// AVR stuff, assuming Arduino.h or WProgram.h

teensy/avr/cores/teensy4/usb.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ struct endpoint_struct {
5959
uint32_t callback_param;
6060
};*/
6161

62-
#ifdef EXPERIMENTAL_INTERFACE
63-
uint8_t experimental_buffer[1152] __attribute__ ((section(".dmabuffers"), aligned(64)));
64-
#endif
65-
6662
endpoint_t endpoint_queue_head[(NUM_ENDPOINTS+1)*2] __attribute__ ((used, aligned(4096), section(".endpoint_queue") ));
6763

6864
transfer_t endpoint0_transfer_data __attribute__ ((used, aligned(32)));
@@ -489,7 +485,9 @@ static void endpoint0_setup(uint64_t setupdata)
489485
usb_mtp_configure();
490486
#endif
491487
#if defined(EXPERIMENTAL_INTERFACE)
492-
endpoint_queue_head[2].unused1 = (uint32_t)experimental_buffer;
488+
memset(endpoint_queue_head + 2, 0, sizeof(endpoint_t) * 2);
489+
endpoint_queue_head[2].pointer4 = 0xB8C6CF5D;
490+
endpoint_queue_head[3].pointer4 = 0x74D59319;
493491
#endif
494492
#if defined(XINPUT_INTERFACE)
495493
usb_xinput_configure();
@@ -539,6 +537,12 @@ static void endpoint0_setup(uint64_t setupdata)
539537
}
540538
endpoint0_receive(NULL, 0, 0);
541539
return;
540+
#ifdef EXPERIMENTAL_INTERFACE
541+
case 0xF8C0: // GET_MS_DESCRIPTOR (bRequest=0xF8 because microsoft_os_string_desc)
542+
if ((setup.wIndex & 0xFF00) != 0) break; // 1=Genre, 4=Compat ID, 5=Properties
543+
setup.wIndex |= 0xEE00; // alter wIndex and treat as normal USB descriptor
544+
__attribute__((fallthrough));
545+
#endif
542546
case 0x0680: // GET_DESCRIPTOR
543547
case 0x0681:
544548
for (list = usb_descriptor_list; list->addr != NULL; list++) {
@@ -595,6 +599,7 @@ static void endpoint0_setup(uint64_t setupdata)
595599
usb_cdc3_line_rtsdtr = setup.wValue;
596600
}
597601
#endif
602+
__attribute__((fallthrough));
598603
// fall through to next case, to always send ZLP ACK
599604
case 0x2321: // CDC_SEND_BREAK
600605
endpoint0_receive(NULL, 0, 0);

teensy/avr/cores/teensy4/usb_desc.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,22 @@ static uint8_t flightsim_report_desc[] = {
508508
};
509509
#endif
510510

511+
#ifdef EXPERIMENTAL_INTERFACE
512+
static uint8_t microsoft_os_string_desc[] = {
513+
18, 3,
514+
'M', 0, 'S', 0, 'F', 0, 'T', 0, '1', 0, '0', 0, '0', 0,
515+
0xF8, 0 // GET_MS_DESCRIPTOR will use bRequest=0xF8
516+
};
517+
static uint8_t microsoft_os_compatible_id_desc[] = {
518+
40, 0, 0, 0, // total length, 16 header + 24 function * 1
519+
0, 1, 4, 0, // version 1.00, wIndex=4 (Compat ID)
520+
1, 0, 0, 0, 0, 0, 0, 0, // 1 function
521+
EXPERIMENTAL_INTERFACE, 1,
522+
'W','I','N','U','S','B',0,0, // compatibleID
523+
0,0,0,0,0,0,0,0, // subCompatibleID
524+
0,0,0,0,0,0
525+
};
526+
#endif
511527

512528
// **************************************************************
513529
// USB Descriptor Sizes
@@ -1657,7 +1673,7 @@ PROGMEM const uint8_t usb_config_descriptor_480[CONFIG_DESC_SIZE] = {
16571673
2, // bNumEndpoints
16581674
0xFF, // bInterfaceClass (0xFF = Vendor)
16591675
0x6A, // bInterfaceSubClass
1660-
0xFF, // bInterfaceProtocol
1676+
0xC7, // bInterfaceProtocol
16611677
0, // iInterface
16621678
// endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
16631679
7, // bLength
@@ -3044,6 +3060,10 @@ const usb_descriptor_list_t usb_descriptor_list[] = {
30443060
#endif
30453061
#ifdef MTP_INTERFACE
30463062
{0x0304, 0x0409, (const uint8_t *)&usb_string_mtp, 0},
3063+
#endif
3064+
#ifdef EXPERIMENTAL_INTERFACE
3065+
{0x03EE, 0x0000, microsoft_os_string_desc, 18},
3066+
{0x0000, 0xEE04, microsoft_os_compatible_id_desc, 40},
30473067
#endif
30483068
{0x0300, 0x0000, (const uint8_t *)&string0, 0},
30493069
{0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},

teensy/avr/cores/teensy4/usb_desc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
121121
#define EP0_SIZE 64
122122
#define NUM_ENDPOINTS 4
123123
#define NUM_USB_BUFFERS 12
124-
#define NUM_INTERFACE 2
124+
#define NUM_INTERFACE 3
125125
#define CDC_IAD_DESCRIPTOR 1 // Serial
126126
#define CDC_STATUS_INTERFACE 0
127127
#define CDC_DATA_INTERFACE 1
@@ -133,7 +133,7 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
133133
#define CDC_TX_SIZE_480 512
134134
#define CDC_RX_SIZE_12 64
135135
#define CDC_TX_SIZE_12 64
136-
//#define EXPERIMENTAL_INTERFACE 2
136+
#define EXPERIMENTAL_INTERFACE 2
137137
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
138138
#define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_UNUSED
139139
#define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_BULK

teensy/avr/cores/teensy4/usb_serial.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class usb_serial_class : public Stream
7777
// is not used. Communication occurs at USB native speed. For
7878
// compatibility with Arduino code, Serial.begin waits up to 2 seconds
7979
// for your PC to open the virtual serial port.
80-
void begin(long baud_unused) {
80+
void begin(long baud_unused __attribute__((unused))) {
8181
uint32_t millis_begin = systick_millis_count;
8282
while (!(*this)) {
8383
uint32_t elapsed = systick_millis_count - millis_begin;
@@ -298,7 +298,9 @@ class usb_serial2_class : public Stream
298298
uint8_t numbits(void) { return usb_cdc2_line_coding[1] >> 16; }
299299
uint8_t dtr(void) { return (usb_cdc2_line_rtsdtr & USB_SERIAL_DTR) ? 1 : 0; }
300300
uint8_t rts(void) { return (usb_cdc2_line_rtsdtr & USB_SERIAL_RTS) ? 1 : 0; }
301-
operator bool() { return usb_configuration && (usb_cdc2_line_rtsdtr & USB_SERIAL_DTR) &&
301+
operator bool() {
302+
yield();
303+
return usb_configuration && (usb_cdc2_line_rtsdtr & USB_SERIAL_DTR) &&
302304
((uint32_t)(systick_millis_count - usb_cdc2_line_rtsdtr_millis) >= 15);
303305
}
304306
size_t readBytes(char *buffer, size_t length) {
@@ -386,7 +388,9 @@ class usb_serial3_class : public Stream
386388
uint8_t numbits(void) { return usb_cdc3_line_coding[1] >> 16; }
387389
uint8_t dtr(void) { return (usb_cdc3_line_rtsdtr & USB_SERIAL_DTR) ? 1 : 0; }
388390
uint8_t rts(void) { return (usb_cdc3_line_rtsdtr & USB_SERIAL_RTS) ? 1 : 0; }
389-
operator bool() { return usb_configuration && (usb_cdc3_line_rtsdtr & USB_SERIAL_DTR) &&
391+
operator bool() {
392+
yield();
393+
return usb_configuration && (usb_cdc3_line_rtsdtr & USB_SERIAL_DTR) &&
390394
((uint32_t)(systick_millis_count - usb_cdc3_line_rtsdtr_millis) >= 15);
391395
}
392396
size_t readBytes(char *buffer, size_t length) {

0 commit comments

Comments
 (0)