Samuel Mokrani
/
USBAudio_micro
USBAudio example using a microphone
USBDevice/USBDevice/USBBusInterface.h@0:539ec61e1fbb, 2011-12-16 (annotated)
- Committer:
- samux
- Date:
- Fri Dec 16 12:31:41 2011 +0000
- Revision:
- 0:539ec61e1fbb
works with m0 and m3 (sinus) but the code is different to have the same result...
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux |
0:539ec61e1fbb | 1 | /* USBBusInterface.h */ |
samux |
0:539ec61e1fbb | 2 | /* USB Bus Interface */ |
samux |
0:539ec61e1fbb | 3 | /* Copyright (c) 2011 ARM Limited. All rights reserved. */ |
samux |
0:539ec61e1fbb | 4 | |
samux |
0:539ec61e1fbb | 5 | #ifndef USBBUSINTERFACE_H |
samux |
0:539ec61e1fbb | 6 | #define USBBUSINTERFACE_H |
samux |
0:539ec61e1fbb | 7 | |
samux |
0:539ec61e1fbb | 8 | #include "mbed.h" |
samux |
0:539ec61e1fbb | 9 | #include "USBEndpoints.h" |
samux |
0:539ec61e1fbb | 10 | |
samux |
0:539ec61e1fbb | 11 | class USBHAL { |
samux |
0:539ec61e1fbb | 12 | public: |
samux |
0:539ec61e1fbb | 13 | /* Configuration */ |
samux |
0:539ec61e1fbb | 14 | USBHAL(); |
samux |
0:539ec61e1fbb | 15 | ~USBHAL(); |
samux |
0:539ec61e1fbb | 16 | void connect(void); |
samux |
0:539ec61e1fbb | 17 | void disconnect(void); |
samux |
0:539ec61e1fbb | 18 | void configureDevice(void); |
samux |
0:539ec61e1fbb | 19 | void unconfigureDevice(void); |
samux |
0:539ec61e1fbb | 20 | void setAddress(uint8_t address); |
samux |
0:539ec61e1fbb | 21 | void remoteWakeup(void); |
samux |
0:539ec61e1fbb | 22 | |
samux |
0:539ec61e1fbb | 23 | /* Endpoint 0 */ |
samux |
0:539ec61e1fbb | 24 | void EP0setup(uint8_t *buffer); |
samux |
0:539ec61e1fbb | 25 | void EP0read(void); |
samux |
0:539ec61e1fbb | 26 | uint32_t EP0getReadResult(uint8_t *buffer); |
samux |
0:539ec61e1fbb | 27 | void EP0write(uint8_t *buffer, uint32_t size); |
samux |
0:539ec61e1fbb | 28 | void EP0getWriteResult(void); |
samux |
0:539ec61e1fbb | 29 | void EP0stall(void); |
samux |
0:539ec61e1fbb | 30 | |
samux |
0:539ec61e1fbb | 31 | /* Other endpoints */ |
samux |
0:539ec61e1fbb | 32 | EP_STATUS endpointRead(uint8_t endpoint, uint32_t maximumSize); |
samux |
0:539ec61e1fbb | 33 | EP_STATUS endpointReadResult(uint8_t endpoint, uint8_t *data, uint32_t *bytesRead); |
samux |
0:539ec61e1fbb | 34 | EP_STATUS endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size); |
samux |
0:539ec61e1fbb | 35 | EP_STATUS endpointWriteResult(uint8_t endpoint); |
samux |
0:539ec61e1fbb | 36 | void stallEndpoint(uint8_t endpoint); |
samux |
0:539ec61e1fbb | 37 | void unstallEndpoint(uint8_t endpoint); |
samux |
0:539ec61e1fbb | 38 | bool realiseEndpoint(uint8_t endpoint, uint32_t maxPacket, uint32_t options); |
samux |
0:539ec61e1fbb | 39 | bool getEndpointStallState(unsigned char endpoint); |
samux |
0:539ec61e1fbb | 40 | uint32_t endpointReadcore(uint8_t endpoint, uint8_t *buffer); |
samux |
0:539ec61e1fbb | 41 | |
samux |
0:539ec61e1fbb | 42 | protected: |
samux |
0:539ec61e1fbb | 43 | virtual void busReset(void){}; |
samux |
0:539ec61e1fbb | 44 | virtual void EP0setupCallback(void){}; |
samux |
0:539ec61e1fbb | 45 | virtual void EP0out(void){}; |
samux |
0:539ec61e1fbb | 46 | virtual void EP0in(void){}; |
samux |
0:539ec61e1fbb | 47 | virtual void connectStateChanged(unsigned int connected){}; |
samux |
0:539ec61e1fbb | 48 | virtual void suspendStateChanged(unsigned int suspended){}; |
samux |
0:539ec61e1fbb | 49 | virtual void SOF(int frameNumber){}; |
samux |
0:539ec61e1fbb | 50 | virtual bool EP1_OUT_callback(){return false;}; |
samux |
0:539ec61e1fbb | 51 | virtual bool EP1_IN_callback(){return false;}; |
samux |
0:539ec61e1fbb | 52 | virtual bool EP2_OUT_callback(){return false;}; |
samux |
0:539ec61e1fbb | 53 | virtual bool EP2_IN_callback(){return false;}; |
samux |
0:539ec61e1fbb | 54 | virtual bool EP3_OUT_callback(){return false;}; |
samux |
0:539ec61e1fbb | 55 | virtual bool EP3_IN_callback(){return false;}; |
samux |
0:539ec61e1fbb | 56 | |
samux |
0:539ec61e1fbb | 57 | private: |
samux |
0:539ec61e1fbb | 58 | void usbisr(void); |
samux |
0:539ec61e1fbb | 59 | static void _usbisr(void); |
samux |
0:539ec61e1fbb | 60 | static USBHAL * instance; |
samux |
0:539ec61e1fbb | 61 | }; |
samux |
0:539ec61e1fbb | 62 | #endif |
samux |
0:539ec61e1fbb | 63 | |
samux |
0:539ec61e1fbb | 64 |