Basic fading in and out of leds with light sensor.

Dependencies:   mbed

Committer:
mturner5
Date:
Mon Sep 19 03:24:58 2016 +0000
Revision:
0:cf7af2656659
Basic v1

Who changed what in which revision?

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