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