AnsweredAssumed Answered

how to read key F1, F2..... from keyboard with stm32f4-- I did it.   file Keyboard_done

Question asked by nguen nguyen on May 1, 2018
Latest reply on May 3, 2018 by nguen nguyen

stm32f411 disco. connect with keyboard via USB

 

uint8_t GetKey(void)
{
uint32_t c;
if(Appli_state==APPLICATION_START)
{
if(USBH_HID_GetDeviceType(&hUsbHostFS) == HID_KEYBOARD)
{

k_pinfo = USBH_HID_GetKeybdInfo(&hUsbHostFS);

if(k_pinfo != NULL)
{
c = USBH_HID_GetASCIICode(k_pinfo);
}

return c;

}

 

//---------------------------

 

while (1)
{

/* USER CODE END WHILE */
MX_USB_HOST_Process();

/* USER CODE BEGIN 3 */

d=GetKey();

if (d == '1' ) HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_SET);

if (d == '2') HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_RESET);


}

Attachments

Outcomes