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