Skip to content

Commit

Permalink
Teensyduino 1.58 Compatibility (#31)
Browse files Browse the repository at this point in the history
* Teensyduino 1.58 Compatibility

* Update CI software versions

Avoiding the 2.0 IDE until it's more stable

* Update Teensyduino version in README
  • Loading branch information
dmadison committed Apr 5, 2023
1 parent 5fdfedf commit f166b56
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request, workflow_dispatch]

env:
IDE_VERSION: 1.8.19
TEENSY_VERSION: 157
TEENSY_VERSION: 158
IDE_LOCATION: /usr/local/share/arduino

jobs:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is meant to be used in conjunction with the [ArduinoXInput library](https:/

## Installation

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.
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.

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.

Expand Down
20 changes: 10 additions & 10 deletions teensy/avr/boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ teensy41.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
teensy41.build.flags.dep=-MMD
teensy41.build.flags.optimize=-Os
teensy41.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
teensy41.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=157
teensy41.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=158
teensy41.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
teensy41.build.flags.c=
teensy41.build.flags.S=-x assembler-with-cpp
Expand Down Expand Up @@ -271,7 +271,7 @@ teensyMM.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
teensyMM.build.flags.dep=-MMD
teensyMM.build.flags.optimize=-Os
teensyMM.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
teensyMM.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=157
teensyMM.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=158
teensyMM.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
teensyMM.build.flags.c=
teensyMM.build.flags.S=-x assembler-with-cpp
Expand Down Expand Up @@ -501,7 +501,7 @@ teensy40.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
teensy40.build.flags.dep=-MMD
teensy40.build.flags.optimize=-Os
teensy40.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
teensy40.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=157
teensy40.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=158
teensy40.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
teensy40.build.flags.c=
teensy40.build.flags.S=-x assembler-with-cpp
Expand Down Expand Up @@ -727,7 +727,7 @@ teensy36.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
teensy36.build.flags.dep=-MMD
teensy36.build.flags.optimize=-Os
teensy36.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
teensy36.build.flags.defs=-D__MK66FX1M0__ -DTEENSYDUINO=157
teensy36.build.flags.defs=-D__MK66FX1M0__ -DTEENSYDUINO=158
teensy36.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensy36.build.flags.c=
teensy36.build.flags.S=-x assembler-with-cpp
Expand Down Expand Up @@ -967,7 +967,7 @@ teensy35.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
teensy35.build.flags.dep=-MMD
teensy35.build.flags.optimize=-Os
teensy35.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
teensy35.build.flags.defs=-D__MK64FX512__ -DTEENSYDUINO=157
teensy35.build.flags.defs=-D__MK64FX512__ -DTEENSYDUINO=158
teensy35.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensy35.build.flags.c=
teensy35.build.flags.S=-x assembler-with-cpp
Expand Down Expand Up @@ -1198,7 +1198,7 @@ teensy31.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
teensy31.build.flags.dep=-MMD
teensy31.build.flags.optimize=-Os
teensy31.build.flags.cpu=-mthumb -mcpu=cortex-m4 -fsingle-precision-constant
teensy31.build.flags.defs=-D__MK20DX256__ -DTEENSYDUINO=157
teensy31.build.flags.defs=-D__MK20DX256__ -DTEENSYDUINO=158
teensy31.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensy31.build.flags.c=
teensy31.build.flags.S=-x assembler-with-cpp
Expand Down Expand Up @@ -1439,7 +1439,7 @@ teensy30.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
teensy30.build.flags.dep=-MMD
teensy30.build.flags.optimize=-Os
teensy30.build.flags.cpu=-mthumb -mcpu=cortex-m4 -fsingle-precision-constant
teensy30.build.flags.defs=-D__MK20DX128__ -DTEENSYDUINO=157
teensy30.build.flags.defs=-D__MK20DX128__ -DTEENSYDUINO=158
teensy30.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensy30.build.flags.c=
teensy30.build.flags.S=-x assembler-with-cpp
Expand Down Expand Up @@ -1615,7 +1615,7 @@ teensyLC.build.command.size=arm-none-eabi-size
teensyLC.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access
teensyLC.build.flags.dep=-MMD
teensyLC.build.flags.cpu=-mthumb -mcpu=cortex-m0plus -fsingle-precision-constant
teensyLC.build.flags.defs=-D__MKL26Z64__ -DTEENSYDUINO=157
teensyLC.build.flags.defs=-D__MKL26Z64__ -DTEENSYDUINO=158
teensyLC.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensyLC.build.flags.c=
teensyLC.build.flags.S=-x assembler-with-cpp
Expand Down Expand Up @@ -1790,7 +1790,7 @@ teensypp2.build.flags.common=-g -Wall -ffunction-sections -fdata-sections
teensypp2.build.flags.dep=-MMD
teensypp2.build.flags.optimize=-Os
teensypp2.build.flags.cpu=-mmcu=at90usb1286
teensypp2.build.flags.defs=-DTEENSYDUINO=157 -DARDUINO_ARCH_AVR
teensypp2.build.flags.defs=-DTEENSYDUINO=158 -DARDUINO_ARCH_AVR
teensypp2.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++11
teensypp2.build.flags.c=
teensypp2.build.flags.S=-x assembler-with-cpp
Expand Down Expand Up @@ -1918,7 +1918,7 @@ teensy2.build.flags.common=-g -Wall -ffunction-sections -fdata-sections
teensy2.build.flags.dep=-MMD
teensy2.build.flags.optimize=-Os
teensy2.build.flags.cpu=-mmcu=atmega32u4
teensy2.build.flags.defs=-DTEENSYDUINO=157 -DARDUINO_ARCH_AVR
teensy2.build.flags.defs=-DTEENSYDUINO=158 -DARDUINO_ARCH_AVR
teensy2.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++11
teensy2.build.flags.c=
teensy2.build.flags.S=-x assembler-with-cpp
Expand Down
1 change: 1 addition & 0 deletions teensy/avr/cores/teensy3/WProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

// some libraries and sketches depend on this
// AVR stuff, assuming Arduino.h or WProgram.h
Expand Down
1 change: 1 addition & 0 deletions teensy/avr/cores/teensy4/WProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

// some libraries and sketches depend on this
// AVR stuff, assuming Arduino.h or WProgram.h
Expand Down
15 changes: 10 additions & 5 deletions teensy/avr/cores/teensy4/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ struct endpoint_struct {
uint32_t callback_param;
};*/

#ifdef EXPERIMENTAL_INTERFACE
uint8_t experimental_buffer[1152] __attribute__ ((section(".dmabuffers"), aligned(64)));
#endif

endpoint_t endpoint_queue_head[(NUM_ENDPOINTS+1)*2] __attribute__ ((used, aligned(4096), section(".endpoint_queue") ));

transfer_t endpoint0_transfer_data __attribute__ ((used, aligned(32)));
Expand Down Expand Up @@ -489,7 +485,9 @@ static void endpoint0_setup(uint64_t setupdata)
usb_mtp_configure();
#endif
#if defined(EXPERIMENTAL_INTERFACE)
endpoint_queue_head[2].unused1 = (uint32_t)experimental_buffer;
memset(endpoint_queue_head + 2, 0, sizeof(endpoint_t) * 2);
endpoint_queue_head[2].pointer4 = 0xB8C6CF5D;
endpoint_queue_head[3].pointer4 = 0x74D59319;
#endif
#if defined(XINPUT_INTERFACE)
usb_xinput_configure();
Expand Down Expand Up @@ -539,6 +537,12 @@ static void endpoint0_setup(uint64_t setupdata)
}
endpoint0_receive(NULL, 0, 0);
return;
#ifdef EXPERIMENTAL_INTERFACE
case 0xF8C0: // GET_MS_DESCRIPTOR (bRequest=0xF8 because microsoft_os_string_desc)
if ((setup.wIndex & 0xFF00) != 0) break; // 1=Genre, 4=Compat ID, 5=Properties
setup.wIndex |= 0xEE00; // alter wIndex and treat as normal USB descriptor
__attribute__((fallthrough));
#endif
case 0x0680: // GET_DESCRIPTOR
case 0x0681:
for (list = usb_descriptor_list; list->addr != NULL; list++) {
Expand Down Expand Up @@ -595,6 +599,7 @@ static void endpoint0_setup(uint64_t setupdata)
usb_cdc3_line_rtsdtr = setup.wValue;
}
#endif
__attribute__((fallthrough));
// fall through to next case, to always send ZLP ACK
case 0x2321: // CDC_SEND_BREAK
endpoint0_receive(NULL, 0, 0);
Expand Down
22 changes: 21 additions & 1 deletion teensy/avr/cores/teensy4/usb_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,22 @@ static uint8_t flightsim_report_desc[] = {
};
#endif

