Link Search Menu Expand Document

MCHP

HID Basic Mouse USART Example (hid_basic_mouse_usart)

This application demonstrates the use of the USB HID Host Client Driver to enumerate and operate a HID USB Mouse device.

Description

This application uses the USB Host layer, HID Client driver and HID Mouse Usage driver to enumerate a USB Mouse and detect Mouse button press release events. The Mouse events are displayed using a terminal emulator on a personal computer.

Downloading and building the application

To clone or download this application from Github, go to the main page of this repository and then click Clone button to clone this repository or download as zip file. This content can also be downloaded using content manager by following these instructions.

Path of the application within the repository is usb_apps_host/apps/hid_basic_mouse_usart.

Following table gives the details of project configurations, target device used, hardware and its IDE. Open the project using the respective IDE and build it.

Project Name IDE Target Device Hardware / Configuration
pic32mz_ef_curiosity_2_0.X MPLABX PIC32MZ2048EFM144 Curiosity PIC32MZ EF 2.0 Development Board
sam_9x60_ek.X MPLABX SAM9X60 SAM9X60-EK Evaluation Board
sam_9x60_ek_freertos.X MPLABX SAM9X60 SAM9X60-EK Evaluation Board
sam_9x60_curiosity.X MPLABX SAM9X60 SAM9X60 Curiosity Development Board
sam_9x60_curiosity_freertos.X MPLABX SAM9X60 SAM9X60 Curiosity Development Board
sam_9x75_eb.X MPLABX SAM9X75 SAM9X75-DDR3-EB Evaluation Board
sam_a5d2_xult.X MPLABX ATSAMA5D27C SAM A5D2 Xplained Ultra Board
sam_a5d2_xult_freertos.X MPLABX ATSAMA5D27C SAMA5D2 Xplained Ultra Board
sam_a5d27_som1_ek.X MPLABX ATSAMA5D27C SAMA5D27 SOM1 Kit1
sam_a5d27_som1_ek_freertos.X MPLABX ATSAMA5D27C SAMA5D27 SOM1 Kit1
sam_a5d27_wlsom1_ek1.X MPLABX ATSAMA5D27C ATSAMA5D27 WLSOM1 EK1
sam_a5d27_wlsom1_ek1_freertos.X MPLABX ATSAMA5D27C ATSAMA5D27 WLSOM1 EK1
sam_a7g5_ek.X MPLABX SAMA7G54 SAMA7G5 EK Board
sam_d21_xpro.X MPLABX ATSAMD21J18A SAMD21 Xplained Pro Board
sam_e54_xpro.X MPLABX ATSAME54P20A SAME54 Xplained Pro Board
sam_e70_xult.X MPLABX ATSAME70Q21B SAME70 Xplained Ultra Board
sam_e70_xult_freertos.X MPLABX ATSAME70Q21B SAME70 Xplained Ultra Board
sam_g55_xpro.X MPLABX ATSAMG55J19 SAMG55 Xplained Pro Board
pic32cz_ca80_curiosity_ultra.X MPLABX PIC32CZ8110CA80208 PIC32CZ Curiosity Development Board
pic32ck_gc01_curiosity_ultra.X MPLABX PIC32CK2051GC01144 PIC32CK Curiosity Development Board

Configuring the Hardware

PIC32CZ CA80 Curiosity Development Board

  • A commercially available USB Mouse is required to run this demonstration application.
  • Connect the USB Mouse to the connector (J102) using a USB Type-A Female to micro-B male cable (This cable is not included in the kit).
  • LED0 indicates a Device Connection (Attached device has been successfully enumerated and configured). This LED is also toggled on the Mouse Button press event.
  • The demonstration uses the PKOB4 Serial Interface to transfer messages on a PC.

PIC32CK Curiosity Development Board

  • A commercially available USB Mouse is required to run this demonstration application.
  • Connect the USB Mouse to the USB Type-C connector (J202). A USB Type-C to Type-A Female adapter is required to connect the USB device to the board (This adapter is not included in the kit).
  • LED1 indicates a Device Connection (Attached device has been successfully enumerated and configured). This LED is also toggled on the Mouse Button press event.
  • The demonstration uses the PKOB4 Serial Interface to transfer messages on a PC.

