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

USBHost/myvector.h

Committer:
beaglescout007
Date:
2016-03-15
Revision:
0:b5f79b4f741d

File content as of revision 0:b5f79b4f741d:

#pragma once

template<class T>
class myvector {
public:
    myvector() {
        m_size = 0;
        m_buf = NULL;
    }
    ~myvector() {
        if (m_buf) {
            delete[] m_buf;
        }
    }
    void push_back(T v) {
        T* new_buf = new T[m_size+1];
        if (m_size > 0) {
            for(int i = 0; i < m_size; i++) {
                new_buf[i] = m_buf[i];
            }
            delete[] m_buf;
        }
        m_buf = new_buf;
        m_buf[m_size++] = v;
    }
    T& operator[](const int index) {
        return m_buf[index];
    }
    int size() { return m_size; }

private:
    int m_size;
    T *m_buf;
};