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