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_SEMIHOST_H
ganlikun 0:20e0c61e0684 20 #define MBED_SEMIHOST_H
ganlikun 0:20e0c61e0684 21
ganlikun 0:20e0c61e0684 22 #include "device.h"
ganlikun 0:20e0c61e0684 23 #include "platform/mbed_toolchain.h"
ganlikun 0:20e0c61e0684 24
ganlikun 0:20e0c61e0684 25 #ifdef __cplusplus
ganlikun 0:20e0c61e0684 26 extern "C" {
ganlikun 0:20e0c61e0684 27 #endif
ganlikun 0:20e0c61e0684 28
ganlikun 0:20e0c61e0684 29 #if DEVICE_SEMIHOST
ganlikun 0:20e0c61e0684 30
ganlikun 0:20e0c61e0684 31 #if !defined(__CC_ARM) && !defined(__ARMCC_VERSION)
ganlikun 0:20e0c61e0684 32
ganlikun 0:20e0c61e0684 33 #if defined(__ICCARM__)
ganlikun 0:20e0c61e0684 34 static inline int __semihost(int reason, const void *arg) {
ganlikun 0:20e0c61e0684 35 return __semihosting(reason, (void*)arg);
ganlikun 0:20e0c61e0684 36 }
ganlikun 0:20e0c61e0684 37 #else
ganlikun 0:20e0c61e0684 38
ganlikun 0:20e0c61e0684 39 #ifdef __thumb__
ganlikun 0:20e0c61e0684 40 # define AngelSWI 0xAB
ganlikun 0:20e0c61e0684 41 # define AngelSWIInsn "bkpt"
ganlikun 0:20e0c61e0684 42 # define AngelSWIAsm bkpt
ganlikun 0:20e0c61e0684 43 #else
ganlikun 0:20e0c61e0684 44 # define AngelSWI 0x123456
ganlikun 0:20e0c61e0684 45 # define AngelSWIInsn "swi"
ganlikun 0:20e0c61e0684 46 # define AngelSWIAsm swi
ganlikun 0:20e0c61e0684 47 #endif
ganlikun 0:20e0c61e0684 48
ganlikun 0:20e0c61e0684 49 static inline int __semihost(int reason, const void *arg) {
ganlikun 0:20e0c61e0684 50 int value;
ganlikun 0:20e0c61e0684 51
ganlikun 0:20e0c61e0684 52 asm volatile (
ganlikun 0:20e0c61e0684 53 "mov r0, %1" "\n\t"
ganlikun 0:20e0c61e0684 54 "mov r1, %2" "\n\t"
ganlikun 0:20e0c61e0684 55 AngelSWIInsn " %a3" "\n\t"
ganlikun 0:20e0c61e0684 56 "mov %0, r0"
ganlikun 0:20e0c61e0684 57 : "=r" (value) /* output operands */
ganlikun 0:20e0c61e0684 58 : "r" (reason), "r" (arg), "i" (AngelSWI) /* input operands */
ganlikun 0:20e0c61e0684 59 : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" /* list of clobbered registers */
ganlikun 0:20e0c61e0684 60 );
ganlikun 0:20e0c61e0684 61
ganlikun 0:20e0c61e0684 62 return value;
ganlikun 0:20e0c61e0684 63 }
ganlikun 0:20e0c61e0684 64 #endif
ganlikun 0:20e0c61e0684 65 #endif
ganlikun 0:20e0c61e0684 66
ganlikun 0:20e0c61e0684 67 #if DEVICE_LOCALFILESYSTEM
ganlikun 0:20e0c61e0684 68 FILEHANDLE semihost_open(const char* name, int openmode);
ganlikun 0:20e0c61e0684 69 int semihost_close (FILEHANDLE fh);
ganlikun 0:20e0c61e0684 70 int semihost_read (FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode);
ganlikun 0:20e0c61e0684 71 int semihost_write (FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode);
ganlikun 0:20e0c61e0684 72 int semihost_ensure(FILEHANDLE fh);
ganlikun 0:20e0c61e0684 73 long semihost_flen (FILEHANDLE fh);
ganlikun 0:20e0c61e0684 74 int semihost_seek (FILEHANDLE fh, long position);
ganlikun 0:20e0c61e0684 75 int semihost_istty (FILEHANDLE fh);
ganlikun 0:20e0c61e0684 76
ganlikun 0:20e0c61e0684 77 int semihost_remove(const char *name);
ganlikun 0:20e0c61e0684 78 int semihost_rename(const char *old_name, const char *new_name);
ganlikun 0:20e0c61e0684 79 #endif
ganlikun 0:20e0c61e0684 80
ganlikun 0:20e0c61e0684 81 int semihost_uid(char *uid);
ganlikun 0:20e0c61e0684 82 int semihost_reset(void);
ganlikun 0:20e0c61e0684 83 int semihost_vbus(void);
ganlikun 0:20e0c61e0684 84 int semihost_powerdown(void);
ganlikun 0:20e0c61e0684 85 int semihost_exit(void);
ganlikun 0:20e0c61e0684 86
ganlikun 0:20e0c61e0684 87 int semihost_connected(void);
ganlikun 0:20e0c61e0684 88 int semihost_disabledebug(void);
ganlikun 0:20e0c61e0684 89
ganlikun 0:20e0c61e0684 90 #endif
ganlikun 0:20e0c61e0684 91
ganlikun 0:20e0c61e0684 92 #ifdef __cplusplus
ganlikun 0:20e0c61e0684 93 }
ganlikun 0:20e0c61e0684 94 #endif
ganlikun 0:20e0c61e0684 95
ganlikun 0:20e0c61e0684 96 #endif
ganlikun 0:20e0c61e0684 97
ganlikun 0:20e0c61e0684 98 /** @}*/
ganlikun 0:20e0c61e0684 99