cancel
Showing results for 
Search instead for 
Did you mean: 

Need to use stm32f407vgt6 discovery board to connect with HID card reader via USB OTG

Akkarachai
Associate

Need to use stm32f407vgt6 discovery board to connect with HID card reader via USB OTG.
Now I was using stm32 to read keyboard input successfully but I think the HID card reader works the same with the keyboard so I was using the same code but nothing happened the stm32 cannot read the data from the HID reader.

Lib that I used:  "usbh_hid.h" , "usb_host.h"

My code: 

 

void USBH_HID_EventCallback(USBH_HandleTypeDef *phost) {

if (USBH_HID_GetDeviceType(phost) == HID_KEYBOARD) {

HID_KEYBD_Info_TypeDef *Keyboard_Info;

Keyboard_Info = USBH_HID_GetKeybdInfo(phost); // get the info

key = USBH_HID_GetASCIICode(Keyboard_Info); // get the key pressed

sprintf (Uart_Buf, "%c", key);

}

}

 

Thank you

3 REPLIES 3
Pavel A.
Evangelist III

 I think the HID card reader works the same with the keyboard 

Are you sure? Does your reader simulate a keyboard (sequence of keypresses/scan codes)? Or it has a different HID report format, with a different size, report index etc.?

 

I'm not sure but, I was testing HID card reader connect to my PC and open notepad then scan the card the card number was printing on my notepad like I type with keyboard.

Pavel A.
Evangelist III

Well then it likely emulates a keyboard. If you don't see any input  from it, maybe it is a composite device where a keyboard is one of functions. This can be seen in Windows device manager or Microsoft's utility UsbView. In that case you need to decode the function descriptor of the keyboard function and find the endpoint number to read from.