Vendor Example (vendor)
This application demonstrates the ability of the MPLAB Harmony USB Device Stack to support Vendor Device class.
Description
This application creates a USB CDC Device that enumerates as a custom vendor USB device on the USB host PC. The device uses USB Device Layer Endpoint functions and demonstrates the PC host’s ability to control the LEDs on the board and query the status of a switch through PC utility.
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_device/apps/vendor.
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 |
pic32mx470_curiosity.X | MPLABX | PIC32MX470F512H | PIC32MX Curiosity Development Board |
pic32mz_ef_sk.X | MPLABX | PIC32MZ2048EFH144 | PIC32MZ Embedded Connectivity with FPU (EF) Starter Kit |
pic32mz_ef_sk_freertos.X | MPLABX | PIC32MZ2048EFH144 | PIC32MZ Embedded Connectivity with FPU (EF) Starter Kit |
pic32mm_usb_curiosity.X | MPLABX | PIC32MM0256GPM064 | PIC32MM USB Curiosity Development Board |
sam_9x60_ek.X | MPLABX | SAM9X60 | SAM9X60-EK Evaluation Board |
sam_9x60_ek_freertos.X | MPLABX | SAM9X60 | SAM9X60-EK Evaluation Board |
sam_a5d2_xult.X | MPLABX | ATSAMA5D27C | SAMA5D2 Xplained Ultra Board |
sam_a5d2_xult_iar.IAR | IAR | ATSAMA5D27C | SAMA5D2 Xplained Ultra Board |
sam_a5d27_som1_ek.X | MPLABX | ATSAMA5D27C | SAMA5D27 SOM1 Kit1 |
sam_a5d27_wlsom1_ek1.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_e54_xpro_freertos.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 |
sam_v71_xult.X | MPLABX | ATSAMV71Q21B | SAMV71 Xplained Ultra board |
Configuring the Hardware
SAMD21 Xplained Pro Board
- Use TARGET USB connector on the board to connect the USB Device to the USB Host PC.
- LED0 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
- Press the switch SW0 to trigger communication from the USB Device to the USB Host.
SAME54 Xplained Pro Board
- Use TARGET USB connector on the board to connect the USB Device to the USB Host PC.
- LED0 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
- Press the switch SW0 to trigger communication from the USB Device to the USB Host.
SAME70 Xplained Ultra Board
- Jumper J203 must be shorted between PB08 and VBUS (positions 2 and 3).
- Use TARGET USB J200 connector on the board to connect the USB Device to the USB Host PC.
- LED3 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
- Press the switch SW1 to trigger communication from the USB Device to the USB Host.
SAMV71 Xplained Ultra board
- Jumper titled “USB VBUS” must be shorted between PC09 and VBUS (positions 2 and 3)
- Use TARGET USB connector on the board to connect the USB Device to the USB Host PC.
- LED0 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
SAMG55 Xplained Pro Board
- Use TARGET USB connector on the board to connect the USB Device to the USB Host PC.
- LED0 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
- Press the switch SW0 to trigger communication from the USB Device to the USB Host.
SAM9X60-EK Evaluation Board
- Setup the SD card
- 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 the debug com port).
- Connect the USB Micro-B Connector (J7) on the board to the computer using a micro USB cable.
- LED D1 indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
-
Press the switch SW1 to trigger communication from the USB Device to the USB Host.
Note: Reset push button on SAM9X60 EK is labeled as SW3
SAMA5D2 Xplained Ultra Board
- Setup the SD card
- 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
- Short jumper JP2(DEBUG_DIS)
- Connect the Debug USB port on the board to the computer using a micro USB cable
- Use “A5-USB-A” connector(J23 - Micro A/B connector) on the board to connect the USB Device to the USB Host.
- RGB LED turning to Green indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
- Press PB_USER Switch to trigger communication from the USB Device to the USB Host
Curiosity PIC32MX470 Development Board
- Use the USB micro-B port J12 to connect the USB Device to the USB Host PC.
- LED1 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
- Press the switch S1 to trigger communication from the USB Device to the USB Host.
Curiosity PIC32MZ EF 2.0 Development Board
- Use the USB micro-B port J201 to connect the USB Device to the USB Host PC.
- LED2 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
- Press the switch SW1 to trigger communication from the USB Device to the USB Host.
PIC32MZ Embedded Connectivity with FPU (EF) Starter Kit
- Use the micro-A/B port J4 (which is located on the bottom side of the board) to connect the USB Device to the USB Host PC.
- LED2 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
- Press the switch SW1 to trigger communication from the USB Device to the USB Host.
SAMA5D27 SOM1 Kit1
- Setup the SD card
- 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 Debug USB port (J10) on the board to the computer using a micro USB cable.
- Connect the USB Micro-B Connector (J17) on the board to the computer using a micro USB cable.
- RGB LED turning to Green indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
- Press the pushbutton PB4 to trigger communication from the USB Device to the USB Host.
ATSAMA5D27-WLSOM1 Evaluation Kit
- Setup the SD card
- 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 MicroAB connector (J10) on the board to the computer using a micro USB cable.
- Press the “START_SOM” button to activate board start-up.
- RGB LED turning to Green indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
- Press the pushbutton SW4 to trigger communication from the USB Device to the USB Host.
PIC32MM USB Curiosity Development Board
- Use the micro-B USB connector USB2 on the board to connect the USB Device to the USB Host PC.
- LED1 indicates USB Device Configuration Set Complete event (the USB device functionality has been activated by the USB Host).
- Press the switch S1 to trigger communication from the USB Device to the USB Host.
SAMA7G5-EK Evaluation Kit
- Powered the board with an external power supply (J1) or power supply the board by connecting J7 to the computer using a micro USB cable.
- Setup the SD card
- 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 SD Card Connector (J4) on the board.
- Reset the board by pressing the Reset Button (nRST)
- Press the “nSTART” button to activate board start-up.
- Connect the USB MicroAB connector (J7) to the computer using an USB cable.
- RGB LED turning to Green indicates USB Device Configuration Set Complete event (The USB device functionality has been activated by the USB Host).
- Press the USER BUTTON SW1 to trigger communication from the USB Device to the USB Host.
Running the Application
The Vendor device can be exercised by using the WinUSB PnP Demonstration application, which is provided in your installation of MPLAB Harmony.
The LEDs on the demonstration board will indicate the USB state of the device. This application allows the state of the LEDs on the board to be toggled and indicates the state of a switch (pressed/released) on the board. Refer to the Configuring the Hardware section for the selected target hardware.
To launch the application, open the executable WinUSB_PnP_Demo.exe from the folder path usb_apps_device/apps/vendor/bin/WinUSB_PnP_Demo.exe. A dialog box similar to the following should appear:
The appropriate device family that is under testing should be selected in the utility. Pressing the Toggle LED button will cause the LED on the board to toggle. The Pushbutton State field in the application indicates the state of a button on connected USB Device. Pressing the switch on the development board will update the Pressed/Not Pressed status of the Pushbutton State field. Note: The device family under test should be selected appropriately. An incorrect selection will result in an invalid push button status. Windows Operating system may select a wrong driver by default. If the application does not run as expected it is suggested to look into the Windows Device Manager and see if the Microchip WinUSB Device is not shown with a Yellow mark. If so, the drivers should be selected manually from the application path.
Manual selection of Drivers
To specifically select the driver, open the device manager and look for device named as WinUSB Device with a Yellow mark. Right click and select Update Driver Software. Select Browse my computer for drivers. Select the drivers in application path ..\usb_apps_device\apps\vendor\driver.