cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 Disco1 HOST HID

Embedded Learner
Associate
Posted on December 14, 2017 at 08:16

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  :

&sharpinclude 'main.h'

&sharpinclude 'stm32f4xx_hal.h'

&sharpinclude 'usb_host.h'

&sharpinclude'usb_host.h'

&sharpinclude'usbh_hid.h'

&sharpinclude'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.

#stm32f429-usb-hid #stm32f4 #usb-hid-host-keyboard-stm32f4 #stm32f4-disco #stm32f4-usb-host
1 REPLY 1

Sorry, bumping old zombie unanswered threads off my feed

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..