Fork of mbed for KL05Z based smart sensor which has no crystal on the board, so MCG FEI mode is required.

Dependents:   smart-sensor-KL05Z-debug

Fork of mbed-src by Ermanno Brusadin

Committer:
r14793
Date:
Mon Jan 29 15:38:37 2018 +0000
Revision:
1:da408b460382
Parent:
0:0a673c671a56
changed KL05 MCG mode to FEI for smart sensor boards (no crystal)

Who changed what in which revision?

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