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