The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Anna Bridge
Date:
Fri Jun 22 15:38:59 2018 +0100
Revision:
169:a7c7b631e539
Parent:
158:1c57384330a6
Child:
170:e95d10626187
mbed library. Release version 162

Who changed what in which revision?

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