Simple USBHost library for Nucleo F446RE/F411RE/F401RE FRDM-KL46Z/KL25Z/F64F LPC4088/LPC1768

Dependencies:   FATFileSystem

Dependents:   F401RE-BTstack_example F401RE-USBHostMSD_HelloWorld

Fork of KL46Z-USBHost by Norimasa Okamoto

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

Platforms

  • Nucleo F446RE
  • Nucleo F411RE
  • Nucleo F401RE
  • FRDM-K64F
  • FRDM-KL46Z
  • FRDM-KL25Z
  • LPC4088
  • LPC1768

Nucleo F446RE/F411RE/F401REのUSB接続方法

ST morphoUSB
U5V (CN10-8)VBUS (1 RED)
PA11 (CN10-14)DM  (2 WHITE)
PA12 (CN10-12)DP  (3 GREEN)
GND (CN10-20)GND (4 BLACK)

Examples

Import programF446RE-USBHostMouse_HelloWorld

USBHostMouse Hello World for ST-Nucleo-F446RE

Import programF401RE-USBHostMSD_HelloWorld

Simple USBHost MSD(USB flash drive) for Nucleo F401RE/FRDM-KL46Z test program

Import programF401RE-USBHostC270_example

Simple USBHost WebCam test program

Import programK64F_USBHostC270_example

Simple USBHost C270 example

Import programF401RE-BTstack_example

BTstack for Nucleo F401RE/FRDM-KL46Z example program

Import programUSBHostRSSI_example

Bluetooth device discovery example program.

Import programKL46Z-USBHostGPS_HelloWorld

Simple USBHost GPS Dongle Receiver for FRDM-KL46Z test program

USBHost/mymap.h

Committer:
va009039
Date:
2016-05-01
Revision:
23:4ab8bc835303
Parent:
12:b91fdea8c0a7

File content as of revision 23:4ab8bc835303:

#pragma once

template<class K,class T>
class mymap {
    struct mypair {
        K first;
        T second;
    };
public:
    mymap() {
        m_size = 0;
    }
    T& operator[](const K& key) {
        int it;
        if (count(key) == 0) {
            it = insert(key, 0);
        } else {
            it = find(key);
        }
        return m_buf[it].second;
    }
    bool empty() { return m_size == 0 ? true : false; }
    int size() { return m_size; }
    void clear() { m_size = 0; }
    int count(K key) {
        for(int i = 0; i < m_size; i++) {
            if (m_buf[i].first == key) {
                return 1;
            }
        }
        return 0;
    }

private:
    int find(K key) {
        for(int i = 0; i < m_size; i++) {
            if (m_buf[i].first == key) {
                return i;
            }
        }
        return -1;
    }
    int insert(K key, T value) {
        int it = find(key);
        if (it != -1) {
            m_buf[it].second = value;
            return it;
        }
        mypair* new_buf = new mypair[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;
        it = m_size++;
        m_buf[it].first = key;
        m_buf[it].second = value;
        return it;
    }

    int m_size;
    mypair *m_buf;
};