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