mbed library sources with internal temperature sensor for nucleo f401

Committer:
elessair
Date:
Sat Jan 17 18:03:58 2015 +0000
Revision:
0:7e2bd16f80af
nucleo f401re internal temperature added

Who changed what in which revision?

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