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