PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Dependents:   Sensitive

Fork of PokittoLib by Jonne Valola

Committer:
spinal
Date:
Wed Oct 18 14:47:54 2017 +0000
Revision:
15:0bbe8f6fae32
Parent:
0:e8b8f36b4505
direct lcd stuff used by sensitive

Who changed what in which revision?

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