SNAKE GAME

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
congvu
Date:
Wed Nov 25 04:25:25 2020 +0000
Revision:
0:24041b847eb5
ECE2035 SNAKE GAME;

Who changed what in which revision?

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