USB HID Basics with PSoC 5LP

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
taas_3144281
Level 5
Level 5
Distributor - Marubun (Japan)
25 sign-ins 50 replies posted 25 replies posted

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

pastedImage_5.png

Pin list

pastedImage_6.png

USBFS component

pastedImage_7.png

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

pastedImage_9.png

Game controller property

pastedImage_8.png

Thanks,

Asanuma

5 Replies