initial

Dependencies:   mbed

Committer:
yihui
Date:
Mon Jan 11 02:32:24 2016 +0000
Revision:
0:638edba3adf6
initial

Who changed what in which revision?

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