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