Graeme Gill
Member
In porting a project from Teensy 3.2 to Teensy 4.0 I have come across a couple of small RAWHID incompatibilities.
The first one is that (at least with the Teensyduino 1.55) I can't compile without a SEREMU_INTERFACE.
i.e. something like this in usb_desc.h:
results in the following errors:
Applying the following change to yield.cpp:
appears to fix the error, but does leave two warnings.
The other issue is that it seem that with the current Teensy 4 code it's not possible to use end point 1. Given that the hardware
only supports 8 end points and 0 is reserved for the control channel, it seems a pity to waste one.
I made the necessary changes to usb.c to allow for end point 1, i.e. adding
to endpoint0_setup(), modifying usb_config_rx(), usb_config_tx() etc. to return on ep < 1 rather than ep < 2,
as well as usb_transmit() and usb_receive(), and end point 1 then appeared to be usable.
Is there a reason ep 1 is not available ?
(I note that the USB_EVERYTHING config. uses ep 1 as well as up to ep 15, so would be unlikely to work on a Teensy 4 ?)
The first one is that (at least with the Teensyduino 1.55) I can't compile without a SEREMU_INTERFACE.
i.e. something like this in usb_desc.h:
Code:
#if defined(USB_CUSTOMRAWHID)
#define VENDOR_ID 0x16C0
#define PRODUCT_ID 0x1234
#define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
#define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
#define MANUFACTURER_NAME {'a','b','c','d'}
#define MANUFACTURER_NAME_LEN 4
#define PRODUCT_NAME {'a','b','c','d'}
#define PRODUCT_NAME_LEN 4
#define EP0_SIZE 64
#define NUM_ENDPOINTS 2
#define NUM_INTERFACE 1
#define RAWHID_INTERFACE 0
#define RAWHID_TX_ENDPOINT 2
#define RAWHID_TX_SIZE 64
#define RAWHID_TX_INTERVAL 1
#define RAWHID_RX_ENDPOINT 2
#define RAWHID_RX_SIZE 64
#define RAWHID_RX_INTERVAL 1
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT
#elif ...
results in the following errors:
Code:
yield.cpp:60:7: error: 'Serial' was not declared in this scope
if (Serial.available()) serialEvent();
^
yield.cpp:60:39: error: 'serialEvent' was not declared in this scope
if (Serial.available()) serialEvent();
Applying the following change to yield.cpp:
Code:
#if defined(SEREMU_INTERFACE) || defined(USB_SERIAL) || defined(USB_DUAL_SERIAL) || defined(USB_TRIPLE_SERIAL)
// USB Serail - Add hack to minimize impact...
if (yield_active_check_flags & YIELD_CHECK_USB_SERIAL) {
if (Serial.available()) serialEvent();
if (_serialEvent_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIAL;
}
#endif
appears to fix the error, but does leave two warnings.
The other issue is that it seem that with the current Teensy 4 code it's not possible to use end point 1. Given that the hardware
only supports 8 end points and 0 is reserved for the control channel, it seems a pity to waste one.
I made the necessary changes to usb.c to allow for end point 1, i.e. adding
Code:
#if defined(ENDPOINT1_CONFIG)
USB1_ENDPTCTRL1 = ENDPOINT1_CONFIG;
#endif
as well as usb_transmit() and usb_receive(), and end point 1 then appeared to be usable.
Is there a reason ep 1 is not available ?
(I note that the USB_EVERYTHING config. uses ep 1 as well as up to ep 15, so would be unlikely to work on a Teensy 4 ?)