Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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