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: USBHALHost.h
- Revision:
- 2:0cdac6bcc534
diff -r c072d9e580b0 -r 0cdac6bcc534 USBHALHost.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/USBHALHost.h Thu Jan 23 08:32:54 2014 +0000
@@ -0,0 +1,66 @@
+// Simple USBHost for FRDM-KL46Z
+#pragma once
+#include "mbed.h"
+
+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
+
+// 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 USBHALHost {
+public:
+ uint8_t LastStatus;
+ uint8_t prev_LastStatus;
+
+protected:
+ USBHALHost();
+ void init();
+ virtual bool enumeration() = 0;
+ bool lowSpeed;
+
+ uint8_t ep_int_in;
+ uint8_t ep_bulk_in;
+ uint8_t ep_bulk_out;
+ int MaxPacketSize0;
+ void setAddr(int addr);
+ void setEndpoint(bool use_retry = false);
+ int token_setup(SETUP_PACKET* setup, uint16_t wLength = 0);
+ int token_in(uint8_t ep, uint8_t* data = NULL, int size = 0, int retryLimit = 10);
+ int token_out(uint8_t ep, const uint8_t* data = NULL, int size = 0);
+ void token_ready();
+ uint8_t tx_data01[16];
+ uint8_t rx_data01[16];
+
+private:
+ static void _usbisr(void);
+ void UsbIrqhandler();
+
+ __IO bool attach_done;
+ __IO bool token_done;
+ void wait_attach();
+ ODD_EVEN tx_ptr;
+ ODD_EVEN rx_ptr;
+ static USBHALHost * instHost;
+};
