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