Simple USBHost library for STM32F746NG Discovery board. Only either the Fastspeed or the Highspeed port can be used( not both together)
Dependents: DISCO-F746NG_USB_Host
Fork of KL46Z-USBHost by
Diff: USBHost/USBEndpoint.h
- Revision:
- 16:981c3104f6c0
- Parent:
- 12:b91fdea8c0a7
- Child:
- 18:61554f238584
diff -r d14c06cc5c07 -r 981c3104f6c0 USBHost/USBEndpoint.h --- a/USBHost/USBEndpoint.h Fri Jun 13 01:52:44 2014 +0000 +++ b/USBHost/USBEndpoint.h Mon Jun 23 20:30:04 2014 +0900 @@ -32,6 +32,7 @@ USBEndpoint(USBDeviceConnected* _dev) { init(CONTROL_ENDPOINT, IN, 8, 0); dev = _dev; + pData = NULL; } /** @@ -43,7 +44,8 @@ * @param ep_number endpoint number */ void init(ENDPOINT_TYPE _type, ENDPOINT_DIRECTION _dir, uint32_t size, uint8_t ep_number) { - type = _type; + setState(USB_TYPE_FREE); + setType(_type); dir = _dir; MaxPacketSize = size; address = ep_number; @@ -81,17 +83,21 @@ rx.call(); }; + void setType(ENDPOINT_TYPE _type) { type = _type; } + void setState(USB_TYPE st) { state = st; } void setDevice(USBDeviceConnected* _dev) { dev = _dev; } - void setState(uint8_t st){}; // dummy void setBuffer(uint8_t* buf, int size) { buf_start = buf, buf_size = size; } void setLengthTransferred(int len) { transferred = len; }; void setAddress(int addr) { address = addr; } void setSize(int size) { MaxPacketSize = size; } void setData01(uint8_t data01) { data01_toggle = data01; } void setNextEndpoint(USBEndpoint* ep) { nextEp = ep; }; + template<class T> + void setHALData(T data) { pData = data; } USBDeviceConnected* getDevice() { return dev; } ENDPOINT_TYPE getType() { return type; }; + USB_TYPE getState() { return state; } int getLengthTransferred() { return transferred; } uint8_t *getBufStart() { return buf_start; } int getBufSize() { return buf_size; } @@ -103,9 +109,13 @@ data01_toggle = (data01_toggle == DATA0) ? DATA1 : DATA0; } USBEndpoint* nextEndpoint() { return nextEp; }; + template<class T> + T getHALData() { return reinterpret_cast<T>(pData); } private: + USBEndpoint(){} ENDPOINT_TYPE type; + USB_TYPE state; ENDPOINT_DIRECTION dir; USBDeviceConnected* dev; uint8_t data01_toggle; // DATA0,DATA1 @@ -116,6 +126,7 @@ FunctionPointer rx; int MaxPacketSize; USBEndpoint* nextEp; + void* pData; }; class EndpointQueue { @@ -143,3 +154,5 @@ USBEndpoint* head; USBEndpoint* tail; }; + +