Hepta_CAM&GPS

Dependencies:   FatFileSystem HeptaSerial mbed

Fork of CameraC1098_Sample by Tadao Iida

Committer:
hepta2ume
Date:
Wed Jul 19 09:25:34 2017 +0000
Revision:
1:890188e041da
Hepta2_Cam&GPS

Who changed what in which revision?

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