mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
187:0387e8f68319
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 149:156823d33999 1
<> 149:156823d33999 2 /** \addtogroup platform */
<> 149:156823d33999 3 /** @{*/
AnnaBridge 178:79309dc6340a 4 /**
AnnaBridge 178:79309dc6340a 5 * \defgroup platform_interface Network interface and other utility functions
AnnaBridge 178:79309dc6340a 6 * @{
AnnaBridge 178:79309dc6340a 7 */
AnnaBridge 178:79309dc6340a 8
<> 149:156823d33999 9 /* mbed Microcontroller Library
<> 149:156823d33999 10 * Copyright (c) 2006-2013 ARM Limited
AnnaBridge 189:f392fc9709a3 11 * SPDX-License-Identifier: Apache-2.0
<> 149:156823d33999 12 *
<> 149:156823d33999 13 * Licensed under the Apache License, Version 2.0 (the "License");
<> 149:156823d33999 14 * you may not use this file except in compliance with the License.
<> 149:156823d33999 15 * You may obtain a copy of the License at
<> 149:156823d33999 16 *
<> 149:156823d33999 17 * http://www.apache.org/licenses/LICENSE-2.0
<> 149:156823d33999 18 *
<> 149:156823d33999 19 * Unless required by applicable law or agreed to in writing, software
<> 149:156823d33999 20 * distributed under the License is distributed on an "AS IS" BASIS,
<> 149:156823d33999 21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 149:156823d33999 22 * See the License for the specific language governing permissions and
<> 149:156823d33999 23 * limitations under the License.
<> 149:156823d33999 24 */
<> 149:156823d33999 25 #ifndef MBED_INTERFACE_H
<> 149:156823d33999 26 #define MBED_INTERFACE_H
<> 149:156823d33999 27
<> 149:156823d33999 28 #include <stdarg.h>
<> 149:156823d33999 29
AnnaBridge 189:f392fc9709a3 30 #include "mbed_toolchain.h"
<> 149:156823d33999 31 #include "device.h"
<> 149:156823d33999 32
<> 149:156823d33999 33 /* Mbed interface mac address
<> 149:156823d33999 34 * if MBED_MAC_ADD_x are zero, interface uid sets mac address,
<> 149:156823d33999 35 * otherwise MAC_ADD_x are used.
<> 149:156823d33999 36 */
<> 149:156823d33999 37 #define MBED_MAC_ADDR_INTERFACE 0x00
<> 149:156823d33999 38 #define MBED_MAC_ADDR_0 MBED_MAC_ADDR_INTERFACE
<> 149:156823d33999 39 #define MBED_MAC_ADDR_1 MBED_MAC_ADDR_INTERFACE
<> 149:156823d33999 40 #define MBED_MAC_ADDR_2 MBED_MAC_ADDR_INTERFACE
<> 149:156823d33999 41 #define MBED_MAC_ADDR_3 MBED_MAC_ADDR_INTERFACE
<> 149:156823d33999 42 #define MBED_MAC_ADDR_4 MBED_MAC_ADDR_INTERFACE
<> 149:156823d33999 43 #define MBED_MAC_ADDR_5 MBED_MAC_ADDR_INTERFACE
<> 149:156823d33999 44 #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)
<> 149:156823d33999 45
<> 149:156823d33999 46 #ifdef __cplusplus
<> 149:156823d33999 47 extern "C" {
<> 149:156823d33999 48 #endif
<> 149:156823d33999 49
<> 149:156823d33999 50 #if DEVICE_SEMIHOST
<> 149:156823d33999 51
AnnaBridge 178:79309dc6340a 52 /**
AnnaBridge 178:79309dc6340a 53 * \defgroup platform_interface interface functions
AnnaBridge 178:79309dc6340a 54 * @{
AnnaBridge 178:79309dc6340a 55 */
AnnaBridge 178:79309dc6340a 56
<> 149:156823d33999 57 /** Functions to control the mbed interface
<> 149:156823d33999 58 *
<> 149:156823d33999 59 * mbed Microcontrollers have a built-in interface to provide functionality such as
<> 149:156823d33999 60 * drag-n-drop download, reset, serial-over-usb, and access to the mbed local file
<> 149:156823d33999 61 * system. These functions provide means to control the interface suing semihost
<> 149:156823d33999 62 * calls it supports.
<> 149:156823d33999 63 */
<> 149:156823d33999 64
<> 149:156823d33999 65 /** Determine whether the mbed interface is connected, based on whether debug is enabled
<> 149:156823d33999 66 *
<> 149:156823d33999 67 * @returns
<> 149:156823d33999 68 * 1 if interface is connected,
<> 149:156823d33999 69 * 0 otherwise
<> 149:156823d33999 70 */
<> 149:156823d33999 71 int mbed_interface_connected(void);
<> 149:156823d33999 72
<> 149:156823d33999 73 /** Instruct the mbed interface to reset, as if the reset button had been pressed
<> 149:156823d33999 74 *
<> 149:156823d33999 75 * @returns
<> 149:156823d33999 76 * 1 if successful,
<> 149:156823d33999 77 * 0 otherwise (e.g. interface not present)
<> 149:156823d33999 78 */
<> 149:156823d33999 79 int mbed_interface_reset(void);
<> 149:156823d33999 80
<> 149:156823d33999 81 /** This will disconnect the debug aspect of the interface, so semihosting will be disabled.
<> 149:156823d33999 82 * The interface will still support the USB serial aspect
<> 149:156823d33999 83 *
<> 149:156823d33999 84 * @returns
<> 149:156823d33999 85 * 0 if successful,
<> 149:156823d33999 86 * -1 otherwise (e.g. interface not present)
<> 149:156823d33999 87 */
<> 149:156823d33999 88 int mbed_interface_disconnect(void);
<> 149:156823d33999 89
<> 149:156823d33999 90 /** This will disconnect the debug aspect of the interface, and if the USB cable is not
<> 149:156823d33999 91 * connected, also power down the interface. If the USB cable is connected, the interface
<> 149:156823d33999 92 * will remain powered up and visible to the host
<> 149:156823d33999 93 *
<> 149:156823d33999 94 * @returns
<> 149:156823d33999 95 * 0 if successful,
<> 149:156823d33999 96 * -1 otherwise (e.g. interface not present)
<> 149:156823d33999 97 */
<> 149:156823d33999 98 int mbed_interface_powerdown(void);
<> 149:156823d33999 99
<> 149:156823d33999 100 /** This returns a string containing the 32-character UID of the mbed interface
<> 149:156823d33999 101 * This is a weak function that can be overwritten if required
<> 149:156823d33999 102 *
<> 149:156823d33999 103 * @param uid A 33-byte array to write the null terminated 32-byte string
<> 149:156823d33999 104 *
<> 149:156823d33999 105 * @returns
<> 149:156823d33999 106 * 0 if successful,
<> 149:156823d33999 107 * -1 otherwise (e.g. interface not present)
<> 149:156823d33999 108 */
<> 149:156823d33999 109 int mbed_interface_uid(char *uid);
<> 149:156823d33999 110
<> 149:156823d33999 111 #endif
<> 149:156823d33999 112
<> 149:156823d33999 113 /** This returns a unique 6-byte MAC address, based on the interface UID
<> 149:156823d33999 114 * If the interface is not present, it returns a default fixed MAC address (00:02:F7:F0:00:00)
<> 149:156823d33999 115 *
<> 149:156823d33999 116 * This is a weak function that can be overwritten if you want to provide your own mechanism to
<> 149:156823d33999 117 * provide a MAC address.
<> 149:156823d33999 118 *
<> 149:156823d33999 119 * @param mac A 6-byte array to write the MAC address
<> 149:156823d33999 120 */
<> 149:156823d33999 121 void mbed_mac_address(char *mac);
<> 149:156823d33999 122
<> 149:156823d33999 123 /** Cause the mbed to flash the BLOD (Blue LEDs Of Death) sequence
<> 149:156823d33999 124 */
AnnaBridge 189:f392fc9709a3 125 MBED_NORETURN void mbed_die(void);
<> 149:156823d33999 126
<> 149:156823d33999 127 /** Print out an error message. This is typically called when
AnnaBridge 167:e84263d55307 128 * handling a crash.
AnnaBridge 167:e84263d55307 129 *
AnnaBridge 167:e84263d55307 130 * @note Synchronization level: Interrupt safe
AnnaBridge 189:f392fc9709a3 131 * @note This uses an internal 128-byte buffer to format the string,
AnnaBridge 189:f392fc9709a3 132 * so the output may be truncated. If you need to write a potentially
AnnaBridge 189:f392fc9709a3 133 * long string, use mbed_error_puts.
<> 149:156823d33999 134 *
AnnaBridge 167:e84263d55307 135 * @param format C string that contains data stream to be printed.
AnnaBridge 167:e84263d55307 136 * Code snippets below show valid format.
AnnaBridge 167:e84263d55307 137 *
AnnaBridge 167:e84263d55307 138 * @code
AnnaBridge 167:e84263d55307 139 * mbed_error_printf("Failed: %s, file: %s, line %d \n", expr, file, line);
AnnaBridge 167:e84263d55307 140 * @endcode
AnnaBridge 167:e84263d55307 141 *
<> 149:156823d33999 142 */
AnnaBridge 189:f392fc9709a3 143 void mbed_error_printf(const char *format, ...) MBED_PRINTF(1, 2);
<> 149:156823d33999 144
<> 149:156823d33999 145 /** Print out an error message. Similar to mbed_error_printf
<> 149:156823d33999 146 * but uses a va_list.
<> 149:156823d33999 147 *
AnnaBridge 167:e84263d55307 148 * @note Synchronization level: Interrupt safe
AnnaBridge 167:e84263d55307 149 *
AnnaBridge 167:e84263d55307 150 * @param format C string that contains data stream to be printed.
AnnaBridge 167:e84263d55307 151 * @param arg Variable arguments list
AnnaBridge 167:e84263d55307 152 *
<> 149:156823d33999 153 */
AnnaBridge 189:f392fc9709a3 154 void mbed_error_vprintf(const char *format, va_list arg) MBED_PRINTF(1, 0);
AnnaBridge 189:f392fc9709a3 155
AnnaBridge 189:f392fc9709a3 156 /** Print out an error message. This is typically called when
AnnaBridge 189:f392fc9709a3 157 * handling a crash.
AnnaBridge 189:f392fc9709a3 158 *
AnnaBridge 189:f392fc9709a3 159 * Unlike mbed_error_printf, there is no limit to the maximum output
AnnaBridge 189:f392fc9709a3 160 * length. Unlike standard puts, but like standard fputs, this does not
AnnaBridge 189:f392fc9709a3 161 * append a '\n' character.
AnnaBridge 189:f392fc9709a3 162 *
AnnaBridge 189:f392fc9709a3 163 * @note Synchronization level: Interrupt safe
AnnaBridge 189:f392fc9709a3 164 *
AnnaBridge 189:f392fc9709a3 165 * @param str C string that contains data stream to be printed.
AnnaBridge 189:f392fc9709a3 166 *
AnnaBridge 189:f392fc9709a3 167 */
AnnaBridge 189:f392fc9709a3 168 void mbed_error_puts(const char *str);
AnnaBridge 189:f392fc9709a3 169
AnnaBridge 189:f392fc9709a3 170 /** @deprecated Renamed to mbed_error_vprintf to match functionality */
AnnaBridge 189:f392fc9709a3 171 MBED_DEPRECATED_SINCE("mbed-os-5.11",
AnnaBridge 189:f392fc9709a3 172 "Renamed to mbed_error_vprintf to match functionality.")
AnnaBridge 189:f392fc9709a3 173 void mbed_error_vfprintf(const char *format, va_list arg) MBED_PRINTF(1, 0);
AnnaBridge 178:79309dc6340a 174 /** @}*/
<> 149:156823d33999 175
AnnaBridge 189:f392fc9709a3 176
<> 149:156823d33999 177 #ifdef __cplusplus
<> 149:156823d33999 178 }
<> 149:156823d33999 179 #endif
<> 149:156823d33999 180
<> 149:156823d33999 181 #endif
<> 149:156823d33999 182
<> 149:156823d33999 183 /** @}*/