Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: F401RE-USBHostMIDI_RecieveExample
Fork of F401RE-USBHost by
Diff: USBHost.h
- Revision:
- 2:0cdac6bcc534
- Parent:
- 1:c072d9e580b0
diff -r c072d9e580b0 -r 0cdac6bcc534 USBHost.h
--- a/USBHost.h Tue Jan 21 08:59:28 2014 +0000
+++ b/USBHost.h Thu Jan 23 08:32:54 2014 +0000
@@ -1,35 +1,9 @@
// Simple USBHost for FRDM-KL46Z
-#include "mbed.h"
#pragma once
-
-struct SETUP_PACKET {
- uint8_t bmRequestType;
- uint8_t bRequest;
- uint16_t wValue;
- uint16_t wIndex;
- uint16_t wLength;
-};
+#include "mbed.h"
+#include "USBHALHost.h"
-#define SET_ADDRESS 5
-#define GET_DESCRIPTOR 6
-#define GET_CONFIGURATION 8
-#define SET_CONFIGURATION 9
-
-// TOK_PID[5:2]
-#define DATA0 0x03
-#define DATA1 0x0b
-#define ACK 0x02
-#define STALL 0x0e
-#define NAK 0x0a
-#define Bus_Timeout 0x00
-#define Data_Error 0x0f
-
-enum ODD_EVEN {
- ODD = 0,
- EVEN = 1,
-};
-
-class USBHost {
+class USBHost : public USBHALHost {
public:
static USBHost* getHostInst();
int InterruptRead(uint8_t* data, int size);
@@ -37,33 +11,11 @@
int ControlWrite(SETUP_PACKET* setup, uint8_t* data = NULL, int size = 0);
int BulkRead(uint8_t* data, int size);
int BulkWrite(const uint8_t* data, int size);
- uint8_t LastStatus;
-
-protected:
- USBHost();
- void init();
- void wait_attach();
- bool enumeration();
- uint8_t ep_int_in;
- uint8_t ep_bulk_in;
- uint8_t ep_bulk_out;
- int MaxPacketSize0;
- bool lowSpeed;
- int dev_addr;
private:
- static void _usbisr(void);
- int token_setup(SETUP_PACKET* setup, uint16_t wLength = 0);
- int token_in(uint8_t ep, uint8_t* data = NULL, int size = 0);
- int token_out(uint8_t ep, const uint8_t* data = NULL, int size = 0);
- void token_ready();
- void UsbIrqhandler();
- __IO bool attach_done;
- __IO bool token_done;
- ODD_EVEN tx_ptr;
- ODD_EVEN rx_ptr;
- uint8_t tx_data01[16];
- uint8_t rx_data01[16];
+ USBHost();
static USBHost* inst;
+ virtual bool enumeration();
+ int dev_addr;
};