Curiosity PIC32MZ EF 2.0 Development Board

  • A commercially available USB Mouse is required to run this demonstration application.
  • Connect the USB Mouse to the “TARGET USB” connector (J201) using a USB Type-A Female to micro-B male cable (This cable is not included in the kit).
  • LED1 indicates a Device Connection (Attached device has been successfully enumerated and configured). This LED is also toggled on the Mouse Button press event.

  • The demonstration uses the PKOB4 Serial Interface to transfer messages on a PC.

SAMD21 Xplained Pro Board

  • A commercially available USB Mouse is required to run this demonstration application.
  • Jumper titled “PA03 SELECT” must be shorted between PA03 and USB_ID(positions 2 and 3)
  • Use “TARGET USB” connector on the board to connect the USB Mouse to the USB Host. A USB micro AB to type A USB Host receptacle converter will be needed to connect the device.
  • LED0 indicates a Device Connection. (Attached device has been successfully enumerated and configured). This LED is also toggled on Mouse Button press event.
  • The demonstration uses the EDBG Serial Interface to transfer demonstration application messages on a PC.

SAME54 Xplained Pro Board

  • A commercially available USB Mouse is required to run this demonstration application.
  • Use “TARGET USB” connector on the board to connect the USB Mouse to the USB Host. A USB micro AB to type A USB Host receptacle converter will be needed to connect the device.
  • LED0 indicates a Device Connection. (Attached device has been successfully enumerated and configured). This LED is also toggled on Mouse Button press event.
  • The demonstration uses the EDBG Serial Interface to transfer demonstration application messages on a PC.

SAME70 Xplained Ultra Board

  • A commercially available USB Mouse is required to run this demonstration application.
  • Jumper J203 must be shorted between PB08 and LED2(positions 1 and 2).
  • Use “TARGET USB” J200 connector on the board to connect the USB Mouse to the USB Host. A USB micro AB to type A USB Host receptacle converter will be needed to connect the device.
  • LED3 indicates a Device Connection. (Attached device has been successfully enumerated and configured). This LED is also toggled on Mouse Button press event.
  • The demonstration uses the EDBG Serial Interface to transfer demonstration application messages on a PC.

SAMG55 Xplained Pro Board

  • A commercially available USB Mouse is required to run this demonstration application.
  • Chip Erase Jumper must be open.
  • Use TARGET USB connector on the board to connect the USB Mouse to the USB Host. A USB micro AB to type A USB Host receptacle converter will be needed to connect the device.
  • LED0 indicates a Device Connection. (Attached device has been successfully enumerated and configured). This LED is also toggled on Mouse Button press event.
  • The demonstration uses the EDBG Serial Interface to transfer demonstration application messages on a PC.

SAM9X60-EK Evaluation Board

  • A commercially available USB Mouse is required to run this demonstration application.
  • Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    • Download harmony MPU bootstrap loader from this location.
    • Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    • Insert the SD card into the SDMMC connector J4 on the board.
    • Reset the board by pressing the Push Button SW3.
  • Jumpers J20, J21, and J13 must be open.
  • Jumper J2 and J3 must be shorted.
  • Connect the USB Micro-B port (J22) on board to the computer using a micro USB cable (to enable debug com port).
  • Connect the USB Micro-B Connector (J7) on the board to the computer using a micro USB cable to power up the board.
  • Connect the USB Mouse to the Type-A connector (J8).
  • LED D1 indicates a Device Connection Attached device has been successfully enumerated and configured). This LED is also toggled on the Mouse Button press event.
  • The demonstration uses the USB Micro-B port (J22) to transfer demonstration application messages on a PC.

    SAM9X60-EK Evaluation Board

    Note: Reset push button on SAM9X60 EK is labelled as SW3

SAM9X60-Curiosity Board

  • Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    • Download harmony MPU bootstrap loader from this location.
    • Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    • Insert the SD card into the SDMMC0 connector J3 on the board.
    • Reset the board by pressing the Push Button RESET.
  • Jumper J4 must be shorted.
  • Connect the USB Micro-B Connector (J1) on the board to the computer using a micro USB cable.
  • Connect the USB device to the Type-A connector (J10).
  • LED D1 indicates a Device Connection Attached device has been successfully enumerated and configured). This LED is also toggled on the Mouse Button press event.
  • The demonstration uses an USB to serial cable to transfer demonstration application messages on a PC.

    SAM9X60-EK Evaluation Board

