PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)
Dependents: YATTT sd_map_test cPong SnowDemo ... more
PokittoLib
Library for programming Pokitto hardware
How to Use
- Import this library to online compiler (see button "import" on the right hand side
- DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
- Change My_settings.h according to your project
- Start coding!
POKITTO_CORE/PokittoDisk.h@63:7d1c08cdde5c, 2018-10-23 (annotated)
- Committer:
- Pokitto
- Date:
- Tue Oct 23 16:21:01 2018 +0000
- Revision:
- 63:7d1c08cdde5c
- Parent:
- 52:c04087025cab
- Child:
- 66:6281a40d73e6
Graphics bug fixed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pokitto | 52:c04087025cab | 1 | /**************************************************************************/ |
Pokitto | 52:c04087025cab | 2 | /*! |
Pokitto | 52:c04087025cab | 3 | @file PokittoDisk.h |
Pokitto | 52:c04087025cab | 4 | @author Jonne Valola |
Pokitto | 52:c04087025cab | 5 | |
Pokitto | 52:c04087025cab | 6 | @section LICENSE |
Pokitto | 52:c04087025cab | 7 | |
Pokitto | 52:c04087025cab | 8 | Software License Agreement (BSD License) |
Pokitto | 52:c04087025cab | 9 | |
Pokitto | 52:c04087025cab | 10 | Copyright (c) 2016, Jonne Valola |
Pokitto | 52:c04087025cab | 11 | All rights reserved. |
Pokitto | 52:c04087025cab | 12 | |
Pokitto | 52:c04087025cab | 13 | Redistribution and use in source and binary forms, with or without |
Pokitto | 52:c04087025cab | 14 | modification, are permitted provided that the following conditions are met: |
Pokitto | 52:c04087025cab | 15 | 1. Redistributions of source code must retain the above copyright |
Pokitto | 52:c04087025cab | 16 | notice, this list of conditions and the following disclaimer. |
Pokitto | 52:c04087025cab | 17 | 2. Redistributions in binary form must reproduce the above copyright |
Pokitto | 52:c04087025cab | 18 | notice, this list of conditions and the following disclaimer in the |
Pokitto | 52:c04087025cab | 19 | documentation and/or other materials provided with the distribution. |
Pokitto | 52:c04087025cab | 20 | 3. Neither the name of the copyright holders nor the |
Pokitto | 52:c04087025cab | 21 | names of its contributors may be used to endorse or promote products |
Pokitto | 52:c04087025cab | 22 | derived from this software without specific prior written permission. |
Pokitto | 52:c04087025cab | 23 | |
Pokitto | 52:c04087025cab | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY |
Pokitto | 52:c04087025cab | 25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Pokitto | 52:c04087025cab | 26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Pokitto | 52:c04087025cab | 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY |
Pokitto | 52:c04087025cab | 28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Pokitto | 52:c04087025cab | 29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Pokitto | 52:c04087025cab | 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
Pokitto | 52:c04087025cab | 31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Pokitto | 52:c04087025cab | 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Pokitto | 52:c04087025cab | 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Pokitto | 52:c04087025cab | 34 | */ |
Pokitto | 52:c04087025cab | 35 | /**************************************************************************/ |
Pokitto | 52:c04087025cab | 36 | |
Pokitto | 52:c04087025cab | 37 | |
Pokitto | 52:c04087025cab | 38 | #ifndef POKITTO_DISK_H |
Pokitto | 52:c04087025cab | 39 | #define POKITTO_DISK_H |
Pokitto | 52:c04087025cab | 40 | |
Pokitto | 52:c04087025cab | 41 | #ifndef POK_SIM |
Pokitto | 52:c04087025cab | 42 | |
Pokitto | 52:c04087025cab | 43 | // real hardware disk driver |
Pokitto | 52:c04087025cab | 44 | #include "diskio.h" |
Pokitto | 52:c04087025cab | 45 | #include "pff.h" |
Pokitto | 52:c04087025cab | 46 | #include "connect.h" |
Pokitto | 52:c04087025cab | 47 | |
Pokitto | 52:c04087025cab | 48 | //using namespace PFFS; |
Pokitto | 52:c04087025cab | 49 | |
Pokitto | 52:c04087025cab | 50 | extern PFFS::BYTE res; |
Pokitto | 52:c04087025cab | 51 | extern PFFS::FATFS fs; /* File system object */ |
Pokitto | 52:c04087025cab | 52 | extern PFFS::FATDIR dir; /* Directory object */ |
Pokitto | 52:c04087025cab | 53 | extern PFFS::FILINFO fno; /* File information */ |
Pokitto | 52:c04087025cab | 54 | |
Pokitto | 52:c04087025cab | 55 | #include "mbed.h" |
Pokitto | 52:c04087025cab | 56 | |
Pokitto | 52:c04087025cab | 57 | extern SPI device; |
Pokitto | 52:c04087025cab | 58 | extern DigitalOut mmccs; |
Pokitto | 52:c04087025cab | 59 | |
Pokitto | 52:c04087025cab | 60 | /**************************************************************************/ |
Pokitto | 52:c04087025cab | 61 | /** SD CONTROL MACROS **/ |
Pokitto | 52:c04087025cab | 62 | /**************************************************************************/ |
Pokitto | 52:c04087025cab | 63 | |
Pokitto | 52:c04087025cab | 64 | // CS ... #define CONNECT_CS P0_7 //p13 |
Pokitto | 52:c04087025cab | 65 | #define CLR_SD_CS LPC_GPIO_PORT->CLR[0] = (1 << 7) |
Pokitto | 52:c04087025cab | 66 | #define SET_SD_CS LPC_GPIO_PORT->SET[0] = (1 << 7) |
Pokitto | 52:c04087025cab | 67 | #define GET_SD_CS LPC_GPIO_PORT->PIN[0] & (1 << 7) |
Pokitto | 52:c04087025cab | 68 | |
Pokitto | 52:c04087025cab | 69 | #else |
Pokitto | 52:c04087025cab | 70 | // simulated disk driver |
Pokitto | 52:c04087025cab | 71 | #endif |
Pokitto | 52:c04087025cab | 72 | |
Pokitto | 52:c04087025cab | 73 | #include <stdint.h> |
Pokitto | 52:c04087025cab | 74 | |
Pokitto | 52:c04087025cab | 75 | |
Pokitto | 52:c04087025cab | 76 | |
Pokitto | 52:c04087025cab | 77 | extern int pokInitSD(); |
Pokitto | 52:c04087025cab | 78 | |
Pokitto | 52:c04087025cab | 79 | // File IO modes |
Pokitto | 52:c04087025cab | 80 | #define FILE_MODE_APPEND 0x1 |
Pokitto | 52:c04087025cab | 81 | #define FILE_MODE_OVERWRITE 0 |
Pokitto | 52:c04087025cab | 82 | #define FILE_MODE_READONLY 0x2 |
Pokitto | 52:c04087025cab | 83 | #define FILE_MODE_READWRITE 0 |
Pokitto | 52:c04087025cab | 84 | #define FILE_MODE_BINARY 0x4 |
Pokitto | 52:c04087025cab | 85 | #define FILE_MODE_ASCII 0 |
Pokitto | 52:c04087025cab | 86 | #define FILE_MODE_FAILED 0x8 |
Pokitto | 52:c04087025cab | 87 | #define FILE_MODE_UNINITIALIZED 0x10 |
Pokitto | 52:c04087025cab | 88 | |
Pokitto | 52:c04087025cab | 89 | extern uint8_t fileOpen(char*, char); |
Pokitto | 52:c04087025cab | 90 | extern void fileClose(); |
Pokitto | 52:c04087025cab | 91 | extern char fileGetChar(); |
Pokitto | 52:c04087025cab | 92 | extern void filePutChar(char); |
Pokitto | 52:c04087025cab | 93 | extern void fileWriteBytes(uint8_t *, uint16_t); |
Pokitto | 52:c04087025cab | 94 | extern uint16_t fileReadBytes(uint8_t *, uint16_t); |
Pokitto | 52:c04087025cab | 95 | extern void fileSeekAbsolute(long); |
Pokitto | 52:c04087025cab | 96 | extern void fileSeekRelative(long); |
Pokitto | 52:c04087025cab | 97 | extern void fileRewind(); |
Pokitto | 52:c04087025cab | 98 | extern void fileEnd(); |
Pokitto | 52:c04087025cab | 99 | extern long int fileGetPosition(); |
Pokitto | 52:c04087025cab | 100 | #define fileSetPosition(n) (fileSeekAbsolute(n)) |
Pokitto | 52:c04087025cab | 101 | extern uint8_t filePeek(long); |
Pokitto | 52:c04087025cab | 102 | extern void filePoke(long, uint8_t); |
Pokitto | 52:c04087025cab | 103 | extern int fileReadLine(char*,int); |
Pokitto | 52:c04087025cab | 104 | extern char* getCurrentFileName (); |
Pokitto | 52:c04087025cab | 105 | extern char* getNextFile (char*); |
Pokitto | 52:c04087025cab | 106 | extern char* getNextFile (); |
Pokitto | 52:c04087025cab | 107 | extern char* getFirstFile(char*); |
Pokitto | 52:c04087025cab | 108 | extern char* getFirstFile(); |
Pokitto | 52:c04087025cab | 109 | extern char* getFirstDirEntry(); |
Pokitto | 52:c04087025cab | 110 | extern char* getNextDirEntry(); |
Pokitto | 52:c04087025cab | 111 | extern int isThisFileOpen(char*); |
Pokitto | 52:c04087025cab | 112 | extern int fileOK(); |
Pokitto | 52:c04087025cab | 113 | extern int dirOpen(); |
Pokitto | 52:c04087025cab | 114 | extern int dirUp(); |
Pokitto | 52:c04087025cab | 115 | |
Pokitto | 52:c04087025cab | 116 | #endif // POKITTO_DISK_H |
Pokitto | 52:c04087025cab | 117 | |
Pokitto | 52:c04087025cab | 118 | |
Pokitto | 52:c04087025cab | 119 |