mbed library sources. Supersedes mbed-src. RTC working even after reset

Fork of mbed-dev by mbed official

Committer:
olympux
Date:
Wed Sep 28 20:59:47 2016 +0000
Revision:
148:161ebc35dc3a
Parent:
144:ef7eb2e8f9f7
RTC working

Who changed what in which revision?

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