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