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 /* IUSBHostSerial.h */
elessair 0:f269e3021894 2 /* Copyright (c) 2010-2012 mbed.org, MIT License
elessair 0:f269e3021894 3 *
elessair 0:f269e3021894 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
elessair 0:f269e3021894 5 * and associated documentation files (the "Software"), to deal in the Software without
elessair 0:f269e3021894 6 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
elessair 0:f269e3021894 7 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
elessair 0:f269e3021894 8 * Software is furnished to do so, subject to the following conditions:
elessair 0:f269e3021894 9 *
elessair 0:f269e3021894 10 * The above copyright notice and this permission notice shall be included in all copies or
elessair 0:f269e3021894 11 * substantial portions of the Software.
elessair 0:f269e3021894 12 *
elessair 0:f269e3021894 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
elessair 0:f269e3021894 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
elessair 0:f269e3021894 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
elessair 0:f269e3021894 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
elessair 0:f269e3021894 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
elessair 0:f269e3021894 18 */
elessair 0:f269e3021894 19
elessair 0:f269e3021894 20 #ifndef IUSBHOSTSERIAL_H_
elessair 0:f269e3021894 21 #define IUSBHOSTSERIAL_H_
elessair 0:f269e3021894 22
elessair 0:f269e3021894 23 /**
elessair 0:f269e3021894 24 * Generic interface to abstract 3G dongles' impl
elessair 0:f269e3021894 25 */
elessair 0:f269e3021894 26
elessair 0:f269e3021894 27 #include "USBHostConf.h"
elessair 0:f269e3021894 28
elessair 0:f269e3021894 29 #ifdef USBHOST_3GMODULE
elessair 0:f269e3021894 30
elessair 0:f269e3021894 31 #include "IUSBHostSerialListener.h"
elessair 0:f269e3021894 32
elessair 0:f269e3021894 33 // This is needed by some versions of GCC
elessair 0:f269e3021894 34 #undef putc
elessair 0:f269e3021894 35 #undef getc
elessair 0:f269e3021894 36
elessair 0:f269e3021894 37 class IUSBHostSerial {
elessair 0:f269e3021894 38 public:
elessair 0:f269e3021894 39
elessair 0:f269e3021894 40 enum IrqType {
elessair 0:f269e3021894 41 RxIrq,
elessair 0:f269e3021894 42 TxIrq
elessair 0:f269e3021894 43 };
elessair 0:f269e3021894 44
elessair 0:f269e3021894 45 /*
elessair 0:f269e3021894 46 * Get a char from the dongle's serial interface
elessair 0:f269e3021894 47 */
elessair 0:f269e3021894 48 virtual int getc() = 0;
elessair 0:f269e3021894 49
elessair 0:f269e3021894 50 /*
elessair 0:f269e3021894 51 * Put a char to the dongle's serial interface
elessair 0:f269e3021894 52 */
elessair 0:f269e3021894 53 virtual int putc(int c) = 0;
elessair 0:f269e3021894 54
elessair 0:f269e3021894 55 /*
elessair 0:f269e3021894 56 * Read a packet from the dongle's serial interface, to be called after multiple getc() calls
elessair 0:f269e3021894 57 */
elessair 0:f269e3021894 58 virtual int readPacket() = 0;
elessair 0:f269e3021894 59
elessair 0:f269e3021894 60 /*
elessair 0:f269e3021894 61 * Write a packet to the dongle's serial interface, to be called after multiple putc() calls
elessair 0:f269e3021894 62 */
elessair 0:f269e3021894 63 virtual int writePacket() = 0;
elessair 0:f269e3021894 64
elessair 0:f269e3021894 65 /**
elessair 0:f269e3021894 66 * Check the number of bytes available.
elessair 0:f269e3021894 67 *
elessair 0:f269e3021894 68 * @returns the number of bytes available
elessair 0:f269e3021894 69 */
elessair 0:f269e3021894 70 virtual int readable() = 0;
elessair 0:f269e3021894 71
elessair 0:f269e3021894 72 /**
elessair 0:f269e3021894 73 * Check the free space in output.
elessair 0:f269e3021894 74 *
elessair 0:f269e3021894 75 * @returns the number of bytes available
elessair 0:f269e3021894 76 */
elessair 0:f269e3021894 77 virtual int writeable() = 0;
elessair 0:f269e3021894 78
elessair 0:f269e3021894 79 /**
elessair 0:f269e3021894 80 * Attach a handler to call when a packet is received / when a packet has been transmitted.
elessair 0:f269e3021894 81 *
elessair 0:f269e3021894 82 * @param pListener instance of the listener deriving from the IUSBHostSerialListener
elessair 0:f269e3021894 83 */
elessair 0:f269e3021894 84 virtual void attach(IUSBHostSerialListener* pListener) = 0;
elessair 0:f269e3021894 85
elessair 0:f269e3021894 86 /**
elessair 0:f269e3021894 87 * Enable or disable readable/writeable callbacks
elessair 0:f269e3021894 88 */
elessair 0:f269e3021894 89 virtual void setupIrq(bool en, IrqType irq = RxIrq) = 0;
elessair 0:f269e3021894 90
elessair 0:f269e3021894 91 };
elessair 0:f269e3021894 92
elessair 0:f269e3021894 93 #endif /* USBHOST_3GMODULE */
elessair 0:f269e3021894 94
elessair 0:f269e3021894 95 #endif /* IUSBHOSTSERIAL_H_ */