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