Version du programme présentée a Clermont

Dependencies:   SHTx mbed BMP085

Committer:
projetmeteo3
Date:
Sat Mar 24 09:51:56 2012 +0000
Revision:
0:eb2609ff92d2
V. Jury

Who changed what in which revision?

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