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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PokittoDisk.h Source File

PokittoDisk.h

Go to the documentation of this file.
00001 /**************************************************************************/
00002 /*!
00003     @file     PokittoDisk.h
00004     @author   Jonne Valola
00005 
00006     @section LICENSE
00007 
00008     Software License Agreement (BSD License)
00009 
00010     Copyright (c) 2016, Jonne Valola
00011     All rights reserved.
00012 
00013     Redistribution and use in source and binary forms, with or without
00014     modification, are permitted provided that the following conditions are met:
00015     1. Redistributions of source code must retain the above copyright
00016     notice, this list of conditions and the following disclaimer.
00017     2. Redistributions in binary form must reproduce the above copyright
00018     notice, this list of conditions and the following disclaimer in the
00019     documentation and/or other materials provided with the distribution.
00020     3. Neither the name of the copyright holders nor the
00021     names of its contributors may be used to endorse or promote products
00022     derived from this software without specific prior written permission.
00023 
00024     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
00025     EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00026     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
00028     DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00031     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00033     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 */
00035 /**************************************************************************/
00036 
00037 
00038 #ifndef POKITTO_DISK_H
00039 #define POKITTO_DISK_H
00040 
00041 #ifndef POK_SIM
00042 
00043 // real hardware disk driver
00044 #include "diskio.h"
00045 #include "pff.h"
00046 #include "connect.h"
00047 
00048 //using namespace PFFS;
00049 
00050 extern PFFS::BYTE res;
00051 extern PFFS::FATFS fs;            /* File system object */
00052 extern PFFS::FATDIR dir;            /* Directory object */
00053 extern PFFS::FILINFO fno;        /* File information */
00054 
00055 #include "mbed.h"
00056 
00057 extern SPI device;
00058 extern DigitalOut mmccs;
00059 
00060 /**************************************************************************/
00061 /**                          SD CONTROL MACROS                           **/
00062 /**************************************************************************/
00063 
00064 // CS ... #define CONNECT_CS      P0_7 //p13
00065 #define CLR_SD_CS LPC_GPIO_PORT->CLR[0] = (1 << 7)
00066 #define SET_SD_CS LPC_GPIO_PORT->SET[0] = (1 << 7)
00067 #define GET_SD_CS LPC_GPIO_PORT->PIN[0] & (1 << 7)
00068 
00069 #else
00070 // simulated disk driver
00071 #endif
00072 
00073 #include <stdint.h>
00074 
00075 
00076 
00077 extern int pokInitSD();
00078 
00079 // File IO modes
00080 #define FILE_MODE_APPEND 0x1
00081 #define FILE_MODE_OVERWRITE 0
00082 #define FILE_MODE_READONLY 0x2
00083 #define FILE_MODE_READWRITE 0
00084 #define FILE_MODE_BINARY 0x4
00085 #define FILE_MODE_ASCII 0
00086 #define FILE_MODE_FAILED 0x8
00087 #define FILE_MODE_UNINITIALIZED 0x10
00088 
00089 extern uint8_t fileOpen(char*, char);
00090 extern void fileClose();
00091 extern char fileGetChar();
00092 extern void filePutChar(char);
00093 extern void fileWriteBytes(uint8_t *, uint16_t);
00094 extern uint16_t fileReadBytes(uint8_t *, uint16_t);
00095 extern void fileSeekAbsolute(long);
00096 extern void fileSeekRelative(long);
00097 extern void fileRewind();
00098 extern void fileEnd();
00099 extern long int fileGetPosition();
00100 #define fileSetPosition(n)  (fileSeekAbsolute(n))
00101 extern uint8_t filePeek(long);
00102 extern void filePoke(long, uint8_t);
00103 extern int fileReadLine(char*,int);
00104 extern char* getCurrentFileName ();
00105 extern char* getNextFile (char*);
00106 extern char* getNextFile ();
00107 extern char* getFirstFile(char*);
00108 extern char* getFirstFile();
00109 extern char* getFirstDirEntry();
00110 extern char* getNextDirEntry();
00111 extern int isThisFileOpen(char*);
00112 extern int fileOK();
00113 extern int dirOpen();
00114 extern int dirUp();
00115 
00116 #endif // POKITTO_DISK_H
00117 
00118 
00119