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

Committer:
Pokitto
Date:
Tue Jan 30 10:41:47 2018 +0000
Revision:
31:f4b9b85c7b62
Sound output improvements added:  louder, clearer, faster!

Who changed what in which revision?

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