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

  1. Import this library to online compiler (see button "import" on the right hand side
  2. DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
  3. Change My_settings.h according to your project
  4. Start coding!
Committer:
Pokitto
Date:
Mon Apr 02 22:37:22 2018 +0000
Revision:
36:771321e70814
Synced with Github repo

Who changed what in which revision?

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