++

Fork of mbed-stm32l0/l1-src by lzbp li

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_interface.h Source File

mbed_interface.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef MBED_INTERFACE_H
00017 #define MBED_INTERFACE_H
00018 
00019 #include "device.h"
00020 
00021 /* Mbed interface mac address
00022  * if MBED_MAC_ADD_x are zero, interface uid sets mac address,
00023  * otherwise MAC_ADD_x are used.
00024  */
00025 #define MBED_MAC_ADDR_INTERFACE 0x00
00026 #define MBED_MAC_ADDR_0  MBED_MAC_ADDR_INTERFACE
00027 #define MBED_MAC_ADDR_1  MBED_MAC_ADDR_INTERFACE
00028 #define MBED_MAC_ADDR_2  MBED_MAC_ADDR_INTERFACE
00029 #define MBED_MAC_ADDR_3  MBED_MAC_ADDR_INTERFACE
00030 #define MBED_MAC_ADDR_4  MBED_MAC_ADDR_INTERFACE
00031 #define MBED_MAC_ADDR_5  MBED_MAC_ADDR_INTERFACE
00032 #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)
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 #if DEVICE_SEMIHOST
00039 
00040 /** Functions to control the mbed interface
00041  *
00042  * mbed Microcontrollers have a built-in interface to provide functionality such as
00043  * drag-n-drop download, reset, serial-over-usb, and access to the mbed local file
00044  * system. These functions provide means to control the interface suing semihost
00045  * calls it supports.
00046  */
00047 
00048 /** Determine whether the mbed interface is connected, based on whether debug is enabled
00049  *
00050  *  @returns
00051  *    1 if interface is connected,
00052  *    0 otherwise
00053  */
00054 int mbed_interface_connected(void);
00055 
00056 /** Instruct the mbed interface to reset, as if the reset button had been pressed
00057  *
00058  *  @returns
00059  *    1 if successful,
00060  *    0 otherwise (e.g. interface not present)
00061  */
00062 int mbed_interface_reset(void);
00063 
00064 /** This will disconnect the debug aspect of the interface, so semihosting will be disabled.
00065  * The interface will still support the USB serial aspect
00066  *
00067  *  @returns
00068  *    0 if successful,
00069  *   -1 otherwise (e.g. interface not present)
00070  */
00071 int mbed_interface_disconnect(void);
00072 
00073 /** This will disconnect the debug aspect of the interface, and if the USB cable is not
00074  * connected, also power down the interface. If the USB cable is connected, the interface
00075  * will remain powered up and visible to the host
00076  *
00077  *  @returns
00078  *    0 if successful,
00079  *   -1 otherwise (e.g. interface not present)
00080  */
00081 int mbed_interface_powerdown(void);
00082 
00083 /** This returns a string containing the 32-character UID of the mbed interface
00084  *  This is a weak function that can be overwritten if required
00085  *
00086  *  @param uid A 33-byte array to write the null terminated 32-byte string
00087  *
00088  *  @returns
00089  *    0 if successful,
00090  *   -1 otherwise (e.g. interface not present)
00091  */
00092 int mbed_interface_uid(char *uid);
00093 
00094 #endif
00095 
00096 /** This returns a unique 6-byte MAC address, based on the interface UID
00097  * If the interface is not present, it returns a default fixed MAC address (00:02:F7:F0:00:00)
00098  *
00099  * This is a weak function that can be overwritten if you want to provide your own mechanism to
00100  * provide a MAC address.
00101  *
00102  *  @param mac A 6-byte array to write the MAC address
00103  */
00104 void mbed_mac_address(char *mac);
00105 
00106 /** Cause the mbed to flash the BLOD (Blue LEDs Of Death) sequence
00107  */
00108 void mbed_die(void);
00109 
00110 #ifdef __cplusplus
00111 }
00112 #endif
00113 
00114 #endif