This is the firmware for the LaOS - Laser Open Source project. You can use it to drive a laser cutter. For hardware and more information, look at our wiki: http://wiki.laoslaser.org

Dependencies:   EthernetNetIf mbed

Committer:
fablabtruck
Date:
Fri Jun 08 09:26:40 2012 +0000
Revision:
0:3852426a5068
svn revision 379

Who changed what in which revision?

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