00

Committer:
ganlikun
Date:
Sun Jun 12 14:02:44 2022 +0000
Revision:
0:13413ea9a877
00

Who changed what in which revision?

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