The prosthetic control(MIT)

Committer:
ganlikun
Date:
Thu Jun 23 05:23:34 2022 +0000
Revision:
0:20e0c61e0684
01

Who changed what in which revision?

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