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
elessair 0:f269e3021894 2 /** \addtogroup platform */
elessair 0:f269e3021894 3 /** @{*/
elessair 0:f269e3021894 4 /* mbed Microcontroller Library
elessair 0:f269e3021894 5 * Copyright (c) 2006-2013 ARM Limited
elessair 0:f269e3021894 6 *
elessair 0:f269e3021894 7 * Licensed under the Apache License, Version 2.0 (the "License");
elessair 0:f269e3021894 8 * you may not use this file except in compliance with the License.
elessair 0:f269e3021894 9 * You may obtain a copy of the License at
elessair 0:f269e3021894 10 *
elessair 0:f269e3021894 11 * http://www.apache.org/licenses/LICENSE-2.0
elessair 0:f269e3021894 12 *
elessair 0:f269e3021894 13 * Unless required by applicable law or agreed to in writing, software
elessair 0:f269e3021894 14 * distributed under the License is distributed on an "AS IS" BASIS,
elessair 0:f269e3021894 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
elessair 0:f269e3021894 16 * See the License for the specific language governing permissions and
elessair 0:f269e3021894 17 * limitations under the License.
elessair 0:f269e3021894 18 */
elessair 0:f269e3021894 19 #ifndef MBED_INTERFACE_H
elessair 0:f269e3021894 20 #define MBED_INTERFACE_H
elessair 0:f269e3021894 21
elessair 0:f269e3021894 22 #include <stdarg.h>
elessair 0:f269e3021894 23
elessair 0:f269e3021894 24 #include "device.h"
elessair 0:f269e3021894 25
elessair 0:f269e3021894 26 /* Mbed interface mac address
elessair 0:f269e3021894 27 * if MBED_MAC_ADD_x are zero, interface uid sets mac address,
elessair 0:f269e3021894 28 * otherwise MAC_ADD_x are used.
elessair 0:f269e3021894 29 */
elessair 0:f269e3021894 30 #define MBED_MAC_ADDR_INTERFACE 0x00
elessair 0:f269e3021894 31 #define MBED_MAC_ADDR_0 MBED_MAC_ADDR_INTERFACE
elessair 0:f269e3021894 32 #define MBED_MAC_ADDR_1 MBED_MAC_ADDR_INTERFACE
elessair 0:f269e3021894 33 #define MBED_MAC_ADDR_2 MBED_MAC_ADDR_INTERFACE
elessair 0:f269e3021894 34 #define MBED_MAC_ADDR_3 MBED_MAC_ADDR_INTERFACE
elessair 0:f269e3021894 35 #define MBED_MAC_ADDR_4 MBED_MAC_ADDR_INTERFACE
elessair 0:f269e3021894 36 #define MBED_MAC_ADDR_5 MBED_MAC_ADDR_INTERFACE
elessair 0:f269e3021894 37 #define MBED_MAC_ADDRESS_SUM (MBED_MAC_ADDR_0 | MBED_MAC_ADDR_1 | MBED_MAC_ADDR_2 | MBED_MAC_ADDR_3 | MBED_MAC_ADDR_4 | MBED_MAC_ADDR_5)
elessair 0:f269e3021894 38
elessair 0:f269e3021894 39 #ifdef __cplusplus
elessair 0:f269e3021894 40 extern "C" {
elessair 0:f269e3021894 41 #endif
elessair 0:f269e3021894 42
elessair 0:f269e3021894 43 #if DEVICE_SEMIHOST
elessair 0:f269e3021894 44
elessair 0:f269e3021894 45 /** Functions to control the mbed interface
elessair 0:f269e3021894 46 *
elessair 0:f269e3021894 47 * mbed Microcontrollers have a built-in interface to provide functionality such as
elessair 0:f269e3021894 48 * drag-n-drop download, reset, serial-over-usb, and access to the mbed local file
elessair 0:f269e3021894 49 * system. These functions provide means to control the interface suing semihost
elessair 0:f269e3021894 50 * calls it supports.
elessair 0:f269e3021894 51 */
elessair 0:f269e3021894 52
elessair 0:f269e3021894 53 /** Determine whether the mbed interface is connected, based on whether debug is enabled
elessair 0:f269e3021894 54 *
elessair 0:f269e3021894 55 * @returns
elessair 0:f269e3021894 56 * 1 if interface is connected,
elessair 0:f269e3021894 57 * 0 otherwise
elessair 0:f269e3021894 58 */
elessair 0:f269e3021894 59 int mbed_interface_connected(void);
elessair 0:f269e3021894 60
elessair 0:f269e3021894 61 /** Instruct the mbed interface to reset, as if the reset button had been pressed
elessair 0:f269e3021894 62 *
elessair 0:f269e3021894 63 * @returns
elessair 0:f269e3021894 64 * 1 if successful,
elessair 0:f269e3021894 65 * 0 otherwise (e.g. interface not present)
elessair 0:f269e3021894 66 */
elessair 0:f269e3021894 67 int mbed_interface_reset(void);
elessair 0:f269e3021894 68
elessair 0:f269e3021894 69 /** This will disconnect the debug aspect of the interface, so semihosting will be disabled.
elessair 0:f269e3021894 70 * The interface will still support the USB serial aspect
elessair 0:f269e3021894 71 *
elessair 0:f269e3021894 72 * @returns
elessair 0:f269e3021894 73 * 0 if successful,
elessair 0:f269e3021894 74 * -1 otherwise (e.g. interface not present)
elessair 0:f269e3021894 75 */
elessair 0:f269e3021894 76 int mbed_interface_disconnect(void);
elessair 0:f269e3021894 77
elessair 0:f269e3021894 78 /** This will disconnect the debug aspect of the interface, and if the USB cable is not
elessair 0:f269e3021894 79 * connected, also power down the interface. If the USB cable is connected, the interface
elessair 0:f269e3021894 80 * will remain powered up and visible to the host
elessair 0:f269e3021894 81 *
elessair 0:f269e3021894 82 * @returns
elessair 0:f269e3021894 83 * 0 if successful,
elessair 0:f269e3021894 84 * -1 otherwise (e.g. interface not present)
elessair 0:f269e3021894 85 */
elessair 0:f269e3021894 86 int mbed_interface_powerdown(void);
elessair 0:f269e3021894 87
elessair 0:f269e3021894 88 /** This returns a string containing the 32-character UID of the mbed interface
elessair 0:f269e3021894 89 * This is a weak function that can be overwritten if required
elessair 0:f269e3021894 90 *
elessair 0:f269e3021894 91 * @param uid A 33-byte array to write the null terminated 32-byte string
elessair 0:f269e3021894 92 *
elessair 0:f269e3021894 93 * @returns
elessair 0:f269e3021894 94 * 0 if successful,
elessair 0:f269e3021894 95 * -1 otherwise (e.g. interface not present)
elessair 0:f269e3021894 96 */
elessair 0:f269e3021894 97 int mbed_interface_uid(char *uid);
elessair 0:f269e3021894 98
elessair 0:f269e3021894 99 #endif
elessair 0:f269e3021894 100
elessair 0:f269e3021894 101 /** This returns a unique 6-byte MAC address, based on the interface UID
elessair 0:f269e3021894 102 * If the interface is not present, it returns a default fixed MAC address (00:02:F7:F0:00:00)
elessair 0:f269e3021894 103 *
elessair 0:f269e3021894 104 * This is a weak function that can be overwritten if you want to provide your own mechanism to
elessair 0:f269e3021894 105 * provide a MAC address.
elessair 0:f269e3021894 106 *
elessair 0:f269e3021894 107 * @param mac A 6-byte array to write the MAC address
elessair 0:f269e3021894 108 */
elessair 0:f269e3021894 109 void mbed_mac_address(char *mac);
elessair 0:f269e3021894 110
elessair 0:f269e3021894 111 /** Cause the mbed to flash the BLOD (Blue LEDs Of Death) sequence
elessair 0:f269e3021894 112 */
elessair 0:f269e3021894 113 void mbed_die(void);
elessair 0:f269e3021894 114
elessair 0:f269e3021894 115 /** Print out an error message. This is typically called when
elessair 0:f269e3021894 116 * hanlding a crash.
elessair 0:f269e3021894 117 *
elessair 0:f269e3021894 118 * @Note Synchronization level: Interrupt safe
elessair 0:f269e3021894 119 */
elessair 0:f269e3021894 120 void mbed_error_printf(const char* format, ...);
elessair 0:f269e3021894 121
elessair 0:f269e3021894 122 /** Print out an error message. Similar to mbed_error_printf
elessair 0:f269e3021894 123 * but uses a va_list.
elessair 0:f269e3021894 124 *
elessair 0:f269e3021894 125 * @Note Synchronization level: Interrupt safe
elessair 0:f269e3021894 126 */
elessair 0:f269e3021894 127 void mbed_error_vfprintf(const char * format, va_list arg);
elessair 0:f269e3021894 128
elessair 0:f269e3021894 129 #ifdef __cplusplus
elessair 0:f269e3021894 130 }
elessair 0:f269e3021894 131 #endif
elessair 0:f269e3021894 132
elessair 0:f269e3021894 133 #endif
elessair 0:f269e3021894 134
elessair 0:f269e3021894 135 /** @}*/