Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DM_HttpServer DM_USBHost
Dependents: lpc4088_displaymodule_emwin lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI ... more
Fork of DMSupport by
FileSystems/RAMFileSystem.h@40:6df4f63aa406, 2015-06-10 (annotated)
- Committer:
- alindvall
- Date:
- Wed Jun 10 09:54:15 2015 +0000
- Revision:
- 40:6df4f63aa406
- Parent:
- 9:a33326afd686
Updated USBDevice, mbed-src and mbed-rtos libraries to latest version. Fixed compiler errors related to us_ticker_read() that was introduced in latest mbed-src version.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| embeddedartists | 9:a33326afd686 | 1 | /* |
| embeddedartists | 9:a33326afd686 | 2 | * Copyright 2014 Embedded Artists AB |
| embeddedartists | 9:a33326afd686 | 3 | * |
| embeddedartists | 9:a33326afd686 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| embeddedartists | 9:a33326afd686 | 5 | * you may not use this file except in compliance with the License. |
| embeddedartists | 9:a33326afd686 | 6 | * You may obtain a copy of the License at |
| embeddedartists | 9:a33326afd686 | 7 | * |
| embeddedartists | 9:a33326afd686 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| embeddedartists | 9:a33326afd686 | 9 | * |
| embeddedartists | 9:a33326afd686 | 10 | * Unless required by applicable law or agreed to in writing, software |
| embeddedartists | 9:a33326afd686 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| embeddedartists | 9:a33326afd686 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| embeddedartists | 9:a33326afd686 | 13 | * See the License for the specific language governing permissions and |
| embeddedartists | 9:a33326afd686 | 14 | * limitations under the License. |
| embeddedartists | 9:a33326afd686 | 15 | */ |
| embeddedartists | 9:a33326afd686 | 16 | |
| embeddedartists | 0:6b68dac0d986 | 17 | #ifndef RAMFILESYSTEM_H |
| embeddedartists | 0:6b68dac0d986 | 18 | #define RAMFILESYSTEM_H |
| embeddedartists | 0:6b68dac0d986 | 19 | |
| embeddedartists | 0:6b68dac0d986 | 20 | #include "mbed.h" |
| embeddedartists | 0:6b68dac0d986 | 21 | #include "FATFileSystem.h" |
| embeddedartists | 0:6b68dac0d986 | 22 | #include "sdram.h" |
| embeddedartists | 0:6b68dac0d986 | 23 | #include <stdint.h> |
| embeddedartists | 0:6b68dac0d986 | 24 | |
| embeddedartists | 0:6b68dac0d986 | 25 | /** Creates a FAT file system in SDRAM |
| embeddedartists | 0:6b68dac0d986 | 26 | * |
| embeddedartists | 0:6b68dac0d986 | 27 | * @code |
| embeddedartists | 0:6b68dac0d986 | 28 | * #include "mbed.h" |
| embeddedartists | 0:6b68dac0d986 | 29 | * #include "RAMFileSystem.h" |
| embeddedartists | 0:6b68dac0d986 | 30 | * |
| embeddedartists | 0:6b68dac0d986 | 31 | * RAMFileSystem ramfs(0xA0000000, 4*1024*1024, "ram"); // 4MB of ram starting at 0xA... |
| embeddedartists | 0:6b68dac0d986 | 32 | * |
| embeddedartists | 0:6b68dac0d986 | 33 | * int main() { |
| embeddedartists | 0:6b68dac0d986 | 34 | * sdram_init(); |
| embeddedartists | 0:6b68dac0d986 | 35 | * |
| embeddedartists | 0:6b68dac0d986 | 36 | * FILE *fp = fopen("/ram/myfile.txt", "w"); |
| embeddedartists | 0:6b68dac0d986 | 37 | * fprintf(fp, "Hello World!\n"); |
| embeddedartists | 0:6b68dac0d986 | 38 | * fclose(fp); |
| embeddedartists | 0:6b68dac0d986 | 39 | * } |
| embeddedartists | 0:6b68dac0d986 | 40 | * @endcode |
| embeddedartists | 0:6b68dac0d986 | 41 | */ |
| embeddedartists | 0:6b68dac0d986 | 42 | class RAMFileSystem : public FATFileSystem { |
| embeddedartists | 0:6b68dac0d986 | 43 | public: |
| embeddedartists | 0:6b68dac0d986 | 44 | |
| embeddedartists | 0:6b68dac0d986 | 45 | /** Create the File System in RAM |
| embeddedartists | 0:6b68dac0d986 | 46 | * |
| embeddedartists | 0:6b68dac0d986 | 47 | * @param addr Start of memory to use for file system |
| embeddedartists | 0:6b68dac0d986 | 48 | * @param size Number of bytes to use for file system |
| embeddedartists | 0:6b68dac0d986 | 49 | * @param name The name used to access the virtual filesystem |
| embeddedartists | 0:6b68dac0d986 | 50 | */ |
| embeddedartists | 0:6b68dac0d986 | 51 | RAMFileSystem(uint32_t addr, uint32_t size, const char* name); |
| embeddedartists | 0:6b68dac0d986 | 52 | virtual int disk_initialize(); |
| embeddedartists | 0:6b68dac0d986 | 53 | virtual int disk_status(); |
| embeddedartists | 0:6b68dac0d986 | 54 | virtual int disk_read(uint8_t * buffer, uint64_t sector, uint8_t count); |
| embeddedartists | 0:6b68dac0d986 | 55 | virtual int disk_write(const uint8_t * buffer, uint64_t sector, uint8_t count); |
| embeddedartists | 0:6b68dac0d986 | 56 | virtual int disk_sync(); |
| embeddedartists | 0:6b68dac0d986 | 57 | virtual uint64_t disk_sectors(); |
| embeddedartists | 0:6b68dac0d986 | 58 | |
| embeddedartists | 0:6b68dac0d986 | 59 | uint64_t disk_size(); |
| embeddedartists | 0:6b68dac0d986 | 60 | |
| embeddedartists | 0:6b68dac0d986 | 61 | protected: |
| embeddedartists | 0:6b68dac0d986 | 62 | |
| embeddedartists | 0:6b68dac0d986 | 63 | uint32_t memStart; |
| embeddedartists | 0:6b68dac0d986 | 64 | uint32_t memSize; |
| embeddedartists | 0:6b68dac0d986 | 65 | int status; |
| embeddedartists | 0:6b68dac0d986 | 66 | }; |
| embeddedartists | 0:6b68dac0d986 | 67 | |
| embeddedartists | 0:6b68dac0d986 | 68 | #endif |
