CDC/ECM driver for mbed, based on USBDevice by mbed-official. Uses PicoTCP to access Ethernet USB device. License: GPLv2

Dependents:   USBEthernet_TEST

Fork of USB_Ethernet by Daniele Lacamera

Committer:
daniele
Date:
Sat Aug 03 13:16:14 2013 +0000
Revision:
2:540f6e142d59
Moved to single package

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniele 2:540f6e142d59 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
daniele 2:540f6e142d59 2 *
daniele 2:540f6e142d59 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
daniele 2:540f6e142d59 4 * and associated documentation files (the "Software"), to deal in the Software without
daniele 2:540f6e142d59 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
daniele 2:540f6e142d59 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
daniele 2:540f6e142d59 7 * Software is furnished to do so, subject to the following conditions:
daniele 2:540f6e142d59 8 *
daniele 2:540f6e142d59 9 * The above copyright notice and this permission notice shall be included in all copies or
daniele 2:540f6e142d59 10 * substantial portions of the Software.
daniele 2:540f6e142d59 11 *
daniele 2:540f6e142d59 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
daniele 2:540f6e142d59 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
daniele 2:540f6e142d59 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
daniele 2:540f6e142d59 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
daniele 2:540f6e142d59 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
daniele 2:540f6e142d59 17 */
daniele 2:540f6e142d59 18
daniele 2:540f6e142d59 19 #ifndef USBBUSINTERFACE_H
daniele 2:540f6e142d59 20 #define USBBUSINTERFACE_H
daniele 2:540f6e142d59 21
daniele 2:540f6e142d59 22 #include "mbed.h"
daniele 2:540f6e142d59 23 #include "USBEndpoints.h"
daniele 2:540f6e142d59 24
daniele 2:540f6e142d59 25 #ifdef __GNUC__
daniele 2:540f6e142d59 26 #define __packed __attribute__ ((__packed__))
daniele 2:540f6e142d59 27 #endif
daniele 2:540f6e142d59 28
daniele 2:540f6e142d59 29 class USBHAL {
daniele 2:540f6e142d59 30 public:
daniele 2:540f6e142d59 31 /* Configuration */
daniele 2:540f6e142d59 32 USBHAL();
daniele 2:540f6e142d59 33 ~USBHAL();
daniele 2:540f6e142d59 34 void connect(void);
daniele 2:540f6e142d59 35 void disconnect(void);
daniele 2:540f6e142d59 36 void configureDevice(void);
daniele 2:540f6e142d59 37 void unconfigureDevice(void);
daniele 2:540f6e142d59 38 void setAddress(uint8_t address);
daniele 2:540f6e142d59 39 void remoteWakeup(void);
daniele 2:540f6e142d59 40
daniele 2:540f6e142d59 41 /* Endpoint 0 */
daniele 2:540f6e142d59 42 void EP0setup(uint8_t *buffer);
daniele 2:540f6e142d59 43 void EP0read(void);
daniele 2:540f6e142d59 44 void EP0readStage(void);
daniele 2:540f6e142d59 45 uint32_t EP0getReadResult(uint8_t *buffer);
daniele 2:540f6e142d59 46 void EP0write(uint8_t *buffer, uint32_t size);
daniele 2:540f6e142d59 47 void EP0getWriteResult(void);
daniele 2:540f6e142d59 48 void EP0stall(void);
daniele 2:540f6e142d59 49
daniele 2:540f6e142d59 50 /* Other endpoints */
daniele 2:540f6e142d59 51 EP_STATUS endpointRead(uint8_t endpoint, uint32_t maximumSize);
daniele 2:540f6e142d59 52 EP_STATUS endpointReadResult(uint8_t endpoint, uint8_t *data, uint32_t *bytesRead);
daniele 2:540f6e142d59 53 EP_STATUS endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size);
daniele 2:540f6e142d59 54 EP_STATUS endpointWriteResult(uint8_t endpoint);
daniele 2:540f6e142d59 55 void stallEndpoint(uint8_t endpoint);
daniele 2:540f6e142d59 56 void unstallEndpoint(uint8_t endpoint);
daniele 2:540f6e142d59 57 bool realiseEndpoint(uint8_t endpoint, uint32_t maxPacket, uint32_t options);
daniele 2:540f6e142d59 58 bool getEndpointStallState(unsigned char endpoint);
daniele 2:540f6e142d59 59 uint32_t endpointReadcore(uint8_t endpoint, uint8_t *buffer);
daniele 2:540f6e142d59 60
daniele 2:540f6e142d59 61 protected:
daniele 2:540f6e142d59 62 virtual void busReset(void){};
daniele 2:540f6e142d59 63 virtual void EP0setupCallback(void){};
daniele 2:540f6e142d59 64 virtual void EP0out(void){};
daniele 2:540f6e142d59 65 virtual void EP0in(void){};
daniele 2:540f6e142d59 66 virtual void connectStateChanged(unsigned int connected){};
daniele 2:540f6e142d59 67 virtual void suspendStateChanged(unsigned int suspended){};
daniele 2:540f6e142d59 68 virtual void SOF(int frameNumber){};
daniele 2:540f6e142d59 69
daniele 2:540f6e142d59 70 virtual bool EP1_OUT_callback(){return false;};
daniele 2:540f6e142d59 71 virtual bool EP1_IN_callback(){return false;};
daniele 2:540f6e142d59 72 virtual bool EP2_OUT_callback(){return false;};
daniele 2:540f6e142d59 73 virtual bool EP2_IN_callback(){return false;};
daniele 2:540f6e142d59 74 virtual bool EP3_OUT_callback(){return false;};
daniele 2:540f6e142d59 75 virtual bool EP3_IN_callback(){return false;};
daniele 2:540f6e142d59 76 virtual bool EP4_OUT_callback(){return false;};
daniele 2:540f6e142d59 77 virtual bool EP4_IN_callback(){return false;};
daniele 2:540f6e142d59 78
daniele 2:540f6e142d59 79 #if !defined(TARGET_LPC11U24)
daniele 2:540f6e142d59 80 virtual bool EP5_OUT_callback(){return false;};
daniele 2:540f6e142d59 81 virtual bool EP5_IN_callback(){return false;};
daniele 2:540f6e142d59 82 virtual bool EP6_OUT_callback(){return false;};
daniele 2:540f6e142d59 83 virtual bool EP6_IN_callback(){return false;};
daniele 2:540f6e142d59 84 virtual bool EP7_OUT_callback(){return false;};
daniele 2:540f6e142d59 85 virtual bool EP7_IN_callback(){return false;};
daniele 2:540f6e142d59 86 virtual bool EP8_OUT_callback(){return false;};
daniele 2:540f6e142d59 87 virtual bool EP8_IN_callback(){return false;};
daniele 2:540f6e142d59 88 virtual bool EP9_OUT_callback(){return false;};
daniele 2:540f6e142d59 89 virtual bool EP9_IN_callback(){return false;};
daniele 2:540f6e142d59 90 virtual bool EP10_OUT_callback(){return false;};
daniele 2:540f6e142d59 91 virtual bool EP10_IN_callback(){return false;};
daniele 2:540f6e142d59 92 virtual bool EP11_OUT_callback(){return false;};
daniele 2:540f6e142d59 93 virtual bool EP11_IN_callback(){return false;};
daniele 2:540f6e142d59 94 virtual bool EP12_OUT_callback(){return false;};
daniele 2:540f6e142d59 95 virtual bool EP12_IN_callback(){return false;};
daniele 2:540f6e142d59 96 virtual bool EP13_OUT_callback(){return false;};
daniele 2:540f6e142d59 97 virtual bool EP13_IN_callback(){return false;};
daniele 2:540f6e142d59 98 virtual bool EP14_OUT_callback(){return false;};
daniele 2:540f6e142d59 99 virtual bool EP14_IN_callback(){return false;};
daniele 2:540f6e142d59 100 virtual bool EP15_OUT_callback(){return false;};
daniele 2:540f6e142d59 101 virtual bool EP15_IN_callback(){return false;};
daniele 2:540f6e142d59 102 #endif
daniele 2:540f6e142d59 103
daniele 2:540f6e142d59 104 private:
daniele 2:540f6e142d59 105 void usbisr(void);
daniele 2:540f6e142d59 106 static void _usbisr(void);
daniele 2:540f6e142d59 107 static USBHAL * instance;
daniele 2:540f6e142d59 108
daniele 2:540f6e142d59 109 #if defined(TARGET_LPC11U24)
daniele 2:540f6e142d59 110 bool (USBHAL::*epCallback[10 - 2])(void);
daniele 2:540f6e142d59 111 #else
daniele 2:540f6e142d59 112 bool (USBHAL::*epCallback[32 - 2])(void);
daniele 2:540f6e142d59 113 #endif
daniele 2:540f6e142d59 114
daniele 2:540f6e142d59 115
daniele 2:540f6e142d59 116 };
daniele 2:540f6e142d59 117 #endif