Georgia Tech ECE2035 Project P2-2 shell code.

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

q

Committer:
rashidi1saeed
Date:
Mon Oct 28 05:26:35 2019 +0000
Revision:
3:e4690ad5a4d2
Parent:
0:35660d7952f7
added more comments

Who changed what in which revision?

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