test

Dependents:   robotic_fish_6

Committer:
juansal12
Date:
Fri Dec 03 23:00:34 2021 +0000
Revision:
0:c792b17d9f78
uploaded sofi code ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
juansal12 0:c792b17d9f78 1 /* mbed Microcontroller Library
juansal12 0:c792b17d9f78 2 * Copyright (c) 2006-2013 ARM Limited
juansal12 0:c792b17d9f78 3 *
juansal12 0:c792b17d9f78 4 * Licensed under the Apache License, Version 2.0 (the "License");
juansal12 0:c792b17d9f78 5 * you may not use this file except in compliance with the License.
juansal12 0:c792b17d9f78 6 * You may obtain a copy of the License at
juansal12 0:c792b17d9f78 7 *
juansal12 0:c792b17d9f78 8 * http://www.apache.org/licenses/LICENSE-2.0
juansal12 0:c792b17d9f78 9 *
juansal12 0:c792b17d9f78 10 * Unless required by applicable law or agreed to in writing, software
juansal12 0:c792b17d9f78 11 * distributed under the License is distributed on an "AS IS" BASIS,
juansal12 0:c792b17d9f78 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
juansal12 0:c792b17d9f78 13 * See the License for the specific language governing permissions and
juansal12 0:c792b17d9f78 14 * limitations under the License.
juansal12 0:c792b17d9f78 15 */
juansal12 0:c792b17d9f78 16 #ifndef MBED_SEMIHOST_H
juansal12 0:c792b17d9f78 17 #define MBED_SEMIHOST_H
juansal12 0:c792b17d9f78 18
juansal12 0:c792b17d9f78 19 #include "device.h"
juansal12 0:c792b17d9f78 20 #include "toolchain.h"
juansal12 0:c792b17d9f78 21
juansal12 0:c792b17d9f78 22 #ifdef __cplusplus
juansal12 0:c792b17d9f78 23 extern "C" {
juansal12 0:c792b17d9f78 24 #endif
juansal12 0:c792b17d9f78 25
juansal12 0:c792b17d9f78 26 #if DEVICE_SEMIHOST
juansal12 0:c792b17d9f78 27
juansal12 0:c792b17d9f78 28 #ifndef __CC_ARM
juansal12 0:c792b17d9f78 29
juansal12 0:c792b17d9f78 30 #if defined(__ICCARM__)
juansal12 0:c792b17d9f78 31 inline int __semihost(int reason, const void *arg) {
juansal12 0:c792b17d9f78 32 return __semihosting(reason, (void*)arg);
juansal12 0:c792b17d9f78 33 }
juansal12 0:c792b17d9f78 34 #else
juansal12 0:c792b17d9f78 35
juansal12 0:c792b17d9f78 36 #ifdef __thumb__
juansal12 0:c792b17d9f78 37 # define AngelSWI 0xAB
juansal12 0:c792b17d9f78 38 # define AngelSWIInsn "bkpt"
juansal12 0:c792b17d9f78 39 # define AngelSWIAsm bkpt
juansal12 0:c792b17d9f78 40 #else
juansal12 0:c792b17d9f78 41 # define AngelSWI 0x123456
juansal12 0:c792b17d9f78 42 # define AngelSWIInsn "swi"
juansal12 0:c792b17d9f78 43 # define AngelSWIAsm swi
juansal12 0:c792b17d9f78 44 #endif
juansal12 0:c792b17d9f78 45
juansal12 0:c792b17d9f78 46 static inline int __semihost(int reason, const void *arg) {
juansal12 0:c792b17d9f78 47 int value;
juansal12 0:c792b17d9f78 48
juansal12 0:c792b17d9f78 49 asm volatile (
juansal12 0:c792b17d9f78 50 "mov r0, %1" "\n\t"
juansal12 0:c792b17d9f78 51 "mov r1, %2" "\n\t"
juansal12 0:c792b17d9f78 52 AngelSWIInsn " %a3" "\n\t"
juansal12 0:c792b17d9f78 53 "mov %0, r0"
juansal12 0:c792b17d9f78 54 : "=r" (value) /* output operands */
juansal12 0:c792b17d9f78 55 : "r" (reason), "r" (arg), "i" (AngelSWI) /* input operands */
juansal12 0:c792b17d9f78 56 : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" /* list of clobbered registers */
juansal12 0:c792b17d9f78 57 );
juansal12 0:c792b17d9f78 58
juansal12 0:c792b17d9f78 59 return value;
juansal12 0:c792b17d9f78 60 }
juansal12 0:c792b17d9f78 61 #endif
juansal12 0:c792b17d9f78 62 #endif
juansal12 0:c792b17d9f78 63
juansal12 0:c792b17d9f78 64 #if DEVICE_LOCALFILESYSTEM
juansal12 0:c792b17d9f78 65 FILEHANDLE semihost_open(const char* name, int openmode);
juansal12 0:c792b17d9f78 66 int semihost_close (FILEHANDLE fh);
juansal12 0:c792b17d9f78 67 int semihost_read (FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode);
juansal12 0:c792b17d9f78 68 int semihost_write (FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode);
juansal12 0:c792b17d9f78 69 int semihost_ensure(FILEHANDLE fh);
juansal12 0:c792b17d9f78 70 long semihost_flen (FILEHANDLE fh);
juansal12 0:c792b17d9f78 71 int semihost_seek (FILEHANDLE fh, long position);
juansal12 0:c792b17d9f78 72 int semihost_istty (FILEHANDLE fh);
juansal12 0:c792b17d9f78 73
juansal12 0:c792b17d9f78 74 int semihost_remove(const char *name);
juansal12 0:c792b17d9f78 75 int semihost_rename(const char *old_name, const char *new_name);
juansal12 0:c792b17d9f78 76 #endif
juansal12 0:c792b17d9f78 77
juansal12 0:c792b17d9f78 78 int semihost_uid(char *uid);
juansal12 0:c792b17d9f78 79 int semihost_reset(void);
juansal12 0:c792b17d9f78 80 int semihost_vbus(void);
juansal12 0:c792b17d9f78 81 int semihost_powerdown(void);
juansal12 0:c792b17d9f78 82 int semihost_exit(void);
juansal12 0:c792b17d9f78 83
juansal12 0:c792b17d9f78 84 int semihost_connected(void);
juansal12 0:c792b17d9f78 85 int semihost_disabledebug(void);
juansal12 0:c792b17d9f78 86
juansal12 0:c792b17d9f78 87 #endif
juansal12 0:c792b17d9f78 88
juansal12 0:c792b17d9f78 89 #ifdef __cplusplus
juansal12 0:c792b17d9f78 90 }
juansal12 0:c792b17d9f78 91 #endif
juansal12 0:c792b17d9f78 92
juansal12 0:c792b17d9f78 93 #endif