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