Official Sheffield ARMBand micro:bit program

Committer:
MrBedfordVan
Date:
Mon Oct 17 12:41:20 2016 +0000
Revision:
0:b9164b348919
Official Sheffield ARMBand Micro:bit program

Who changed what in which revision?

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