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