Simple USBHost library for STM32F746NG Discovery board. Only either the Fastspeed or the Highspeed port can be used( not both together)
Dependents: DISCO-F746NG_USB_Host
Fork of KL46Z-USBHost by
USBHost/myvector.h@25:7d6d9fc471bf, 2016-06-17 (annotated)
- Committer:
- DieterGraef
- Date:
- Fri Jun 17 09:00:35 2016 +0000
- Revision:
- 25:7d6d9fc471bf
- Parent:
- 16:981c3104f6c0
USB Host now works with both Interfaces even in parallel. Some changes in the USB MSD driver to make it operable
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 10:40c7f6788902 | 1 | #pragma once |
va009039 | 10:40c7f6788902 | 2 | |
va009039 | 10:40c7f6788902 | 3 | template<class T> |
va009039 | 10:40c7f6788902 | 4 | class myvector { |
va009039 | 10:40c7f6788902 | 5 | public: |
va009039 | 10:40c7f6788902 | 6 | myvector() { |
va009039 | 10:40c7f6788902 | 7 | m_size = 0; |
va009039 | 10:40c7f6788902 | 8 | m_buf = NULL; |
va009039 | 10:40c7f6788902 | 9 | } |
va009039 |
16:981c3104f6c0 | 10 | ~myvector() { |
va009039 |
16:981c3104f6c0 | 11 | if (m_buf) { |
va009039 |
16:981c3104f6c0 | 12 | delete[] m_buf; |
va009039 |
16:981c3104f6c0 | 13 | } |
va009039 |
16:981c3104f6c0 | 14 | } |
va009039 | 10:40c7f6788902 | 15 | void push_back(T v) { |
va009039 | 10:40c7f6788902 | 16 | T* new_buf = new T[m_size+1]; |
va009039 | 10:40c7f6788902 | 17 | if (m_size > 0) { |
va009039 | 10:40c7f6788902 | 18 | for(int i = 0; i < m_size; i++) { |
va009039 | 10:40c7f6788902 | 19 | new_buf[i] = m_buf[i]; |
va009039 | 10:40c7f6788902 | 20 | } |
va009039 | 10:40c7f6788902 | 21 | delete[] m_buf; |
va009039 | 10:40c7f6788902 | 22 | } |
va009039 | 10:40c7f6788902 | 23 | m_buf = new_buf; |
va009039 | 10:40c7f6788902 | 24 | m_buf[m_size++] = v; |
va009039 | 10:40c7f6788902 | 25 | } |
va009039 | 10:40c7f6788902 | 26 | T& operator[](const int index) { |
va009039 | 10:40c7f6788902 | 27 | return m_buf[index]; |
va009039 | 10:40c7f6788902 | 28 | } |
va009039 | 10:40c7f6788902 | 29 | int size() { return m_size; } |
va009039 | 10:40c7f6788902 | 30 | |
va009039 | 10:40c7f6788902 | 31 | private: |
va009039 | 10:40c7f6788902 | 32 | int m_size; |
va009039 | 10:40c7f6788902 | 33 | T *m_buf; |
va009039 | 10:40c7f6788902 | 34 | }; |