5 Replies Latest reply on Sep 1, 2020 12:34 AM by taas_3144281

    USB HID Basics with PSoC 5LP

    taas_3144281

      Hi.

       

      This sample uses CY8CKIT-059.

      This sample code is based on “https://www.cypress.com/documentation/application-notes/an57473-usb-hid-basics-psoc-3-and-psoc-5lp”.

      This "AN57473" has 5 buttons, but add 1 button to make 6 buttons.

      I hope this sample will help you evaluate USB HID.

       

       

       

      schematics

       

       

       

       

      Pin list

       

       

      USBFS component

       

       

      AN57473        This sample

      Usage Maximum (5) ⇒ Usage Maximum (6)

      Report Count (5)    ⇒ Report Count (6)

      Report Size (3)     ⇒ Report Size (2)

       

       

      main.c

      ===========================================

      void ReadButtons (void)

      {

      if(Thumb_Button_Read() != 0)                   /* Detect if button was pressed        */

      Buttons |= 0x01;                                         /* If pressed, mask bit to indicate button press */

      else

      Buttons &= ~0x01;                                      /* If released, clear bit */

       

      if(Button_A_Read() != 0)

      Buttons |= 0x02;

      else

      Buttons &= ~0x02;

       

      if(Button_B_Read() != 0)

      Buttons |= 0x04;

      else

      Buttons &= ~0x04;

       

      if(Button_C_Read() != 0)

      Buttons |= 0x08;

      else

      Buttons &= ~0x08;

       

      if(Button_D_Read() != 0)

      Buttons |= 0x10;

      else

      Buttons &= ~0x10;

        

               if(Button_E_Read() != 0)       

               Buttons |= 0x20;

               else

               Buttons &= ~0x20;

      }

       

      ===========================================

       

       

       

      Breadboard wiring diagram

       

       

       

      Game controller property

       

       

       

      Thanks,

      Asanuma