mbed

Dependents:   DHTSensor_Test K64F_eCompass_OneNET_JW

Committer:
mbotkinl
Date:
Wed Feb 25 20:22:22 2015 +0000
Revision:
0:2cc6bb4d7fea
Working code to read Temperature and Humidity readings

Who changed what in which revision?

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