This example demonstrates the reading of the USB Gamepad in the Nucleo.
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
This circuit diagram was created by fritzing.
USB con. | Nucleo |
---|---|
GND | GND |
+ | PA_12 |
- | PA_11 |
5V | 5V |
Original Library
- F401RE-USBHost by Norimasa Okamoto
- USBHostGamepad by Yuuichi Akagawa
USBHost/myvector.h@0:b5f79b4f741d, 2016-03-15 (annotated)
- Committer:
- beaglescout007
- Date:
- Tue Mar 15 11:39:04 2016 +0000
- Revision:
- 0:b5f79b4f741d
Release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
beaglescout007 | 0:b5f79b4f741d | 1 | #pragma once |
beaglescout007 | 0:b5f79b4f741d | 2 | |
beaglescout007 | 0:b5f79b4f741d | 3 | template<class T> |
beaglescout007 | 0:b5f79b4f741d | 4 | class myvector { |
beaglescout007 | 0:b5f79b4f741d | 5 | public: |
beaglescout007 | 0:b5f79b4f741d | 6 | myvector() { |
beaglescout007 | 0:b5f79b4f741d | 7 | m_size = 0; |
beaglescout007 | 0:b5f79b4f741d | 8 | m_buf = NULL; |
beaglescout007 | 0:b5f79b4f741d | 9 | } |
beaglescout007 | 0:b5f79b4f741d | 10 | ~myvector() { |
beaglescout007 | 0:b5f79b4f741d | 11 | if (m_buf) { |
beaglescout007 | 0:b5f79b4f741d | 12 | delete[] m_buf; |
beaglescout007 | 0:b5f79b4f741d | 13 | } |
beaglescout007 | 0:b5f79b4f741d | 14 | } |
beaglescout007 | 0:b5f79b4f741d | 15 | void push_back(T v) { |
beaglescout007 | 0:b5f79b4f741d | 16 | T* new_buf = new T[m_size+1]; |
beaglescout007 | 0:b5f79b4f741d | 17 | if (m_size > 0) { |
beaglescout007 | 0:b5f79b4f741d | 18 | for(int i = 0; i < m_size; i++) { |
beaglescout007 | 0:b5f79b4f741d | 19 | new_buf[i] = m_buf[i]; |
beaglescout007 | 0:b5f79b4f741d | 20 | } |
beaglescout007 | 0:b5f79b4f741d | 21 | delete[] m_buf; |
beaglescout007 | 0:b5f79b4f741d | 22 | } |
beaglescout007 | 0:b5f79b4f741d | 23 | m_buf = new_buf; |
beaglescout007 | 0:b5f79b4f741d | 24 | m_buf[m_size++] = v; |
beaglescout007 | 0:b5f79b4f741d | 25 | } |
beaglescout007 | 0:b5f79b4f741d | 26 | T& operator[](const int index) { |
beaglescout007 | 0:b5f79b4f741d | 27 | return m_buf[index]; |
beaglescout007 | 0:b5f79b4f741d | 28 | } |
beaglescout007 | 0:b5f79b4f741d | 29 | int size() { return m_size; } |
beaglescout007 | 0:b5f79b4f741d | 30 | |
beaglescout007 | 0:b5f79b4f741d | 31 | private: |
beaglescout007 | 0:b5f79b4f741d | 32 | int m_size; |
beaglescout007 | 0:b5f79b4f741d | 33 | T *m_buf; |
beaglescout007 | 0:b5f79b4f741d | 34 | }; |
beaglescout007 | 0:b5f79b4f741d | 35 |