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