J&W / Mbed 2 deprecated Rejestrator

Dependencies:   mbed Rejestrator

Dependents:   Rejestrator

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers USBHALHost_F401RE.h Source File

USBHALHost_F401RE.h

00001 // Simple USBHost for  Nucleo F401RE
00002 #pragma once
00003 #include "mbed.h"
00004 #include "USBHostTypes.h"
00005 #include "USBEndpoint.h"
00006 
00007 struct SETUP_PACKET {
00008     uint8_t bmRequestType;
00009     uint8_t bRequest;
00010     uint16_t wValue;
00011     uint16_t wIndex;
00012     uint16_t wLength;
00013 };
00014 
00015 class USBHALHost {
00016 public:
00017     uint8_t LastStatus;
00018     uint8_t prev_LastStatus;
00019 
00020 protected:
00021     USBHALHost();
00022     void init();
00023     virtual bool addDevice(USBDeviceConnected* parent, int port, bool lowSpeed) = 0;
00024     void setAddr(int addr, bool lowSpeed = false){}
00025     void setEndpoint(){}
00026     void token_transfer_init(){}
00027     int token_setup(USBEndpoint* ep, SETUP_PACKET* setup, uint16_t wLength = 0);
00028     int token_in(USBEndpoint* ep, uint8_t* data = NULL, int size = 0, int retryLimit = 10);
00029     int token_out(USBEndpoint* ep, const uint8_t* data = NULL, int size = 0, int retryLimit = 10);
00030     int token_iso_in(USBEndpoint* ep, uint8_t* data, int size);
00031     void token_ready(){}
00032 
00033 private:
00034     int token_ctl_in(USBEndpoint* ep, uint8_t* data, int size, int retryLimit);
00035     int token_int_in(USBEndpoint* ep, uint8_t* data, int size);
00036     int token_blk_in(USBEndpoint* ep, uint8_t* data, int size, int retryLimit);
00037     int token_ctl_out(USBEndpoint* ep, const uint8_t* data, int size, int retryLimit);
00038     int token_int_out(USBEndpoint* ep, const uint8_t* data, int size);
00039     int token_blk_out(USBEndpoint* ep, const uint8_t* data, int size, int retryLimit);
00040     bool wait_attach();
00041     static USBHALHost * instHost;
00042 };
00043