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