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