I've created a new TeensyLC usb type that emulates an off the shelf device. I've completely tested, and that code is working. When I plug the new Teensy device into a host, the host sees the Teensy as the off the shelf device and works as expected. All of the code changes have been made to the files in teensy/avr/cores/teensy3
Now im trying to port the code to a Teensy4.1. I have the code compiling using board = Teensy4.1, usb=mydevice.
Its not working as expected yet, but the first major thing (that needs customized for mydevice) that I see different between LC and 4.1 is this section from usb.c
The rest of the porting seems to be pretty strait forward, but this seems entirely new. mydevice is probably closest to the KEYBOARD_INTERFACE. Can someone explain what is happening in this section?
I've attached a screenshot of whats happening when I plug in the device. The host receives the descriptor, then goes into a loop of FUNCTION SYNC RESET PIPE AND CLEAR STALL, FUNCTION BULK OR INTERRUPT TRANSFER, and FUNCTION ABORT PIPE. I'm wondering if it has to do with the endpoint0_complete code above.
Thanks,
Scott...
Now im trying to port the code to a Teensy4.1. I have the code compiling using board = Teensy4.1, usb=mydevice.
Its not working as expected yet, but the first major thing (that needs customized for mydevice) that I see different between LC and 4.1 is this section from usb.c
Code:
static void endpoint0_complete(void)
{
setup_t setup;
setup.bothwords = endpoint0_setupdata.bothwords;
//printf("complete %x %x %x\n", setup.word1, setup.word2, endpoint0_buffer[0]);
#ifdef CDC_STATUS_INTERFACE
// 0x2021 is CDC_SET_LINE_CODING
if (setup.wRequestAndType == 0x2021 && setup.wIndex == CDC_STATUS_INTERFACE) {
memcpy(usb_cdc_line_coding, endpoint0_buffer, 7);
printf("usb_cdc_line_coding, baud=%u\n", usb_cdc_line_coding[0]);
if (usb_cdc_line_coding[0] == 134) {
usb_start_sof_interrupts(NUM_INTERFACE);
usb_reboot_timer = 80; // TODO: 10 if only 12 Mbit/sec
}
}
#endif
.....
#ifdef KEYBOARD_INTERFACE
if (setup.word1 == 0x02000921 && setup.word2 == ((1 << 16) | KEYBOARD_INTERFACE)) {
keyboard_leds = endpoint0_buffer[0];
endpoint0_transmit(NULL, 0, 0);
}
#endif
The rest of the porting seems to be pretty strait forward, but this seems entirely new. mydevice is probably closest to the KEYBOARD_INTERFACE. Can someone explain what is happening in this section?
I've attached a screenshot of whats happening when I plug in the device. The host receives the descriptor, then goes into a loop of FUNCTION SYNC RESET PIPE AND CLEAR STALL, FUNCTION BULK OR INTERRUPT TRANSFER, and FUNCTION ABORT PIPE. I'm wondering if it has to do with the endpoint0_complete code above.
Thanks,
Scott...
Last edited: