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.
SDFileSystem.h
00001 /* mbed Microcontroller Library - SDFileSystem 00002 * Copyright (c) 2008-2009, sford 00003 */ 00004 00005 #ifndef SDFILESYSTEM_H 00006 #define SDFILESYSTEM_H 00007 00008 #include "mbed.h" 00009 #include "FATFileSystem.h" 00010 00011 /* Class: SDFileSystem 00012 * Access the filesystem on an SD Card using SPI 00013 * 00014 * Example: 00015 * > SDFileSystem sd(p5, p6, p7, p12, "sd"); 00016 * > 00017 * > int main() { 00018 * > FILE *fp = fopen("/sd/myfile.txt", "w"); 00019 * > fprintf(fp, "Hello World!\n"); 00020 * > fclose(fp); 00021 * > } 00022 */ 00023 class SDFileSystem : public FATFileSystem { 00024 public: 00025 00026 /* Constructor: SDFileSystem 00027 * Create the File System for accessing an SD Card using SPI 00028 * 00029 * Variables: 00030 * mosi - SPI mosi pin connected to SD Card 00031 * miso - SPI miso pin conencted to SD Card 00032 * sclk - SPI sclk pin connected to SD Card 00033 * cs - DigitalOut pin used as SD Card chip select 00034 * name - The name used to access the filesystem 00035 */ 00036 SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name); 00037 virtual int disk_initialize(); 00038 virtual int disk_write(const char *buffer, int block_number); 00039 virtual int disk_read(char *buffer, int block_number); 00040 virtual int disk_status(); 00041 virtual int disk_sync(); 00042 virtual int disk_sectors(); 00043 00044 protected: 00045 00046 int _cmd(int cmd, int arg); 00047 int _cmd8(); 00048 00049 int _read(char *buffer, int length); 00050 int _write(const char *buffer, int length); 00051 int _sd_sectors(); 00052 int _sectors; 00053 00054 SPI _spi; 00055 DigitalOut _cs; 00056 }; 00057 00058 #endif
Generated on Tue Jul 12 2022 20:39:37 by
1.7.2