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:
- 0:5160ee0c522d
- Child:
- 1:c072d9e580b0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/USBHost.h Sat Jan 18 13:30:22 2014 +0000
@@ -0,0 +1,54 @@
+// 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;
+};
+
+#define SET_ADDRESS 5
+#define GET_DESCRIPTOR 6
+#define GET_CONFIGURATION 8
+#define SET_CONFIGURATION 9
+
+enum ODD_EVEN {
+ ODD = 0,
+ EVEN = 1,
+};
+
+class USBHost {
+public:
+ static USBHost* getHostInst();
+ int InterruptRead(uint8_t* data, int size);
+ int ControlRead(SETUP_PACKET* setup, uint8_t* data, int size);
+ 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);
+
+protected:
+ USBHost();
+ void init();
+ void wait_attach();
+ void enumeration();
+ uint8_t ep_int_in;
+ uint8_t ep_bulk_in;
+ uint8_t ep_bulk_out;
+ int MaxPacketSize0;
+
+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 UsbIrqhandler();
+ __IO bool attach_done;
+ __IO bool token_done;
+ ODD_EVEN tx_ptr;
+ ODD_EVEN rx_ptr;
+ static USBHost* inst;
+};
+
