mbed library sources with internal temperature sensor for nucleo f401

Committer:
elessair
Date:
Sat Jan 17 18:03:58 2015 +0000
Revision:
0:7e2bd16f80af
nucleo f401re internal temperature added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elessair 0:7e2bd16f80af 1 /* mbed Microcontroller Library
elessair 0:7e2bd16f80af 2 * Copyright (c) 2006-2013 ARM Limited
elessair 0:7e2bd16f80af 3 *
elessair 0:7e2bd16f80af 4 * Licensed under the Apache License, Version 2.0 (the "License");
elessair 0:7e2bd16f80af 5 * you may not use this file except in compliance with the License.
elessair 0:7e2bd16f80af 6 * You may obtain a copy of the License at
elessair 0:7e2bd16f80af 7 *
elessair 0:7e2bd16f80af 8 * http://www.apache.org/licenses/LICENSE-2.0
elessair 0:7e2bd16f80af 9 *
elessair 0:7e2bd16f80af 10 * Unless required by applicable law or agreed to in writing, software
elessair 0:7e2bd16f80af 11 * distributed under the License is distributed on an "AS IS" BASIS,
elessair 0:7e2bd16f80af 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
elessair 0:7e2bd16f80af 13 * See the License for the specific language governing permissions and
elessair 0:7e2bd16f80af 14 * limitations under the License.
elessair 0:7e2bd16f80af 15 */
elessair 0:7e2bd16f80af 16 #ifndef MBED_LOCALFILESYSTEM_H
elessair 0:7e2bd16f80af 17 #define MBED_LOCALFILESYSTEM_H
elessair 0:7e2bd16f80af 18
elessair 0:7e2bd16f80af 19 #include "platform.h"
elessair 0:7e2bd16f80af 20
elessair 0:7e2bd16f80af 21 #if DEVICE_LOCALFILESYSTEM
elessair 0:7e2bd16f80af 22
elessair 0:7e2bd16f80af 23 #include "FileSystemLike.h"
elessair 0:7e2bd16f80af 24
elessair 0:7e2bd16f80af 25 namespace mbed {
elessair 0:7e2bd16f80af 26
elessair 0:7e2bd16f80af 27 FILEHANDLE local_file_open(const char* name, int flags);
elessair 0:7e2bd16f80af 28
elessair 0:7e2bd16f80af 29 class LocalFileHandle : public FileHandle {
elessair 0:7e2bd16f80af 30
elessair 0:7e2bd16f80af 31 public:
elessair 0:7e2bd16f80af 32 LocalFileHandle(FILEHANDLE fh);
elessair 0:7e2bd16f80af 33
elessair 0:7e2bd16f80af 34 virtual int close();
elessair 0:7e2bd16f80af 35
elessair 0:7e2bd16f80af 36 virtual ssize_t write(const void *buffer, size_t length);
elessair 0:7e2bd16f80af 37
elessair 0:7e2bd16f80af 38 virtual ssize_t read(void *buffer, size_t length);
elessair 0:7e2bd16f80af 39
elessair 0:7e2bd16f80af 40 virtual int isatty();
elessair 0:7e2bd16f80af 41
elessair 0:7e2bd16f80af 42 virtual off_t lseek(off_t position, int whence);
elessair 0:7e2bd16f80af 43
elessair 0:7e2bd16f80af 44 virtual int fsync();
elessair 0:7e2bd16f80af 45
elessair 0:7e2bd16f80af 46 virtual off_t flen();
elessair 0:7e2bd16f80af 47
elessair 0:7e2bd16f80af 48 protected:
elessair 0:7e2bd16f80af 49 FILEHANDLE _fh;
elessair 0:7e2bd16f80af 50 int pos;
elessair 0:7e2bd16f80af 51 };
elessair 0:7e2bd16f80af 52
elessair 0:7e2bd16f80af 53 /** A filesystem for accessing the local mbed Microcontroller USB disk drive
elessair 0:7e2bd16f80af 54 *
elessair 0:7e2bd16f80af 55 * This allows programs to read and write files on the same disk drive that is used to program the
elessair 0:7e2bd16f80af 56 * mbed Microcontroller. Once created, the standard C file access functions are used to open,
elessair 0:7e2bd16f80af 57 * read and write files.
elessair 0:7e2bd16f80af 58 *
elessair 0:7e2bd16f80af 59 * Example:
elessair 0:7e2bd16f80af 60 * @code
elessair 0:7e2bd16f80af 61 * #include "mbed.h"
elessair 0:7e2bd16f80af 62 *
elessair 0:7e2bd16f80af 63 * LocalFileSystem local("local"); // Create the local filesystem under the name "local"
elessair 0:7e2bd16f80af 64 *
elessair 0:7e2bd16f80af 65 * int main() {
elessair 0:7e2bd16f80af 66 * FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing
elessair 0:7e2bd16f80af 67 * fprintf(fp, "Hello World!");
elessair 0:7e2bd16f80af 68 * fclose(fp);
elessair 0:7e2bd16f80af 69 * remove("/local/out.txt"); // Removes the file "out.txt" from the local file system
elessair 0:7e2bd16f80af 70 *
elessair 0:7e2bd16f80af 71 * DIR *d = opendir("/local"); // Opens the root directory of the local file system
elessair 0:7e2bd16f80af 72 * struct dirent *p;
elessair 0:7e2bd16f80af 73 * while((p = readdir(d)) != NULL) { // Print the names of the files in the local file system
elessair 0:7e2bd16f80af 74 * printf("%s\n", p->d_name); // to stdout.
elessair 0:7e2bd16f80af 75 * }
elessair 0:7e2bd16f80af 76 * closedir(d);
elessair 0:7e2bd16f80af 77 * }
elessair 0:7e2bd16f80af 78 * @endcode
elessair 0:7e2bd16f80af 79 *
elessair 0:7e2bd16f80af 80 * @note
elessair 0:7e2bd16f80af 81 * If the microcontroller program makes an access to the local drive, it will be marked as "removed"
elessair 0:7e2bd16f80af 82 * on the Host computer. This means it is no longer accessible from the Host Computer.
elessair 0:7e2bd16f80af 83 *
elessair 0:7e2bd16f80af 84 * The drive will only re-appear when the microcontroller program exists. Note that if the program does
elessair 0:7e2bd16f80af 85 * not exit, you will need to hold down reset on the mbed Microcontroller to be able to see the drive again!
elessair 0:7e2bd16f80af 86 */
elessair 0:7e2bd16f80af 87 class LocalFileSystem : public FileSystemLike {
elessair 0:7e2bd16f80af 88
elessair 0:7e2bd16f80af 89 public:
elessair 0:7e2bd16f80af 90 LocalFileSystem(const char* n) : FileSystemLike(n) {
elessair 0:7e2bd16f80af 91
elessair 0:7e2bd16f80af 92 }
elessair 0:7e2bd16f80af 93
elessair 0:7e2bd16f80af 94 virtual FileHandle *open(const char* name, int flags);
elessair 0:7e2bd16f80af 95 virtual int remove(const char *filename);
elessair 0:7e2bd16f80af 96 virtual DirHandle *opendir(const char *name);
elessair 0:7e2bd16f80af 97 };
elessair 0:7e2bd16f80af 98
elessair 0:7e2bd16f80af 99 } // namespace mbed
elessair 0:7e2bd16f80af 100
elessair 0:7e2bd16f80af 101 #endif
elessair 0:7e2bd16f80af 102
elessair 0:7e2bd16f80af 103 #endif