My Gigabyte USB keyboard works with Due but not with Teensy 3.6. The difference is Due sends SET PROTOCOL to boot mode while keyboard.cpp does not. I added SET PROTOCOL to keyboard.cpp and now the keyboard works. I suspect the keyboard defaults to HID mode so the SET PROTOCOL forces the keyboard to boot mode. Other keyboards work maybe because they default to boot mode.
Attached is a Beagle USB capture showing Due, T36, and T36 with patch. The first enumeration is for Due running the KeyboardController example. The second is for Teensy 3.6 which fails. The third is for Teensy 3.6 with patch. The Mouse example is used on the T36.
Code change is just 3 lines.
Attached is a Beagle USB capture showing Due, T36, and T36 with patch. The first enumeration is for Due running the KeyboardController example. The second is for Teensy 3.6 which fails. The third is for Teensy 3.6 with patch. The Mouse example is used on the T36.
Code change is just 3 lines.
Code:
--- a/USBHost_t36.h
+++ b/USBHost_t36.h
@@ -731,6 +731,7 @@ private:
void (*keyReleasedFunction)(int unicode);
Pipe_t *datapipe;
setup_t setup;
+ setup_t protocol;
uint8_t report[8];
uint16_t keyCode;
uint8_t modifiers;
diff --git a/keyboard.cpp b/keyboard.cpp
index bfc127c..ba2bf0d 100644
--- a/keyboard.cpp
+++ b/keyboard.cpp
@@ -138,6 +138,8 @@ bool KeyboardController::claim(Device_t *dev, int type, cons
datapipe = new_Pipe(dev, 3, endpoint, 1, 8, interval);
datapipe->callback_function = callback;
queue_Data_Transfer(datapipe, report, 8, this);
+ mk_setup(protocol, 0x21, 11, 0, 0, 0); // 11=SET_PROTOCOL
+ queue_Control_Transfer(dev, &protocol, NULL, this);
mk_setup(setup, 0x21, 10, 0, 0, 0); // 10=SET_IDLE
queue_Control_Transfer(dev, &setup, NULL, this);
return true;