2019-12-09 05:05 AM
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.
https://www.amazon.com/Rii-Wireless-Keyboard-Touchpad%EF%BC%86QWERTY-Raspberry/dp/B00B9996LA
2019-12-09 05:06 AM
It seems that USBH_UserProcess is called several times so it stops responding.
2019-12-09 05:16 AM
Note: Common (wired) mouse and keyboard work separately. Wireless mouse did not work (Logtech M185).
2019-12-09 09:00 PM
I noticed that with the wired keyboard the variable Appli_state gets the state APPLICATION_READY. But with the wireless keyboard the Appli_state variable goes into APPLICATION_START state, so the keyboard stops responding.
Is there any use example with state variable APPLICATION_START?
Reference Subroutine:
static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id)
{
/* USER CODE BEGIN CALL_BACK_21 */
switch(id)
{
case HOST_USER_SELECT_CONFIGURATION:
break;
case HOST_USER_DISCONNECTION:
Appli_state = APPLICATION_DISCONNECT;
printf("FS DISCONNECT\r\n");
break;
case HOST_USER_CLASS_ACTIVE:
Appli_state = APPLICATION_READY;
printf("FS READY\r\n");
break;
case HOST_USER_CONNECTION:
Appli_state = APPLICATION_START;
printf("FS START\r\n");
break;
default:
break;
}
/* USER CODE END CALL_BACK_21 */
}
2019-12-10 05:39 AM
I have enabled data output for DEBUG:
usbh_conf.h --> #define USBH_DEBUG_LEVEL 3U // 0U
Note that processes are restarted several times, and then the process stops responding.
Log:
[00]USB Device Attached
PID: 318h
VID: 513h
Address (#1) assigned.
Manufacturer : N/A
Product : N/A
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Device remote wakeup enabled
Switching to Interface (#0)
Class : 3h
SubClass : 1h
Protocol : 1h
KeyBoard device found!
HID class started.
USB Device disconnected
USB Device Attached
PID: 318h
VID: 513h
Address (#1) assigned.
Manufacturer : N/A
Product : N/A
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Device remote wakeup enabled
Switching to Interface (#0)
Class : 3h
SubClass : 1h
Protocol : 1h
KeyBoard device found!
HID class started.
USB Device disconnected
USB Device Attached
PID: 318h
VID: 513h
Address (#1) assigned.
Manufacturer : N/A
Product : N/A
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Device remote wakeup enabled
Switching to Interface (#0)
Class : 3h
SubClass : 1h
Protocol : 1h
KeyBoard device found!
HID class started.
USB Device disconnected
USB Device Attached
PID: 318h
VID: 513h
Address (#1) assigned.
Manufacturer : N/A
Product : N/A
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Device remote wakeup enabled
Switching to Interface (#0)
Class : 3h
SubClass : 1h
Protocol : 1h
KeyBoard device found!
HID class started.
USB Device disconnected
USB Device Attached
PID: 318h
VID: 513h
Address (#1) assigned.
Manufacturer : N/A
Product : N/A
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Device remote wakeup enabled
Switching to Interface (#0)
Class : 3h
SubClass : 1h
Protocol : 1h
KeyBoard device found!
HID class started.
USB Device disconnected
USB Device Attached
PID: 318h
VID: 513h
Address (#1) assigned.
Manufacturer : N/A
Product : N/A
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Device remote wakeup enabled
Switching to Interface (#0)
Class : 3h
SubClass : 1h
Protocol : 1h
KeyBoard device found!
HID class started.
USB Device disconnected
USB Device Attached
PID: 318h
VID: 513h
Address (#1) assigned.
Manufacturer : N/A
Product : N/A
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Device remote wakeup enabled
Switching to Interface (#0)
Class : 3h
SubClass : 1h
Protocol : 1h
KeyBoard device found!
HID class started.
USB Device disconnected
USB Device Attached
2019-12-10 05:50 AM
If a keyboard key is pressed continuously, the process remains stable, but when the keyboard is turned off by its power switch, the process restarts, and then locks up. To work again you need to restart uC.
[00]USB Device Attached
PID: 318h
VID: 513h
Address (#1) assigned.
Manufacturer : N/A
Product : N/A
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Device remote wakeup enabled
Switching to Interface (#0)
Class : 3h
SubClass : 1h
Protocol : 1h
KeyBoard device found!
HID class started.
aaaaaaaaaaaaaaaaaaassssaasssssbb <--- (Pulsed keys)
USB Device disconnected <--- (Keyboard: power off)
USB Device Attached
PID: 318h
VID: 513h
Address (#1) assigned.
Manufacturer : N/A
Product : N/A
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Device remote wakeup enabled
Switching to Interface (#0)
Class : 3h
SubClass : 1h
Protocol : 1h
KeyBoard device found!
HID class started.
USB Device disconnected
USB Device Attached
2019-12-10 05:53 AM
Would an automatic reset be required when the device is disconnected?
2019-12-10 06:08 AM
Note: I am not using additional pins like Drive_VBUS or VBUS, I am using only DM and DP wires. Could this be affecting the reboot process?
2019-12-11 08:48 PM
I watched the training videos on YouTube:
(https://www.youtube.com/watch?v=rI3yBmnfAZU&list=PLnMKNibPkDnFFRBVD206EfnnHhQZI4Hxa)
The video examples worked, but I still can't make this keyboard work properly.
I noticed that the library found two interfaces.
How can I receive data from both interfaces at the same time?
It seems that the library is implementing only the first interface, and when the touchpad is triggered the library gets lost and stops responding.
Got some data on Windows using USBPcap
1-Descriptor Request DEVICE:
2-Descriptor Response DEVICE:
3-GET DESCRIPTOR Request CONFIGURATION:
4a-GET DESCRIPTOR Response CONFIGURATION:
4b-GET DESCRIPTOR Response CONFIGURATION:
5-SET CONFIGURATION Request:
6-SET CONFIGURATION Response:
7-URB_INTERRUPT in:
8-URB_INTERRUPT in:
9-URB_INTERRUPT in:
2019-12-11 10:09 PM
I may have found the answer to this keyboard not working.
Post content found:
USB Library with device having multiple interfaces
Posted on October 22, 2016 at 04:27
I am not sure if this is a bug fix or an enhancement.
I am developing on a proprietary board using the STM32F7 series processor. I have a device connected via USB using the USB Host Library. This particular device has more than just a CDC interface and the CDC is NOT the first one in the descriptor list. The USB Library source file usbh_core.c has code which should be looking through all of the interfaces, but only looks at the first. To fix this, I changed this:
case HOST_CHECK_CLASS:
if (phost->ClassNumber == 0)
{
USBH_UsrLog(''No Class has been registered.'');
}
else
{
phost->pActiveClass = NULL;
for (idx = 0; idx <
USBH_MAX_NUM_SUPPORTED_CLASS
; idx++)
{
if ((phost->pClass [ idx ]->ClassCode == phost->device.CfgDesc.Itf_Desc [ 0 ].bInterfaceClass))
{
phost->pActiveClass = phost->pClass [ idx ];
}
}
to this:
case HOST_CHECK_CLASS:
if (phost->ClassNumber == 0)
{
USBH_UsrLog(''No Class has been registered.'');
}
else
{
phost->pActiveClass = NULL;
for (idx = 0; idx <
USBH_MAX_NUM_SUPPORTED_CLASS
; idx++)
{
for (int
infx
=
0
; infx < USBH_MAX_NUM_INTERFACES; infx++)
{
if ((phost->pClass [ idx ]->ClassCode == phost->device.CfgDesc.Itf_Desc [ infx ].bInterfaceClass))
{
phost->pActiveClass = phost->pClass [ idx ];
break;
}
}
}
This picks up all of the interfaces in the descriptor. I also modified usbh_cdc.c in the
function to return separate notification and data interfaces. Worked out well in the long run. You should also change the SetLineCoding and GetLineCoding functions - and maybe a couple of others - so that the ''0'' interface is not the default interface. Use the current interface. I spent a week wondering why everything worked great over the base/notification interface but terrible on the data interfaces. Discovered the problem tonight. In usbh_core.c
uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t SubClass, uint8_t Protocol, int8_t startWith)
{
USBH_InterfaceDescTypeDef *pif;
USBH_CfgDescTypeDef *pcfg;
int8_t if_ix = startWith; //0; <-- was searching from the first interface for the associated data interface - should start from current interface
So, references to this function need an extra parameter for setting a starting index. The bug here is that the function was always returning the data interface for the first interface when I needed it from the next interface pair after the first. Hope this helps people who are using USB devices with multiple interfaces or fixes a bug in the library. #!stm32-!usb-!library-!interfaces