test
Dependents: Production_version1_0 Production_ver1_0 USBHost_TEST USBHost_Test5 ... more
Fork of USBHost by
Diff: USBHost/USBEndpoint.h
- Revision:
- 37:f1e388e7b752
- Parent:
- 24:868cbfe611a7
diff -r 655a8c5fa238 -r f1e388e7b752 USBHost/USBEndpoint.h --- a/USBHost/USBEndpoint.h Sun Apr 30 04:17:16 2017 +0000 +++ b/USBHost/USBEndpoint.h Thu Jul 20 10:13:56 2017 +0100 @@ -17,7 +17,7 @@ #ifndef USBENDPOINT_H #define USBENDPOINT_H -#include "FunctionPointer.h" +#include "Callback.h" #include "USBHostTypes.h" #include "rtos.h" @@ -33,6 +33,9 @@ * Constructor */ USBEndpoint() { +#ifdef USBHOST_OTHER + speed = false; +#endif state = USB_TYPE_FREE; nextEp = NULL; }; @@ -47,6 +50,7 @@ * @param ep_number endpoint number * @param td_list array of two allocated transfer descriptors */ + void init(HCED * hced, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint32_t size, uint8_t ep_number, HCTD* td_list[2]); /** @@ -67,7 +71,7 @@ /** * Queue a transfer on the endpoint */ - void queueTransfer(); + USB_TYPE queueTransfer(); /** * Unqueue a transfer from the endpoint @@ -104,12 +108,17 @@ * Call the handler associted to the end of a transfer */ inline void call() { - rx.call(); + if (rx) + rx.call(); }; // setters +#ifdef USBHOST_OTHER + void setState(USB_TYPE st); +#else inline void setState(USB_TYPE st) { state = st; } +#endif void setState(uint8_t st); void setDeviceAddress(uint8_t addr); inline void setLengthTransferred(int len) { transferred = len; }; @@ -122,12 +131,17 @@ const char * getStateString(); inline USB_TYPE getState() { return state; } inline ENDPOINT_TYPE getType() { return type; }; +#ifdef USBHOST_OTHER + inline uint8_t getDeviceAddress() { return device_address; }; + inline uint32_t getSize() { return size; }; +#else inline uint8_t getDeviceAddress() { return hced->control & 0x7f; }; + inline uint32_t getSize() { return (hced->control >> 16) & 0x3ff; }; + inline volatile HCTD * getHeadTD() { return (volatile HCTD*) ((uint32_t)hced->headTD & ~0xF); }; +#endif inline int getLengthTransferred() { return transferred; } inline uint8_t * getBufStart() { return buf_start; } inline uint8_t getAddress(){ return address; }; - inline uint32_t getSize() { return (hced->control >> 16) & 0x3ff; }; - inline volatile HCTD * getHeadTD() { return (volatile HCTD*) ((uint32_t)hced->headTD & ~0xF); }; inline volatile HCTD** getTDList() { return td_list; }; inline volatile HCED * getHCED() { return hced; }; inline ENDPOINT_DIRECTION getDir() { return dir; } @@ -145,6 +159,12 @@ ENDPOINT_TYPE type; volatile USB_TYPE state; ENDPOINT_DIRECTION dir; +#ifdef USBHOST_OTHER + uint32_t size; + uint32_t ep_number; + uint32_t speed; + uint8_t device_address; +#endif bool setup; uint8_t address; @@ -153,7 +173,7 @@ int transferred; uint8_t * buf_start; - FunctionPointer rx; + Callback<void()> rx; USBEndpoint* nextEp;