Usb read

Dependencies:   FATFileSystem

Fork of F401RE-USBHost by Norimasa Okamoto

Committer:
va009039
Date:
Tue Jul 01 18:33:31 2014 +0900
Revision:
18:61554f238584
Parent:
16:981c3104f6c0
add lpc4088/lpc1768

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 11:61843badd06e 1 #pragma once
va009039 11:61843badd06e 2 #include "mbed.h"
va009039 11:61843badd06e 3 #include "USBHostTypes.h"
va009039 11:61843badd06e 4 #include "USBEndpoint.h"
va009039 11:61843badd06e 5
va009039 11:61843badd06e 6 #define GET_CONFIGURATION 8
va009039 11:61843badd06e 7
va009039 11:61843badd06e 8 // TOK_PID[5:2]
va009039 11:61843badd06e 9 #define Bus_Timeout 0x00
va009039 11:61843badd06e 10 #define Data_Error 0x0f
va009039 11:61843badd06e 11
va009039 11:61843badd06e 12 enum ODD_EVEN {
va009039 11:61843badd06e 13 ODD = 0,
va009039 11:61843badd06e 14 EVEN = 1,
va009039 11:61843badd06e 15 };
va009039 11:61843badd06e 16
va009039 11:61843badd06e 17 class Report {
va009039 11:61843badd06e 18 public:
va009039 11:61843badd06e 19 void clear();
va009039 11:61843badd06e 20 void print_errstat();
va009039 11:61843badd06e 21 // error count
va009039 11:61843badd06e 22 uint32_t errstat_piderr; // USBx_ERRSTAT[PIDERR]
va009039 11:61843badd06e 23 uint32_t errstat_crc5eof;// USBx_ERRSTAT[CRC5EOF]
va009039 11:61843badd06e 24 uint32_t errstat_crc16; // USBx_ERRSTAT[CRC16]
va009039 11:61843badd06e 25 uint32_t errstat_dfn8; // USBx_ERRSTAT[DFN8]
va009039 11:61843badd06e 26 uint32_t errstat_btoerr; // USBx_ERRSTAT[BTOERR]
va009039 11:61843badd06e 27 uint32_t errstat_dmaerr; // USBx_ERRSTAT[DMAERR]
va009039 11:61843badd06e 28 uint32_t errstat_bsterr; // USBx_ERRSTAT[BTSERR]
va009039 11:61843badd06e 29 //
va009039 11:61843badd06e 30 uint32_t nak;
va009039 11:61843badd06e 31 uint32_t stall;
va009039 11:61843badd06e 32 };
va009039 11:61843badd06e 33
va009039 11:61843badd06e 34 class USBHALHost {
va009039 11:61843badd06e 35 public:
va009039 11:61843badd06e 36 uint8_t LastStatus;
va009039 11:61843badd06e 37 uint8_t prev_LastStatus;
va009039 11:61843badd06e 38 Report report;
va009039 11:61843badd06e 39
va009039 11:61843badd06e 40 protected:
va009039 11:61843badd06e 41 USBHALHost();
va009039 11:61843badd06e 42 void init();
va009039 11:61843badd06e 43 virtual bool addDevice(USBDeviceConnected* parent, int port, bool lowSpeed) = 0;
va009039 18:61554f238584 44 int token_setup(USBEndpoint* ep, SETUP_PACKET* setup, uint16_t wLength = 0);
va009039 18:61554f238584 45 int multi_token_in(USBEndpoint* ep, uint8_t* data = NULL, size_t total = 0, bool block = true);
va009039 18:61554f238584 46 int multi_token_out(USBEndpoint* ep, const uint8_t* data = NULL, size_t total = 0);
va009039 18:61554f238584 47 void multi_token_inNB(USBEndpoint* ep, uint8_t* data, int size);
va009039 18:61554f238584 48 USB_TYPE multi_token_inNB_result(USBEndpoint* ep);
va009039 18:61554f238584 49 void setToggle(USBEndpoint* ep, uint8_t toggle);
va009039 18:61554f238584 50 int token_iso_in(USBEndpoint* ep, uint8_t* data, int size);
va009039 18:61554f238584 51
va009039 18:61554f238584 52 private:
va009039 11:61843badd06e 53 void setAddr(int addr, bool lowSpeed = false);
va009039 11:61843badd06e 54 void setEndpoint();
va009039 11:61843badd06e 55 void token_transfer_init();
va009039 16:981c3104f6c0 56 void token_ready();
va009039 11:61843badd06e 57 int token_in(USBEndpoint* ep, uint8_t* data = NULL, int size = 0, int retryLimit = 10);
va009039 11:61843badd06e 58 int token_out(USBEndpoint* ep, const uint8_t* data = NULL, int size = 0, int retryLimit = 10);
va009039 11:61843badd06e 59 static void _usbisr(void);
va009039 11:61843badd06e 60 void UsbIrqhandler();
va009039 11:61843badd06e 61 __IO bool attach_done;
va009039 11:61843badd06e 62 __IO bool token_done;
va009039 11:61843badd06e 63 bool wait_attach();
va009039 11:61843badd06e 64 bool root_lowSpeed;
va009039 11:61843badd06e 65 ODD_EVEN tx_ptr;
va009039 11:61843badd06e 66 ODD_EVEN rx_ptr;
va009039 11:61843badd06e 67 static USBHALHost * instHost;
va009039 11:61843badd06e 68 };