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