Game for Leeds University Gamepad for the FRDM-K64F: Game is a RPG Horror Title.

Dependencies:   mbed FATFileSystem

Committer:
rottenegg
Date:
Fri May 10 21:25:27 2019 +0000
Revision:
26:716bcd47f3ca
Parent:
3:63cdd5cab431
FINAL_SUBMISSION; ; Changes:; WDplayer: Major Memory Leek fixed related to fclose(); Game_Manager: Tuned Scene Order and Improved Random number generator.; SceneFuctions: Added a Randomly changing Object to Scene 4.

Who changed what in which revision?

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