mbed library sources that still uses the stm standard peripheral library

Fork of mbed-src by Reinhold Schaefer

Committer:
emilmont
Date:
Mon Feb 18 11:44:18 2013 +0000
Revision:
2:143cac498751
Parent:
0:fd0d7bdfcdc2
Child:
3:c24f5ba8a7f9
Update mbed sources to Rev 59

Who changed what in which revision?

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