Test of Embedded Artists LPCXpresso baseboard SD card and ethernet facilities. This program downloads files from a website to the SD card. This program now uses the HTTPClient from: http://mbed.org/users/donatien/programs/HTTPClient/latest which downloads the files without errors. The previous version of this program was used to demonstrate that an earlier HTTPClient downloaded files with errors.

Dependencies:   EthernetNetIf mbed

Committer:
tom_coxon
Date:
Fri Aug 13 14:45:50 2010 +0000
Revision:
1:0734a7b0fd5e

        

Who changed what in which revision?

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