Skip to content

Commit 154e26f

Browse files
committed
Add patch files for teensy4.1
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 5f92ab3 commit 154e26f

File tree

5 files changed

+136
-3
lines changed

5 files changed

+136
-3
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,30 @@ jobs:
2525
run: |
2626
# Build but ignore failure, will install pre-requisites
2727
pio run -e teensy36 || true
28+
pio run -e teensy41 || true
2829
2930
ls -l ~/.platformio
3031
ls -l ~/.platformio/platforms/teensy/builder/frameworks/arduino.py
32+
# Teensy3.6
3133
patch -d ~/.platformio/ -p0 < diff/arduino.py.diff
3234
patch -d ~/.platformio/ -p0 < diff/teensy3/usb_desc.c.diff
3335
patch -d ~/.platformio/ -p0 < diff/teensy3/usb_desc.h.diff
3436
patch -d ~/.platformio/ -p0 < diff/teensy3/usb_inst.cpp.diff
3537
patch -d ~/.platformio/ -p0 < diff/teensy3/yield.cpp.diff
3638
39+
# Teensy4.1
40+
patch -d ~/.platformio/ -p0 < diff/arduino.py.diff || true
41+
patch -d ~/.platformio/ -p0 < diff/teensy4/usb_desc.c.diff
42+
patch -d ~/.platformio/ -p0 < diff/teensy4/usb_desc.h.diff
43+
patch -d ~/.platformio/ -p0 < diff/teensy4/usb_inst.cpp.diff
44+
patch -d ~/.platformio/ -p0 < diff/teensy4/yield.cpp.diff
45+
3746
- name: Build for Teensy 3.6
3847
# Still build 4.1, even if 3.6 fails
3948
continue-on-error: true
4049
run: |
4150
pio run -e teensy36
4251
43-
# - name: Build for Teensy 4.1
44-
# run: |
45-
# pio run -e teensy41
52+
- name: Build for Teensy 4.1
53+
run: |
54+
pio run -e teensy41

diff/teensy4/usb_desc.c.diff

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- packages/framework-arduinoteensy/cores/teensy4/usb_desc.c 2023-12-11 17:38:41.575512487 +0800
2+
+++ packages/framework-arduinoteensy/cores/teensy4/usb_desc.c 2023-12-11 17:39:15.207185545 +0800
3+
@@ -1207,7 +1207,7 @@
4+
0x03, // bInterfaceClass (0x03 = HID)
5+
0x00, // bInterfaceSubClass
6+
0x00, // bInterfaceProtocol
7+
- 0, // iInterface
8+
+ 2, // iInterface <-------------------Change this from 0 to 2!
9+
// HID interface descriptor, HID 1.11 spec, section 6.2.1
10+
9, // bLength
11+
0x21, // bDescriptorType

diff/teensy4/usb_desc.h.diff

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
--- packages/framework-arduinoteensy/cores/teensy4/usb_desc.h 2023-12-11 17:38:41.575512487 +0800
2+
+++ packages/framework-arduinoteensy/cores/teensy4/usb_desc.h 2023-12-11 17:51:01.544054165 +0800
3+
@@ -111,7 +111,8 @@
4+
*/
5+
6+
7+
-#if defined(USB_SERIAL)
8+
+#if defined(USB_SERIAL) && FALSE
9+
+OMG!!!
10+
#define VENDOR_ID 0x16C0
11+
#define PRODUCT_ID 0x0483
12+
#define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
13+
@@ -949,6 +950,62 @@
14+
#define ENDPOINT14_CONFIG ENDPOINT_TRANSMIT_ISOCHRONOUS
15+
#define ENDPOINT15_CONFIG ENDPOINT_TRANSMIT_ONLY
16+
17+
+#elif defined(USB_RAWHID_TRIPLESERIAL)
18+
+ #define VENDOR_ID 0x16C0
19+
+ #define PRODUCT_ID 0x048C
20+
+ #define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
21+
+ #define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
22+
+ #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
23+
+ #define MANUFACTURER_NAME_LEN 11
24+
+ #define PRODUCT_NAME {'T','r','i','p','l','e',' ','S','e','r','i','a','l'}
25+
+ #define PRODUCT_NAME_LEN 13
26+
+ #define EP0_SIZE 64
27+
+ #define NUM_ENDPOINTS 9
28+
+ #define NUM_INTERFACE 7
29+
+
30+
+ #define CDC_IAD_DESCRIPTOR 1 // Serial
31+
+ #define CDC_STATUS_INTERFACE 0
32+
+ #define CDC_DATA_INTERFACE 1
33+
+ #define CDC_ACM_ENDPOINT 2
34+
+ #define CDC_RX_ENDPOINT 3
35+
+ #define CDC_TX_ENDPOINT 3
36+
+ #define CDC_ACM_SIZE 16
37+
+ #define CDC_RX_SIZE_480 512
38+
+ #define CDC_TX_SIZE_480 512
39+
+ #define CDC_RX_SIZE_12 64
40+
+ #define CDC_TX_SIZE_12 64
41+
+ #define SEREMU_TX_SIZE 64
42+
+
43+
+ #define CDC2_STATUS_INTERFACE 2 // SerialUSB1
44+
+ #define CDC2_DATA_INTERFACE 3
45+
+ #define CDC2_ACM_ENDPOINT 4
46+
+ #define CDC2_RX_ENDPOINT 5
47+
+ #define CDC2_TX_ENDPOINT 5
48+
+
49+
+ #define CDC3_STATUS_INTERFACE 4 // SerialUSB2
50+
+ #define CDC3_DATA_INTERFACE 5
51+
+ #define CDC3_ACM_ENDPOINT 6
52+
+ #define CDC3_RX_ENDPOINT 7
53+
+ #define CDC3_TX_ENDPOINT 7
54+
+
55+
+ #define RAWHID_INTERFACE 6 // RawHID
56+
+ #define RAWHID_TX_ENDPOINT 8
57+
+ #define RAWHID_TX_SIZE 64
58+
+ #define RAWHID_TX_INTERVAL 1 // TODO: is this ok for 480 Mbit speed
59+
+ #define RAWHID_RX_ENDPOINT 9
60+
+ #define RAWHID_RX_SIZE 64
61+
+ #define RAWHID_RX_INTERVAL 1 // TODO: is this ok for 480 Mbit speed
62+
+
63+
+ #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
64+
+ #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
65+
+ #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
66+
+ #define ENDPOINT5_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
67+
+ #define ENDPOINT6_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
68+
+ #define ENDPOINT7_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
69+
+/* for raw hid */
70+
+ #define ENDPOINT8_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
71+
+ #define ENDPOINT9_CONFIG ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_UNUSED
72+
+
73+
#endif
74+
75+
#ifdef USB_DESC_LIST_DEFINE

