![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Test of Embedded Artists LPCXpresso baseboard ethernet, SD card, audio and OLED display facilities. The program displays the day, date and time on the baseboard OLED and sounds the Big Ben chimes on the hour and quarter hour. On initial startup the program checks that the mbed clock is set and that the chime wav files can be accessed on the SD card. If not it asks to be connected to the internet to obtain the current time and to download the wav files to the SD card.
Dependencies: EthernetNetIf NTPClient_NetServices mbed EAOLED
SDHCFileSystem.h@0:f61e8db0570d, 2010-08-14 (annotated)
- Committer:
- tom_coxon
- Date:
- Sat Aug 14 10:33:13 2010 +0000
- Revision:
- 0:f61e8db0570d
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tom_coxon | 0:f61e8db0570d | 1 | /* mbed SDFileSystem Library, for providing file access to SD cards |
tom_coxon | 0:f61e8db0570d | 2 | * Copyright (c) 2008-2010, sford |
tom_coxon | 0:f61e8db0570d | 3 | * |
tom_coxon | 0:f61e8db0570d | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
tom_coxon | 0:f61e8db0570d | 5 | * of this software and associated documentation files (the "Software"), to deal |
tom_coxon | 0:f61e8db0570d | 6 | * in the Software without restriction, including without limitation the rights |
tom_coxon | 0:f61e8db0570d | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
tom_coxon | 0:f61e8db0570d | 8 | * copies of the Software, and to permit persons to whom the Software is |
tom_coxon | 0:f61e8db0570d | 9 | * furnished to do so, subject to the following conditions: |
tom_coxon | 0:f61e8db0570d | 10 | * |
tom_coxon | 0:f61e8db0570d | 11 | * The above copyright notice and this permission notice shall be included in |
tom_coxon | 0:f61e8db0570d | 12 | * all copies or substantial portions of the Software. |
tom_coxon | 0:f61e8db0570d | 13 | * |
tom_coxon | 0:f61e8db0570d | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
tom_coxon | 0:f61e8db0570d | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
tom_coxon | 0:f61e8db0570d | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
tom_coxon | 0:f61e8db0570d | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
tom_coxon | 0:f61e8db0570d | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
tom_coxon | 0:f61e8db0570d | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
tom_coxon | 0:f61e8db0570d | 20 | * THE SOFTWARE. |
tom_coxon | 0:f61e8db0570d | 21 | */ |
tom_coxon | 0:f61e8db0570d | 22 | |
tom_coxon | 0:f61e8db0570d | 23 | #ifndef MBED_SDHCFILESYSTEM_H |
tom_coxon | 0:f61e8db0570d | 24 | #define MBED_SDHCFILESYSTEM_H |
tom_coxon | 0:f61e8db0570d | 25 | |
tom_coxon | 0:f61e8db0570d | 26 | #include "mbed.h" |
tom_coxon | 0:f61e8db0570d | 27 | #include "FATFileSystem.h" |
tom_coxon | 0:f61e8db0570d | 28 | |
tom_coxon | 0:f61e8db0570d | 29 | /* Double Words */ |
tom_coxon | 0:f61e8db0570d | 30 | typedef unsigned long long uint64_t; |
tom_coxon | 0:f61e8db0570d | 31 | typedef long long sint64_t; |
tom_coxon | 0:f61e8db0570d | 32 | |
tom_coxon | 0:f61e8db0570d | 33 | /** Access the filesystem on an SD Card using SPI |
tom_coxon | 0:f61e8db0570d | 34 | * |
tom_coxon | 0:f61e8db0570d | 35 | * @code |
tom_coxon | 0:f61e8db0570d | 36 | * #include "mbed.h" |
tom_coxon | 0:f61e8db0570d | 37 | * #include "SDFileSystem.h" |
tom_coxon | 0:f61e8db0570d | 38 | * |
tom_coxon | 0:f61e8db0570d | 39 | * SDFileSystem sd(p5, p6, p7, p12, "sd"); // mosi, miso, sclk, cs |
tom_coxon | 0:f61e8db0570d | 40 | * |
tom_coxon | 0:f61e8db0570d | 41 | * int main() { |
tom_coxon | 0:f61e8db0570d | 42 | * FILE *fp = fopen("/sd/myfile.txt", "w"); |
tom_coxon | 0:f61e8db0570d | 43 | * fprintf(fp, "Hello World!\n"); |
tom_coxon | 0:f61e8db0570d | 44 | * fclose(fp); |
tom_coxon | 0:f61e8db0570d | 45 | * } |
tom_coxon | 0:f61e8db0570d | 46 | */ |
tom_coxon | 0:f61e8db0570d | 47 | class SDFileSystem : public FATFileSystem { |
tom_coxon | 0:f61e8db0570d | 48 | public: |
tom_coxon | 0:f61e8db0570d | 49 | |
tom_coxon | 0:f61e8db0570d | 50 | /** Create the File System for accessing an SD Card using SPI |
tom_coxon | 0:f61e8db0570d | 51 | * |
tom_coxon | 0:f61e8db0570d | 52 | * @param mosi SPI mosi pin connected to SD Card |
tom_coxon | 0:f61e8db0570d | 53 | * @param miso SPI miso pin conencted to SD Card |
tom_coxon | 0:f61e8db0570d | 54 | * @param sclk SPI sclk pin connected to SD Card |
tom_coxon | 0:f61e8db0570d | 55 | * @param cs DigitalOut pin used as SD Card chip select |
tom_coxon | 0:f61e8db0570d | 56 | * @param name The name used to access the virtual filesystem |
tom_coxon | 0:f61e8db0570d | 57 | */ |
tom_coxon | 0:f61e8db0570d | 58 | SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name); |
tom_coxon | 0:f61e8db0570d | 59 | virtual int disk_initialize(); |
tom_coxon | 0:f61e8db0570d | 60 | virtual int disk_write(const char *buffer, int block_number); |
tom_coxon | 0:f61e8db0570d | 61 | virtual int disk_read(char *buffer, int block_number); |
tom_coxon | 0:f61e8db0570d | 62 | virtual int disk_status(); |
tom_coxon | 0:f61e8db0570d | 63 | virtual int disk_sync(); |
tom_coxon | 0:f61e8db0570d | 64 | virtual int disk_sectors(); |
tom_coxon | 0:f61e8db0570d | 65 | |
tom_coxon | 0:f61e8db0570d | 66 | protected: |
tom_coxon | 0:f61e8db0570d | 67 | |
tom_coxon | 0:f61e8db0570d | 68 | int _cmd(int cmd, int arg); |
tom_coxon | 0:f61e8db0570d | 69 | int _cmdx(int cmd, int arg); |
tom_coxon | 0:f61e8db0570d | 70 | int _cmd8(); |
tom_coxon | 0:f61e8db0570d | 71 | int _cmd58(); |
tom_coxon | 0:f61e8db0570d | 72 | int initialise_card(); |
tom_coxon | 0:f61e8db0570d | 73 | int initialise_card_v1(); |
tom_coxon | 0:f61e8db0570d | 74 | int initialise_card_v2(); |
tom_coxon | 0:f61e8db0570d | 75 | |
tom_coxon | 0:f61e8db0570d | 76 | int _read(char *buffer, int length); |
tom_coxon | 0:f61e8db0570d | 77 | int _write(const char *buffer, int length); |
tom_coxon | 0:f61e8db0570d | 78 | int _sd_sectors(); |
tom_coxon | 0:f61e8db0570d | 79 | int _sectors; |
tom_coxon | 0:f61e8db0570d | 80 | |
tom_coxon | 0:f61e8db0570d | 81 | SPI _spi; |
tom_coxon | 0:f61e8db0570d | 82 | DigitalOut _cs; |
tom_coxon | 0:f61e8db0570d | 83 | int cdv; |
tom_coxon | 0:f61e8db0570d | 84 | }; |
tom_coxon | 0:f61e8db0570d | 85 | |
tom_coxon | 0:f61e8db0570d | 86 | #endif |