Fixing issues with library dependencies

Dependencies:   FATFileSystem mbed-rtos

Fork of USBHost by mbed official

Committer:
mbed_official
Date:
Tue Jun 03 11:30:38 2014 +0100
Revision:
24:868cbfe611a7
Parent:
9:7671b6a8c363
Synchronized with git revision bcacbb9fbf3432829227430830cca4315b57c1b9

Full URL: https://github.com/mbedmicro/mbed/commit/bcacbb9fbf3432829227430830cca4315b57c1b9/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 8:93da8ea2708b 1 /* mbed USBHost Library
samux 8:93da8ea2708b 2 * Copyright (c) 2006-2013 ARM Limited
samux 8:93da8ea2708b 3 *
samux 8:93da8ea2708b 4 * Licensed under the Apache License, Version 2.0 (the "License");
samux 8:93da8ea2708b 5 * you may not use this file except in compliance with the License.
samux 8:93da8ea2708b 6 * You may obtain a copy of the License at
samux 8:93da8ea2708b 7 *
samux 8:93da8ea2708b 8 * http://www.apache.org/licenses/LICENSE-2.0
samux 8:93da8ea2708b 9 *
samux 8:93da8ea2708b 10 * Unless required by applicable law or agreed to in writing, software
samux 8:93da8ea2708b 11 * distributed under the License is distributed on an "AS IS" BASIS,
samux 8:93da8ea2708b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
samux 8:93da8ea2708b 13 * See the License for the specific language governing permissions and
samux 8:93da8ea2708b 14 * limitations under the License.
samux 8:93da8ea2708b 15 */
mbed_official 0:a554658735bf 16
mbed_official 0:a554658735bf 17 #ifndef USBENDPOINT_H
mbed_official 0:a554658735bf 18 #define USBENDPOINT_H
mbed_official 0:a554658735bf 19
mbed_official 0:a554658735bf 20 #include "FunctionPointer.h"
mbed_official 0:a554658735bf 21 #include "USBHostTypes.h"
samux 9:7671b6a8c363 22 #include "rtos.h"
mbed_official 0:a554658735bf 23
mbed_official 0:a554658735bf 24 class USBDeviceConnected;
mbed_official 0:a554658735bf 25
samux 9:7671b6a8c363 26 /**
samux 8:93da8ea2708b 27 * USBEndpoint class
samux 8:93da8ea2708b 28 */
mbed_official 0:a554658735bf 29 class USBEndpoint
mbed_official 0:a554658735bf 30 {
mbed_official 0:a554658735bf 31 public:
mbed_official 0:a554658735bf 32 /**
mbed_official 0:a554658735bf 33 * Constructor
mbed_official 0:a554658735bf 34 */
mbed_official 0:a554658735bf 35 USBEndpoint() {
mbed_official 0:a554658735bf 36 state = USB_TYPE_FREE;
mbed_official 0:a554658735bf 37 nextEp = NULL;
mbed_official 0:a554658735bf 38 };
mbed_official 0:a554658735bf 39
mbed_official 0:a554658735bf 40 /**
mbed_official 0:a554658735bf 41 * Initialize an endpoint
mbed_official 0:a554658735bf 42 *
mbed_official 0:a554658735bf 43 * @param hced hced associated to the endpoint
mbed_official 0:a554658735bf 44 * @param type endpoint type
mbed_official 0:a554658735bf 45 * @param dir endpoint direction
mbed_official 0:a554658735bf 46 * @param size endpoint size
mbed_official 0:a554658735bf 47 * @param ep_number endpoint number
mbed_official 0:a554658735bf 48 * @param td_list array of two allocated transfer descriptors
mbed_official 0:a554658735bf 49 */
mbed_official 0:a554658735bf 50 void init(HCED * hced, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint32_t size, uint8_t ep_number, HCTD* td_list[2]);
mbed_official 0:a554658735bf 51
mbed_official 0:a554658735bf 52 /**
samux 8:93da8ea2708b 53 * Set next token. Warning: only useful for the control endpoint
mbed_official 0:a554658735bf 54 *
mbed_official 0:a554658735bf 55 * @param token IN, OUT or SETUP token
mbed_official 0:a554658735bf 56 */
mbed_official 0:a554658735bf 57 void setNextToken(uint32_t token);
mbed_official 0:a554658735bf 58
mbed_official 0:a554658735bf 59 /**
mbed_official 0:a554658735bf 60 * Queue an endpoint
mbed_official 0:a554658735bf 61 *
samux 8:93da8ea2708b 62 * @param endpoint endpoint which will be queued in the linked list
mbed_official 0:a554658735bf 63 */
mbed_official 0:a554658735bf 64 void queueEndpoint(USBEndpoint * endpoint);
mbed_official 0:a554658735bf 65
mbed_official 0:a554658735bf 66
mbed_official 0:a554658735bf 67 /**
mbed_official 0:a554658735bf 68 * Queue a transfer on the endpoint
mbed_official 0:a554658735bf 69 */
mbed_official 0:a554658735bf 70 void queueTransfer();
mbed_official 0:a554658735bf 71
mbed_official 0:a554658735bf 72 /**
mbed_official 0:a554658735bf 73 * Unqueue a transfer from the endpoint
mbed_official 0:a554658735bf 74 *
mbed_official 0:a554658735bf 75 * @param td hctd which will be unqueued
mbed_official 0:a554658735bf 76 */
mbed_official 0:a554658735bf 77 void unqueueTransfer(volatile HCTD * td);
mbed_official 0:a554658735bf 78
mbed_official 0:a554658735bf 79 /**
mbed_official 0:a554658735bf 80 * Attach a member function to call when a transfer is finished
mbed_official 0:a554658735bf 81 *
mbed_official 0:a554658735bf 82 * @param tptr pointer to the object to call the member function on
mbed_official 0:a554658735bf 83 * @param mptr pointer to the member function to be called
mbed_official 0:a554658735bf 84 */
mbed_official 0:a554658735bf 85 template<typename T>
mbed_official 0:a554658735bf 86 inline void attach(T* tptr, void (T::*mptr)(void)) {
mbed_official 0:a554658735bf 87 if((mptr != NULL) && (tptr != NULL)) {
mbed_official 0:a554658735bf 88 rx.attach(tptr, mptr);
mbed_official 0:a554658735bf 89 }
mbed_official 0:a554658735bf 90 }
mbed_official 0:a554658735bf 91
mbed_official 0:a554658735bf 92 /**
mbed_official 0:a554658735bf 93 * Attach a callback called when a transfer is finished
mbed_official 0:a554658735bf 94 *
mbed_official 0:a554658735bf 95 * @param fptr function pointer
mbed_official 0:a554658735bf 96 */
samux 8:93da8ea2708b 97 inline void attach(void (*fptr)(void)) {
samux 8:93da8ea2708b 98 if(fptr != NULL) {
samux 8:93da8ea2708b 99 rx.attach(fptr);
mbed_official 0:a554658735bf 100 }
mbed_official 0:a554658735bf 101 }
mbed_official 0:a554658735bf 102
mbed_official 0:a554658735bf 103 /**
mbed_official 0:a554658735bf 104 * Call the handler associted to the end of a transfer
mbed_official 0:a554658735bf 105 */
mbed_official 0:a554658735bf 106 inline void call() {
mbed_official 0:a554658735bf 107 rx.call();
mbed_official 0:a554658735bf 108 };
mbed_official 0:a554658735bf 109
mbed_official 0:a554658735bf 110
mbed_official 0:a554658735bf 111 // setters
mbed_official 0:a554658735bf 112 inline void setState(USB_TYPE st) { state = st; }
mbed_official 0:a554658735bf 113 void setState(uint8_t st);
mbed_official 0:a554658735bf 114 void setDeviceAddress(uint8_t addr);
mbed_official 0:a554658735bf 115 inline void setLengthTransferred(int len) { transferred = len; };
mbed_official 0:a554658735bf 116 void setSpeed(uint8_t speed);
mbed_official 0:a554658735bf 117 void setSize(uint32_t size);
mbed_official 0:a554658735bf 118 inline void setDir(ENDPOINT_DIRECTION d) { dir = d; }
samux 4:b320d68e98e7 119 inline void setIntfNb(uint8_t intf_nb_) { intf_nb = intf_nb_; };
mbed_official 0:a554658735bf 120
mbed_official 0:a554658735bf 121 // getters
mbed_official 0:a554658735bf 122 const char * getStateString();
mbed_official 0:a554658735bf 123 inline USB_TYPE getState() { return state; }
mbed_official 0:a554658735bf 124 inline ENDPOINT_TYPE getType() { return type; };
mbed_official 0:a554658735bf 125 inline uint8_t getDeviceAddress() { return hced->control & 0x7f; };
mbed_official 0:a554658735bf 126 inline int getLengthTransferred() { return transferred; }
mbed_official 0:a554658735bf 127 inline uint8_t * getBufStart() { return buf_start; }
mbed_official 0:a554658735bf 128 inline uint8_t getAddress(){ return address; };
mbed_official 0:a554658735bf 129 inline uint32_t getSize() { return (hced->control >> 16) & 0x3ff; };
mbed_official 0:a554658735bf 130 inline volatile HCTD * getHeadTD() { return (volatile HCTD*) ((uint32_t)hced->headTD & ~0xF); };
mbed_official 0:a554658735bf 131 inline volatile HCTD** getTDList() { return td_list; };
mbed_official 0:a554658735bf 132 inline volatile HCED * getHCED() { return hced; };
mbed_official 0:a554658735bf 133 inline ENDPOINT_DIRECTION getDir() { return dir; }
mbed_official 0:a554658735bf 134 inline volatile HCTD * getProcessedTD() { return td_current; };
mbed_official 0:a554658735bf 135 inline volatile HCTD* getNextTD() { return td_current; };
mbed_official 0:a554658735bf 136 inline bool isSetup() { return setup; }
mbed_official 0:a554658735bf 137 inline USBEndpoint * nextEndpoint() { return (USBEndpoint*)nextEp; };
samux 4:b320d68e98e7 138 inline uint8_t getIntfNb() { return intf_nb; };
mbed_official 24:868cbfe611a7 139
mbed_official 0:a554658735bf 140 USBDeviceConnected * dev;
mbed_official 24:868cbfe611a7 141
samux 9:7671b6a8c363 142 Queue<uint8_t, 1> ep_queue;
mbed_official 0:a554658735bf 143
mbed_official 0:a554658735bf 144 private:
mbed_official 0:a554658735bf 145 ENDPOINT_TYPE type;
mbed_official 0:a554658735bf 146 volatile USB_TYPE state;
mbed_official 0:a554658735bf 147 ENDPOINT_DIRECTION dir;
mbed_official 0:a554658735bf 148 bool setup;
mbed_official 0:a554658735bf 149
mbed_official 0:a554658735bf 150 uint8_t address;
mbed_official 0:a554658735bf 151
mbed_official 0:a554658735bf 152 int transfer_len;
mbed_official 0:a554658735bf 153 int transferred;
mbed_official 0:a554658735bf 154 uint8_t * buf_start;
mbed_official 0:a554658735bf 155
mbed_official 0:a554658735bf 156 FunctionPointer rx;
mbed_official 0:a554658735bf 157
mbed_official 0:a554658735bf 158 USBEndpoint* nextEp;
mbed_official 0:a554658735bf 159
mbed_official 0:a554658735bf 160 // USBEndpoint descriptor
mbed_official 0:a554658735bf 161 volatile HCED * hced;
mbed_official 0:a554658735bf 162
mbed_official 0:a554658735bf 163 volatile HCTD * td_list[2];
mbed_official 0:a554658735bf 164 volatile HCTD * td_current;
mbed_official 0:a554658735bf 165 volatile HCTD * td_next;
mbed_official 24:868cbfe611a7 166
samux 4:b320d68e98e7 167 uint8_t intf_nb;
mbed_official 0:a554658735bf 168
mbed_official 0:a554658735bf 169 };
mbed_official 0:a554658735bf 170
mbed_official 0:a554658735bf 171 #endif