BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

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