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