Lucas Lim / Mbed 2 deprecated HSP_Temperature_Barometer_CS3237

Dependencies:   mbed

Committer:
lucaslwl
Date:
Mon Aug 26 08:11:41 2019 +0000
Revision:
22:5c07298d3383
add library folder

Who changed what in which revision?

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