Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

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