diff/teensy4/usb_inst.cpp.diff

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- packages/framework-arduinoteensy/cores/teensy4/usb_inst.cpp 2023-12-11 17:38:46.011469367 +0800
2+
+++ packages/framework-arduinoteensy/cores/teensy4/usb_inst.cpp 2023-12-11 17:40:34.002419647 +0800
3+
@@ -87,7 +87,7 @@
4+
5+
#else // F_CPU < 20 MHz
6+
7+
-#if defined(USB_SERIAL) || defined(USB_SERIAL_HID)
8+
+#if defined(USB_SERIAL) || defined(USB_SERIAL_HID) || defined(USB_RAWHID_TRIPLESERIAL)
9+
usb_serial_class Serial;
10+
#elif (USB_DISABLED)
11+
usb_serial_class Serial;

diff/teensy4/yield.cpp.diff

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--- packages/framework-arduinoteensy/cores/teensy4/yield.cpp 2023-12-11 17:38:48.495445219 +0800
2+
+++ packages/framework-arduinoteensy/cores/teensy4/yield.cpp 2023-12-11 17:41:10.658063282 +0800
3+
@@ -31,7 +31,7 @@
4+
#include <Arduino.h>
5+
#include "EventResponder.h"
6+
7+
-#ifdef USB_TRIPLE_SERIAL
8+
+#if defined(USB_TRIPLE_SERIAL) || defined(USB_RAWHID_TRIPLESERIAL)
9+
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL | YIELD_CHECK_USB_SERIALUSB1 | YIELD_CHECK_USB_SERIALUSB2; // default to check USB.
10+
extern const uint8_t _serialEventUSB2_default;
11+
extern const uint8_t _serialEventUSB1_default;
12+
@@ -61,13 +61,13 @@
13+
if (_serialEvent_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIAL;
14+
}
15+
16+
-#if defined(USB_DUAL_SERIAL) || defined(USB_TRIPLE_SERIAL)
17+
+#if defined(USB_DUAL_SERIAL) || defined(USB_TRIPLE_SERIAL) || defined(USB_RAWHID_TRIPLESERIAL)
18+
if (yield_active_check_flags & YIELD_CHECK_USB_SERIALUSB1) {
19+
if (SerialUSB1.available()) serialEventUSB1();
20+
if (_serialEventUSB1_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIALUSB1;
21+
}
22+
#endif
23+
-#ifdef USB_TRIPLE_SERIAL
24+
+#if defined(USB_TRIPLE_SERIAL) || defined(USB_RAWHID_TRIPLESERIAL)
25+
if (yield_active_check_flags & YIELD_CHECK_USB_SERIALUSB2) {
26+
if (SerialUSB2.available()) serialEventUSB2();
27+
if (_serialEventUSB2_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIALUSB2;

0 commit comments

Comments
 (0)