Mangue Baja Box

Dependencies:   mbed

Committer:
einsteingustavo
Date:
Mon Jul 29 20:38:00 2019 +0000
Revision:
0:0dee8840a1c0
Mangue Baja Box

Who changed what in which revision?

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