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