#ifdef EXPERIMENTAL_INTERFACE
static uint8_t microsoft_os_string_desc[] = {
18, 3,
'M', 0, 'S', 0, 'F', 0, 'T', 0, '1', 0, '0', 0, '0', 0,
0xF8, 0 // GET_MS_DESCRIPTOR will use bRequest=0xF8
};
static uint8_t microsoft_os_compatible_id_desc[] = {
40, 0, 0, 0, // total length, 16 header + 24 function * 1
0, 1, 4, 0, // version 1.00, wIndex=4 (Compat ID)
1, 0, 0, 0, 0, 0, 0, 0, // 1 function
EXPERIMENTAL_INTERFACE, 1,
'W','I','N','U','S','B',0,0, // compatibleID
0,0,0,0,0,0,0,0, // subCompatibleID
0,0,0,0,0,0
};
#endif

// **************************************************************
// USB Descriptor Sizes
Expand Down Expand Up @@ -1657,7 +1673,7 @@ PROGMEM const uint8_t usb_config_descriptor_480[CONFIG_DESC_SIZE] = {
2, // bNumEndpoints
0xFF, // bInterfaceClass (0xFF = Vendor)
0x6A, // bInterfaceSubClass
0xFF, // bInterfaceProtocol
0xC7, // bInterfaceProtocol
0, // iInterface
// endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
7, // bLength
Expand Down Expand Up @@ -3044,6 +3060,10 @@ const usb_descriptor_list_t usb_descriptor_list[] = {
#endif
#ifdef MTP_INTERFACE
{0x0304, 0x0409, (const uint8_t *)&usb_string_mtp, 0},
#endif
#ifdef EXPERIMENTAL_INTERFACE
{0x03EE, 0x0000, microsoft_os_string_desc, 18},
{0x0000, 0xEE04, microsoft_os_compatible_id_desc, 40},
#endif
{0x0300, 0x0000, (const uint8_t *)&string0, 0},
{0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
Expand Down
4 changes: 2 additions & 2 deletions teensy/avr/cores/teensy4/usb_desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
#define EP0_SIZE 64
#define NUM_ENDPOINTS 4
#define NUM_USB_BUFFERS 12
#define NUM_INTERFACE 2
#define NUM_INTERFACE 3
#define CDC_IAD_DESCRIPTOR 1 // Serial
#define CDC_STATUS_INTERFACE 0
#define CDC_DATA_INTERFACE 1
Expand All @@ -133,7 +133,7 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
#define CDC_TX_SIZE_480 512
#define CDC_RX_SIZE_12 64
#define CDC_TX_SIZE_12 64
//#define EXPERIMENTAL_INTERFACE 2
#define EXPERIMENTAL_INTERFACE 2
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
#define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_UNUSED
#define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_BULK
Expand Down
10 changes: 7 additions & 3 deletions teensy/avr/cores/teensy4/usb_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class usb_serial_class : public Stream
// is not used. Communication occurs at USB native speed. For
// compatibility with Arduino code, Serial.begin waits up to 2 seconds
// for your PC to open the virtual serial port.
void begin(long baud_unused) {
void begin(long baud_unused __attribute__((unused))) {
uint32_t millis_begin = systick_millis_count;
while (!(*this)) {
uint32_t elapsed = systick_millis_count - millis_begin;
Expand Down Expand Up @@ -298,7 +298,9 @@ class usb_serial2_class : public Stream
uint8_t numbits(void) { return usb_cdc2_line_coding[1] >> 16; }
uint8_t dtr(void) { return (usb_cdc2_line_rtsdtr & USB_SERIAL_DTR) ? 1 : 0; }
uint8_t rts(void) { return (usb_cdc2_line_rtsdtr & USB_SERIAL_RTS) ? 1 : 0; }
operator bool() { return usb_configuration && (usb_cdc2_line_rtsdtr & USB_SERIAL_DTR) &&
operator bool() {
yield();
return usb_configuration && (usb_cdc2_line_rtsdtr & USB_SERIAL_DTR) &&
((uint32_t)(systick_millis_count - usb_cdc2_line_rtsdtr_millis) >= 15);
}
size_t readBytes(char *buffer, size_t length) {
Expand Down Expand Up @@ -386,7 +388,9 @@ class usb_serial3_class : public Stream
uint8_t numbits(void) { return usb_cdc3_line_coding[1] >> 16; }
uint8_t dtr(void) { return (usb_cdc3_line_rtsdtr & USB_SERIAL_DTR) ? 1 : 0; }
uint8_t rts(void) { return (usb_cdc3_line_rtsdtr & USB_SERIAL_RTS) ? 1 : 0; }
operator bool() { return usb_configuration && (usb_cdc3_line_rtsdtr & USB_SERIAL_DTR) &&
operator bool() {
yield();
return usb_configuration && (usb_cdc3_line_rtsdtr & USB_SERIAL_DTR) &&
((uint32_t)(systick_millis_count - usb_cdc3_line_rtsdtr_millis) >= 15);
}
size_t readBytes(char *buffer, size_t length) {
Expand Down

0 comments on commit f166b56

Please sign in to comment.