Simple USBHost library for LPC4088. Backward compatibility of official-USBHost.

Dependencies:   FATFileSystem mbed-rtos

EA LPC4088 QSB専用の簡易USBホストライブラリです。
official-USBHostの下位互換で対応プログラムを僅かな修正で動かすことが出来ます。
examples:

Import programLPC4088-USBHostMSD_HelloWorld

Simple USBHost MSD(USB flash drive) for EA LPC4088 QSB test program

Import programLPC4088-BTstack_example

BTstack for EA LPC4088 QSB example program

Import programLPC4088-USBHostC270_example

Simple USBHost WebCam for EA LPC4088 QSB/LPC1768 test program

Committer:
va009039
Date:
Fri Apr 25 05:18:55 2014 +0000
Revision:
0:148fca6fd246
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:148fca6fd246 1 #pragma once
va009039 0:148fca6fd246 2
va009039 0:148fca6fd246 3 template<class K,class T>
va009039 0:148fca6fd246 4 class mymap {
va009039 0:148fca6fd246 5 struct mypair {
va009039 0:148fca6fd246 6 K first;
va009039 0:148fca6fd246 7 T second;
va009039 0:148fca6fd246 8 };
va009039 0:148fca6fd246 9 public:
va009039 0:148fca6fd246 10 mymap() {
va009039 0:148fca6fd246 11 m_size = 0;
va009039 0:148fca6fd246 12 }
va009039 0:148fca6fd246 13 T& operator[](const K& key) {
va009039 0:148fca6fd246 14 int it;
va009039 0:148fca6fd246 15 if (count(key) == 0) {
va009039 0:148fca6fd246 16 it = insert(key, 0);
va009039 0:148fca6fd246 17 } else {
va009039 0:148fca6fd246 18 it = find(key);
va009039 0:148fca6fd246 19 }
va009039 0:148fca6fd246 20 return m_buf[it].second;
va009039 0:148fca6fd246 21 }
va009039 0:148fca6fd246 22 bool empty() { return m_size == 0 ? true : false; }
va009039 0:148fca6fd246 23 int size() { return m_size; }
va009039 0:148fca6fd246 24 void clear() { m_size = 0; }
va009039 0:148fca6fd246 25 int count(K key) {
va009039 0:148fca6fd246 26 for(int i = 0; i < m_size; i++) {
va009039 0:148fca6fd246 27 if (m_buf[i].first == key) {
va009039 0:148fca6fd246 28 return 1;
va009039 0:148fca6fd246 29 }
va009039 0:148fca6fd246 30 }
va009039 0:148fca6fd246 31 return 0;
va009039 0:148fca6fd246 32 }
va009039 0:148fca6fd246 33
va009039 0:148fca6fd246 34 private:
va009039 0:148fca6fd246 35 int find(K key) {
va009039 0:148fca6fd246 36 for(int i = 0; i < m_size; i++) {
va009039 0:148fca6fd246 37 if (m_buf[i].first == key) {
va009039 0:148fca6fd246 38 return i;
va009039 0:148fca6fd246 39 }
va009039 0:148fca6fd246 40 }
va009039 0:148fca6fd246 41 return -1;
va009039 0:148fca6fd246 42 }
va009039 0:148fca6fd246 43 int insert(K key, T value) {
va009039 0:148fca6fd246 44 int it = find(key);
va009039 0:148fca6fd246 45 if (it != -1) {
va009039 0:148fca6fd246 46 m_buf[it].second = value;
va009039 0:148fca6fd246 47 return it;
va009039 0:148fca6fd246 48 }
va009039 0:148fca6fd246 49 mypair* new_buf = new mypair[m_size+1];
va009039 0:148fca6fd246 50 if (m_size > 0) {
va009039 0:148fca6fd246 51 for(int i = 0; i < m_size; i++) {
va009039 0:148fca6fd246 52 new_buf[i] = m_buf[i];
va009039 0:148fca6fd246 53 }
va009039 0:148fca6fd246 54 delete[] m_buf;
va009039 0:148fca6fd246 55 }
va009039 0:148fca6fd246 56 m_buf = new_buf;
va009039 0:148fca6fd246 57 it = m_size++;
va009039 0:148fca6fd246 58 m_buf[it].first = key;
va009039 0:148fca6fd246 59 m_buf[it].second = value;
va009039 0:148fca6fd246 60 return it;
va009039 0:148fca6fd246 61 }
va009039 0:148fca6fd246 62
va009039 0:148fca6fd246 63 int m_size;
va009039 0:148fca6fd246 64 mypair *m_buf;
va009039 0:148fca6fd246 65 };