fix nrf51822 i2c & spi conflict

Dependencies:   BLE_API eMPL_MPU6050 nRF51822

Fork of Seeed_Tiny_BLE_Flash by Darren Huang

Committer:
yihui
Date:
Tue Nov 17 07:48:56 2015 +0000
Revision:
5:b8c02645e6af
fix i2c & spi conflict

Who changed what in which revision?

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