USBMSD SD card Hello World for Mbed platforms

Dependencies:   mbed USBMSD_SD USBDevice

Committer:
samux
Date:
Wed Nov 16 17:17:42 2011 +0000
Revision:
11:a26e7b7a1221
GOOD COMMIT: msd and hid work even on MAC...

Who changed what in which revision?

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