Teensy USB Keyboard - Power Management

yeahtuna

Well-known member
I have a composite device which include MIDI, rawHID, and keyboard interfaces. When I go into the Windows Device Manager and check the properties of the keyboard interface, I notice that there is no power management tab.

I'd like to be able to use the composite device to wake my computer from sleep, but without that power management tab, it's not possible. Is there a way for the Teensy keyboard interface to support this functionality? Thanks in advance if you have any info to share.

Rob
 
If I were a guessing person, I would look at the USB descriptor:
Code:
/ USB Configuration Descriptor.  This huge descriptor tells all
// of the devices capbilities.
static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
        // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
        9,                                      // bLength;
        2,                                      // bDescriptorType;
        LSB(CONFIG_DESC_SIZE),                 // wTotalLength
        MSB(CONFIG_DESC_SIZE),
        NUM_INTERFACE,                          // bNumInterfaces
        1,                                      // bConfigurationValue
        0,                                      // iConfiguration
[COLOR="#FF0000"]        0xC0,                                   // bmAttributes[/COLOR]
        50,                                     // bMaxPower

At the bmAttributes: If you look at the attributes definition
Code:
D7 Reserved, set to 1. (USB 1.0 Bus Powered)
D6 Self Powered
D5 Remote Wakeup
D4..0 Reserved, set to 0.
You may try setting D5?

When I look at a logitech keyboard on a Linux board:
Code:
kurt@kurt-UP-CHT01:~$ lsusb -v -d  046d:c517

Bus 001 Device 002: ID 046d:c517 Logitech, Inc. LX710 Cordless Desktop Laser
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x046d Logitech, Inc.
  idProduct          0xc517 LX710 Cordless Desktop Laser
  bcdDevice           38.10
  iManufacturer           1
  iProduct                2
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           59
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
   [COLOR="#FF0000"] bmAttributes         0xa0[/COLOR]
      (Bus Powered)
      Remote Wakeup
    MaxPower               98mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      1 Keyboard
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      59
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     177
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
kurt@kurt-UP-CHT01:~$
That bit is set

Forgot to mention: That this is in the teensy3\usb_desc.c file. And I don't know what else this might imply...
 
I changed the bmAttributes to 0xa0 and it definitely makes the Power Management tab show up, but my first tests seem to indicate that the Teensy is unable to wake the computer. I need to do more testing....
 
Last edited:
I changed the bmAttributes to 0xa0 and it definitely makes the Power Management tab show up, but my first tests seem to indicate that the Teensy is unable to wake the computer. I need to do more testing....
It's hard for me to say how well this is going to work. , As my computer has had a few sleeping issues since I updated to the fall creators update, but I can confirm that the teensy can wake the computer when the monitor has gone into power saving mode. Once I get the machine to sleep properly, I'll report more.
 
I did some more tests. When my computer is in S3 sleep, the teensy is not able to wake the computer, but interestingly the key that I press (the teensy generates) while the computer is sleeping is registered by the system once it's awake. I'll check what my power meter says is going on with the teensy once the computer enters sleep. Maybe that'll offer some hints.
 
Again I have not tried any of this stuff nor know much about them. But in the document you posted in #5, there are some definitions for wakeup keys and or events.

Not sure how easy it would be to generate these... Or to know you are in sleep state or not.
 
I think this might be even easier than I thought. Apparently there's a KEY_SYSTEM_WAKE_UP defined in keylayouts.h. Maybe sending that is the ticket.
 
I still can't get this to work. I'm pretty sure it won't work with the 'old' style keyboard type. Instead you'll need to use the new Multimedia Keyboard type. I've lost interest in this pursuit so.....
 
Hi, I am interested in this as I am facing same issue with an Teensy-LC to wake-up a windows 10 system from sleep. I tried changing the bmAttributes to 0xA0. As Yeahtuna mentioned the Power Management tab is showing in the device property. I enabled "allow the device to wake the computer" checked. But it seems not working. Is there any possible solution I can try to get this working?
 
Hi, I am also having this same issue and wonder if anyone has figured this out yet. I'm using T4.1 connected to Windows 10 and unable to wake the computer from sleep using:

Code:
Keyboard.press(KEY_SYSTEM_WAKE_UP); 
Keyboard.release(KEY_SYSTEM_WAKE_UP);

I have confirmed in BIOS that USB wake is enabled on the computer. I do NOT see the Power Management tab in the OS Device Manager preferences, but I'm not sure if thats an issue or not.

Any help would be appreciated!
 
Back
Top