SAM9X75-DDR3-EB Evaluation Board

  • A commercially available USB Mouse is required to run this demonstration application.
  • Powered the board with an external power supply (or use the micro AB connector).
  • Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    • Download harmony MPU bootstrap loader from this location.
    • Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    • Insert the SD card into the SDMMC connector (SDMMC0) on the board.
    • Reset the board by pressing the Push Button RESET, then START.
  • Connect an USB to serial cable to DBGU0 (to enable debug com port).
  • Connect the USB device to the Type-A connector or to the micro AB with a specific dongle (in these case the need to be powered by the external power supply).
  • LED near VDDCORE inscription on the board indicates a Device Connection Attached device has been successfully enumerated and configured). This LED is also toggled on the Mouse Button press event.
  • The demonstration uses an USB to serial cable to transfer demonstration application messages on a PC.

    SAM9X75-DDR3-EB Evaluation Board

SAMA5D2 Xplained Ultra Board

  • A commercially available USB Mouse is required to run this demonstration application.
  • Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    • Download harmony MPU bootstrap loader from this location.
    • Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    • Insert the SD card into the SDMMC1 slot on the board.
    • Reset the board by pressing the Push Button BP3.
  • Connect the EDBG USB Micro-B port J14 on the board to the computer using a micro USB cable.
  • Connect the USB Mouse to the USB Type-A connector “A5-USB-B” (J13).
  • RGB LED indicates a Device Connection (Attached device has been successfully enumerated and configured). This LED is also toggled on the Mouse Button press event.
  • The demonstration uses the EDBG USB Micro-B port J14 to transfer demonstration application messages on a PC.

SAMA5D27 SOM1 Kit1

  • A commercially available USB Mouse is required to run this demonstration application.
  • Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    • Jumper J9 must be removed to have the JTAG-CDC enable.
    • Download harmony MPU bootstrap loader from this location.
    • Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    • Insert the SD card into the SDMMC0 slot (J12) on the board.
    • Reset the board by pressing the Push Button PB1.
  • Connect the USB Micro-AB port (J10) on the board to the computer using a micro USB cable.
  • Connect the USB Mouse to the USB-B Type-C connector (J19) on the board.
  • RGB LED indicates a Device Connection (Attached device has been successfully enumerated and configured). This LED is also toggled on the Mouse Button press event.
  • The demonstration uses the USB Micro-AB port (J10) to transfer demonstration application messages on a PC. SAMA5D27 SOM1 Kit1

ATSAMA5D27-WLSOM1 Evaluation Kit

  • A commercially available USB Mouse is required to run this demonstration application.
  • Setup the SD card (Note: exFAT formatted SD Cards are not supported)
    • Download harmony MPU bootstrap loader from this location.
    • Copy the downloaded boot loader binary (boot.bin) and generated application binary (harmony.bin) into the SD card.
    • Insert the SD card into the SDMMC0 Card Connector (J9) on the board.
    • Reset the board by pressing the Reset Button (SW2)
  • Connect the USB-A Micro-AB connector (J10) on the board to the computer using a micro USB cable.
  • Press the “START_SOM” button to activate board start-up.
  • Connect the USB Mouse to the USB Type-A connector (J11) on the board.
  • RGB LED indicates a Device Connection (Attached device has been successfully enumerated and configured). This LED is also toggled on the Mouse Button press event.
  • The demonstration uses the Debug UART port (J26) to transfer demonstration application messages on a PC. A USB/Serial converter is required to connect the J26 to a PC (The USB/Serial converter is not included in the kit). ATSAMA5D27 WLSOM1 EK1

Running the Application

  1. Open the project with appropriate IDE. Compile the project and program the target device.
  2. Launch a terminal emulator, such as Tera Term. Select the appropriate COM port and set the serial port settings to 115200-N-1.
  3. If a USB mouse is not connected to the Host connector, the serial terminal emulator window will show the “Connect Mouse” prompt.
  4. Attach a USB mouse to the Host connector of the target hardware. Refer to the Configuring the Hardware section for any converter requirements. The message, “Mouse Connected”, will display in the serial terminal emulator window.
  5. Begin moving the mouse and the appropriate relative coordinate changes for X,Y, and Z axes should be displayed in the serial terminal window.
  6. Click the mouse button to toggle LEDs on the board. Refer to the Configuring the Hardware section for details on the relevant LED.
  7. Disconnecting the mouse will result in the message, “Connect Mouse”, to reappear on the serial console.

    Found New Hardware Wizard



Copyright © 2020 Microchip Technology.