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 Norimasa Okamoto

Committer:
va009039
Date:
Mon Feb 03 13:00:16 2014 +0000
Revision:
9:7f9f64cf5ded
Child:
10:40c7f6788902
add interrupt write transfer.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 9:7f9f64cf5ded 1 #pragma once
va009039 9:7f9f64cf5ded 2
va009039 9:7f9f64cf5ded 3 template<class K,class T>
va009039 9:7f9f64cf5ded 4 class mymap {
va009039 9:7f9f64cf5ded 5 struct mypair {
va009039 9:7f9f64cf5ded 6 K key;
va009039 9:7f9f64cf5ded 7 T value;
va009039 9:7f9f64cf5ded 8 };
va009039 9:7f9f64cf5ded 9 public:
va009039 9:7f9f64cf5ded 10 mymap() {
va009039 9:7f9f64cf5ded 11 m_size = 0;
va009039 9:7f9f64cf5ded 12 m_limit = 4;
va009039 9:7f9f64cf5ded 13 m_buf = new mypair[m_limit];
va009039 9:7f9f64cf5ded 14 }
va009039 9:7f9f64cf5ded 15 void put(K key, T value) {
va009039 9:7f9f64cf5ded 16 int i = find(key);
va009039 9:7f9f64cf5ded 17 if (i == (-1)) {
va009039 9:7f9f64cf5ded 18 if (m_size >= m_limit) {
va009039 9:7f9f64cf5ded 19 int new_limit = m_limit + 4;
va009039 9:7f9f64cf5ded 20 mypair* new_buf = new mypair[new_limit];
va009039 9:7f9f64cf5ded 21 for(int i = 0; i < m_size; i++) {
va009039 9:7f9f64cf5ded 22 new_buf[i] = m_buf[i];
va009039 9:7f9f64cf5ded 23 }
va009039 9:7f9f64cf5ded 24 delete[] m_buf;
va009039 9:7f9f64cf5ded 25 m_buf = new_buf;
va009039 9:7f9f64cf5ded 26 m_limit = new_limit;
va009039 9:7f9f64cf5ded 27 }
va009039 9:7f9f64cf5ded 28 i = m_size++;
va009039 9:7f9f64cf5ded 29 m_buf[i].key = key;
va009039 9:7f9f64cf5ded 30 }
va009039 9:7f9f64cf5ded 31 m_buf[i].value = value;
va009039 9:7f9f64cf5ded 32 }
va009039 9:7f9f64cf5ded 33 T get(K key) {
va009039 9:7f9f64cf5ded 34 int i = find(key);
va009039 9:7f9f64cf5ded 35 return (i == -1) ? NULL : m_buf[i].value;
va009039 9:7f9f64cf5ded 36 }
va009039 9:7f9f64cf5ded 37 bool empty() { return m_size == 0 ? true : false; }
va009039 9:7f9f64cf5ded 38 int size() { return m_size; }
va009039 9:7f9f64cf5ded 39 void clear() { m_size = 0; }
va009039 9:7f9f64cf5ded 40
va009039 9:7f9f64cf5ded 41 private:
va009039 9:7f9f64cf5ded 42 int find(K key) {
va009039 9:7f9f64cf5ded 43 for(int i = 0; i < m_size; i++) {
va009039 9:7f9f64cf5ded 44 if (m_buf[i].key == key) {
va009039 9:7f9f64cf5ded 45 return i;
va009039 9:7f9f64cf5ded 46 }
va009039 9:7f9f64cf5ded 47 }
va009039 9:7f9f64cf5ded 48 return -1;
va009039 9:7f9f64cf5ded 49 }
va009039 9:7f9f64cf5ded 50 int m_limit;
va009039 9:7f9f64cf5ded 51 int m_size;
va009039 9:7f9f64cf5ded 52 mypair *m_buf;
va009039 9:7f9f64cf5ded 53 };