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