Skip to main content
December 9, 2019
Question

STM32CubeIDE USB Host FS (1.5MBit/s) HID - Mini keyboard Touchpad Wireless is stopping responding when it enters standby or touchpad mode

  • December 9, 2019
  • 11 replies
  • 3989 views

Does anyone know how to make this keyboard work?

With the MAX3421E chip in conjunction with the USH30 library this works but with STM32CubeIDE not working properly.

0690X00000AsNmkQAF.jpg

https://www.amazon.com/Rii-Wireless-Keyboard-Touchpad%EF%BC%86QWERTY-Raspberry/dp/B00B9996LA

This topic has been closed for replies.

11 replies

December 12, 2019

I managed to make it work poorly (for tests).

First I had the interface toggle each time a disconnect occurs. It seems that we need to treat both interfaces in sequence, if left as it is, alternating when switching from keyboard to touchpad, or vice versa, the first interaction is lost.

And the other thing I noticed was that an enumeration problem occurs, and so the process crashes, because there is no timeout to escape errors. I added a 32-bit variable to try to force a restart, and it seems to work.

usbh_core.c:

case HOST_ENUMERATION:
		/* Check for enumeration status */
		if ( USBH_HandleEnum(phost) == USBH_OK)
		{
			enumTimeout=0;
			/* The function shall return USBH_OK when full enumeration is complete */
			USBH_UsrLog ("Enumeration done.");
			//			phost->device.current_interface = 0U;
			if(phost->device.current_interface != 0){
				phost->device.current_interface = 0;
			} else {
				phost->device.current_interface = 1;
			}
			if(phost->device.DevDesc.bNumConfigurations == 1U)
			{
				USBH_UsrLog ("This device has only 1 configuration.");
				phost->gState = HOST_SET_CONFIGURATION;
 
			}
			else
			{
				phost->gState = HOST_INPUT;
			}
 
		}
		else
		{
			if(enumTimeout < 0xffff){
				enumTimeout++;
			}
			else
			{
				enumTimeout=0;
				USBH_UsrLog ("Enumeration fail.");
				USBH_DeInit(phost);
				MX_USB_HOST_Init();
			}
		}
		break;

usbh_hid.c:

static USBH_StatusTypeDef USBH_HID_InterfaceInit (USBH_HandleTypeDef *phost)
{
	uint8_t max_ep;
	uint8_t num = 0U;
	uint8_t interface;
 
	USBH_StatusTypeDef status = USBH_FAIL;
	HID_HandleTypeDef *HID_Handle;
 
	interface = phost->device.current_interface; // USBH_FindInterface(phost, phost->pActiveClass->ClassCode, HID_BOOT_CODE, 0xFFU);