The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Kojto
Date:
Wed Jul 19 16:46:19 2017 +0100
Revision:
147:a97add6d7e64
Parent:
145:64910690c574
Release 147 of the mbed library.

Who changed what in which revision?

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