This example demonstrates the reading of the USB Gamepad in the Nucleo.

Dependencies:   mbed

Intro

This example demonstrates the reading of the USB Gamepad in the Nucleo.

Parts

STM32 Nucleo F446RE
USB Connector
LED 2pcs
Register 470 ohm 2pcs
Breadboard
Wires

Wiring diagram

/media/uploads/beaglescout007/nucleo_ex04_usbpad.png This circuit diagram was created by fritzing.

/media/uploads/beaglescout007/usbcon.jpg

USB con.Nucleo
GNDGND
+PA_12
-PA_11
5V5V

https://youtu.be/EYIukjwJSew

Original Library

Committer:
beaglescout007
Date:
Tue Mar 15 11:39:04 2016 +0000
Revision:
0:b5f79b4f741d
Release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
beaglescout007 0:b5f79b4f741d 1 #include "mbed.h"
beaglescout007 0:b5f79b4f741d 2
beaglescout007 0:b5f79b4f741d 3 struct SETUP_PACKET {
beaglescout007 0:b5f79b4f741d 4 uint8_t bmRequestType;
beaglescout007 0:b5f79b4f741d 5 uint8_t bRequest;
beaglescout007 0:b5f79b4f741d 6 uint16_t wValue;
beaglescout007 0:b5f79b4f741d 7 uint16_t wIndex;
beaglescout007 0:b5f79b4f741d 8 uint16_t wLength;
beaglescout007 0:b5f79b4f741d 9 SETUP_PACKET(uint8_t RequestType, uint8_t Request, uint16_t Value, uint16_t Index, uint16_t Length) {
beaglescout007 0:b5f79b4f741d 10 bmRequestType = RequestType;
beaglescout007 0:b5f79b4f741d 11 bRequest = Request;
beaglescout007 0:b5f79b4f741d 12 wValue = Value;
beaglescout007 0:b5f79b4f741d 13 wIndex = Index;
beaglescout007 0:b5f79b4f741d 14 wLength = Length;
beaglescout007 0:b5f79b4f741d 15 }
beaglescout007 0:b5f79b4f741d 16 };
beaglescout007 0:b5f79b4f741d 17
beaglescout007 0:b5f79b4f741d 18 #if defined(TARGET_NUCLEO_F401RE)||defined(TARGET_NUCLEO_F411RE)||defined(TARGET_NUCLEO_F446RE)
beaglescout007 0:b5f79b4f741d 19 #include "USBHALHost_F401RE.h"
beaglescout007 0:b5f79b4f741d 20 #elif defined(TARGET_KL46Z)||defined(TARGET_KL25Z)||defined(TARGET_K64F)
beaglescout007 0:b5f79b4f741d 21 #include "USBHALHost_KL46Z.h"
beaglescout007 0:b5f79b4f741d 22 #elif defined(TARGET_LPC4088)||defined(TARGET_LPC1768)
beaglescout007 0:b5f79b4f741d 23 #include "USBHALHost_LPC4088.h"
beaglescout007 0:b5f79b4f741d 24 #else
beaglescout007 0:b5f79b4f741d 25 #error "target error"
beaglescout007 0:b5f79b4f741d 26 #endif
beaglescout007 0:b5f79b4f741d 27
beaglescout007 0:b5f79b4f741d 28 #ifndef CTASSERT
beaglescout007 0:b5f79b4f741d 29 template <bool>struct CtAssert;
beaglescout007 0:b5f79b4f741d 30 template <>struct CtAssert<true> {};
beaglescout007 0:b5f79b4f741d 31 #define CTASSERT(A) CtAssert<A>();
beaglescout007 0:b5f79b4f741d 32 #endif // CTASSERT
beaglescout007 0:b5f79b4f741d 33
beaglescout007 0:b5f79b4f741d 34
beaglescout007 0:b5f79b4f741d 35