mbed os with nrf51 internal bandgap enabled to read battery level

Dependents:   BLE_file_test BLE_Blink ExternalEncoder

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elessair 0:f269e3021894 1 /* Copyright (c) 2010-2012 mbed.org, MIT License
elessair 0:f269e3021894 2 *
elessair 0:f269e3021894 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
elessair 0:f269e3021894 4 * and associated documentation files (the "Software"), to deal in the Software without
elessair 0:f269e3021894 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
elessair 0:f269e3021894 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
elessair 0:f269e3021894 7 * Software is furnished to do so, subject to the following conditions:
elessair 0:f269e3021894 8 *
elessair 0:f269e3021894 9 * The above copyright notice and this permission notice shall be included in all copies or
elessair 0:f269e3021894 10 * substantial portions of the Software.
elessair 0:f269e3021894 11 *
elessair 0:f269e3021894 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
elessair 0:f269e3021894 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
elessair 0:f269e3021894 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
elessair 0:f269e3021894 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
elessair 0:f269e3021894 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
elessair 0:f269e3021894 17 */
elessair 0:f269e3021894 18
elessair 0:f269e3021894 19 #ifndef WANDONGLEINITIALIZER_H
elessair 0:f269e3021894 20 #define WANDONGLEINITIALIZER_H
elessair 0:f269e3021894 21
elessair 0:f269e3021894 22 #include "USBHostConf.h"
elessair 0:f269e3021894 23
elessair 0:f269e3021894 24 #ifdef USBHOST_3GMODULE
elessair 0:f269e3021894 25
elessair 0:f269e3021894 26 #include <stdint.h>
elessair 0:f269e3021894 27
elessair 0:f269e3021894 28 #include "USBHost.h"
elessair 0:f269e3021894 29 #include "IUSBEnumerator.h"
elessair 0:f269e3021894 30
elessair 0:f269e3021894 31 // [TODO] move these declarations to a proper place
elessair 0:f269e3021894 32 #define WANDONGLE_MAX_SERIAL_PORTS 2
elessair 0:f269e3021894 33 #define WANDONGLE_MAX_INITIALIZERS 6
elessair 0:f269e3021894 34
elessair 0:f269e3021894 35 #define WAN_DONGLE_TYPE_UNKNOWN (-1)
elessair 0:f269e3021894 36
elessair 0:f269e3021894 37 class WANDongleInitializer : public IUSBEnumerator
elessair 0:f269e3021894 38 {
elessair 0:f269e3021894 39 protected:
elessair 0:f269e3021894 40 WANDongleInitializer(USBHost* pHost) { m_pHost = pHost; }
elessair 0:f269e3021894 41 USBHost* m_pHost;
elessair 0:f269e3021894 42 uint8_t m_serialIntfMap[WANDONGLE_MAX_SERIAL_PORTS];
elessair 0:f269e3021894 43
elessair 0:f269e3021894 44 public:
elessair 0:f269e3021894 45 virtual ~WANDongleInitializer() {}
elessair 0:f269e3021894 46 virtual uint16_t getMSDVid() = 0;
elessair 0:f269e3021894 47 virtual uint16_t getMSDPid() = 0;
elessair 0:f269e3021894 48
elessair 0:f269e3021894 49 virtual uint16_t getSerialVid() = 0;
elessair 0:f269e3021894 50 virtual uint16_t getSerialPid() = 0;
elessair 0:f269e3021894 51
elessair 0:f269e3021894 52 virtual bool switchMode(USBDeviceConnected* pDev) = 0;
elessair 0:f269e3021894 53
elessair 0:f269e3021894 54 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) {
elessair 0:f269e3021894 55 return pDev->getEndpoint(m_serialIntfMap[serialPortNumber], BULK_ENDPOINT, tx ? OUT : IN, 0);
elessair 0:f269e3021894 56 }
elessair 0:f269e3021894 57
elessair 0:f269e3021894 58 virtual int getSerialPortCount() = 0;
elessair 0:f269e3021894 59
elessair 0:f269e3021894 60 virtual void setVidPid(uint16_t vid, uint16_t pid) = 0;
elessair 0:f269e3021894 61
elessair 0:f269e3021894 62 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) = 0; //Must return true if the interface should be parsed
elessair 0:f269e3021894 63
elessair 0:f269e3021894 64 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) = 0; //Must return true if the endpoint will be used
elessair 0:f269e3021894 65
elessair 0:f269e3021894 66 virtual int getType() = 0;
elessair 0:f269e3021894 67
elessair 0:f269e3021894 68 virtual uint8_t getSerialIntf(int index) { return m_serialIntfMap[index]; }
elessair 0:f269e3021894 69 };
elessair 0:f269e3021894 70
elessair 0:f269e3021894 71 #endif /* USBHOST_3GMODULE */
elessair 0:f269e3021894 72
elessair 0:f269e3021894 73 #endif