Usb read
Dependencies: FATFileSystem
Fork of F401RE-USBHost by
USBHost/USBHALHost_F401RE.h@25:e1e02d62995c, 2018-01-08 (annotated)
- Committer:
- vincenzoDMT
- Date:
- Mon Jan 08 15:04:36 2018 +0000
- Revision:
- 25:e1e02d62995c
- Parent:
- 11:61843badd06e
- Child:
- 16:981c3104f6c0
nothing;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 11:61843badd06e | 1 | // Simple USBHost for Nucleo F401RE |
va009039 | 11:61843badd06e | 2 | #pragma once |
va009039 | 11:61843badd06e | 3 | #include "mbed.h" |
va009039 | 11:61843badd06e | 4 | #include "USBHostTypes.h" |
va009039 | 11:61843badd06e | 5 | #include "USBEndpoint.h" |
va009039 | 11:61843badd06e | 6 | |
va009039 | 11:61843badd06e | 7 | struct SETUP_PACKET { |
va009039 | 11:61843badd06e | 8 | uint8_t bmRequestType; |
va009039 | 11:61843badd06e | 9 | uint8_t bRequest; |
va009039 | 11:61843badd06e | 10 | uint16_t wValue; |
va009039 | 11:61843badd06e | 11 | uint16_t wIndex; |
va009039 | 11:61843badd06e | 12 | uint16_t wLength; |
va009039 | 11:61843badd06e | 13 | }; |
va009039 | 11:61843badd06e | 14 | |
va009039 | 11:61843badd06e | 15 | class USBHALHost { |
va009039 | 11:61843badd06e | 16 | public: |
va009039 | 11:61843badd06e | 17 | uint8_t LastStatus; |
va009039 | 11:61843badd06e | 18 | uint8_t prev_LastStatus; |
va009039 | 11:61843badd06e | 19 | |
va009039 | 11:61843badd06e | 20 | protected: |
va009039 | 11:61843badd06e | 21 | USBHALHost(); |
va009039 | 11:61843badd06e | 22 | void init(); |
va009039 | 11:61843badd06e | 23 | virtual bool addDevice(USBDeviceConnected* parent, int port, bool lowSpeed) = 0; |
va009039 | 11:61843badd06e | 24 | void setAddr(int addr, bool lowSpeed = false){} |
va009039 | 11:61843badd06e | 25 | void setEndpoint(){} |
va009039 | 11:61843badd06e | 26 | void token_transfer_init(){} |
va009039 | 11:61843badd06e | 27 | int token_setup(USBEndpoint* ep, SETUP_PACKET* setup, uint16_t wLength = 0); |
va009039 | 11:61843badd06e | 28 | int token_in(USBEndpoint* ep, uint8_t* data = NULL, int size = 0, int retryLimit = 10); |
va009039 | 11:61843badd06e | 29 | int token_out(USBEndpoint* ep, const uint8_t* data = NULL, int size = 0, int retryLimit = 10); |
va009039 | 11:61843badd06e | 30 | int token_iso_in(USBEndpoint* ep, uint8_t* data, int size); |
va009039 | 11:61843badd06e | 31 | void token_ready(){} |
va009039 | 11:61843badd06e | 32 | |
va009039 | 11:61843badd06e | 33 | private: |
va009039 | 11:61843badd06e | 34 | int token_ctl_in(USBEndpoint* ep, uint8_t* data, int size, int retryLimit); |
va009039 | 11:61843badd06e | 35 | int token_int_in(USBEndpoint* ep, uint8_t* data, int size); |
va009039 | 11:61843badd06e | 36 | int token_blk_in(USBEndpoint* ep, uint8_t* data, int size, int retryLimit); |
va009039 | 11:61843badd06e | 37 | int token_ctl_out(USBEndpoint* ep, const uint8_t* data, int size, int retryLimit); |
va009039 | 11:61843badd06e | 38 | int token_int_out(USBEndpoint* ep, const uint8_t* data, int size); |
va009039 | 11:61843badd06e | 39 | int token_blk_out(USBEndpoint* ep, const uint8_t* data, int size, int retryLimit); |
va009039 | 11:61843badd06e | 40 | bool wait_attach(); |
va009039 | 11:61843badd06e | 41 | static USBHALHost * instHost; |
va009039 | 11:61843badd06e | 42 | }; |
va009039 | 11:61843badd06e | 43 |