AnsweredAssumed Answered

STM32F429 Disco1 HOST HID

Question asked by Embedded Learner on Dec 14, 2017

Code Generator using cubeMX for STM32F429 Disco1 HOST HID.

Keyboard Behavior:

When I connect Keyboard, It Shows that keyboard is connected. But If I press any key on keyboard. Immediately USB disconnected routines start executing. C Code  :

 

#include "main.h"

#include "stm32f4xx_hal.h"

#include "usb_host.h"

#include"usb_host.h"

#include"usbh_hid.h"

#include"usbh_def.h"

 

extern ApplicationTypeDef Appli_state;

HID_TypeTypeDef hidDevice;

extern USBH_HandleTypeDef hUsbHostHS;

 

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

void MX_USB_HOST_Process(void);

uint8_t key;

 

int main(void)

{

     HID_KEYBD_Info_TypeDef *keybdInfo=NULL;

     HAL_Init();

     MX_USB_HOST_Init();

 

     while (1){

          MX_USB_HOST_Process();

          switch(Appli_state){

               case APPLICATION_READY:

                    hidDevice=USBH_HID_GetDeviceType(&hUsbHostHS);

                    switch(hidDevice){

                         case HID_KEYBOARD:

                              keybdInfo=USBH_HID_GetKeybdInfo(&hUsbHostHS); /*if commented out this line, then keyboard is not disconnected on key press*/

                              if(keybdInfo!=NULL){

                                   key=USBH_HID_GetASCIICode(keybdInfo);

                              }

                              break;

                         case HID_MOUSE:

                              break;

                         case HID_UNKNOWN:

                              break;

                    }

                    break;

               case APPLICATION_DISCONNECT:        

                    break;

          }

  }

}

Mouse Behavior:

On connecting USB mouse, after showing USB is connected, immediately USB gets disconnected routine start executing. Even there is no code for mouse as you see in above code.

 

Please can anyone throw light on exact issue? Why i am getting disconnected message without removing USB HID device? What is the solution to this problem.

Outcomes