4D systems Picaso uLCD 32PTU touch display library

Committer:
CaptainR
Date:
Mon Sep 26 13:41:22 2016 +0000
Revision:
21:ea68a8a3cea4
Parent:
20:88e137b9ea46
Child:
22:cea582ea74c1
file error not checked yet, because MBED not working properly :)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CaptainR 20:88e137b9ea46 1 //
CaptainR 20:88e137b9ea46 2 // Picaso_4DGL-32PTU is a class to drive 4D Systems TFT touch screens with PICASO processor
CaptainR 20:88e137b9ea46 3 // Tested with NUCLEO L152RE development board
CaptainR 20:88e137b9ea46 4 // Copyright (C) <2016> Rihards Balass <rihards.balass@gmail.com>
CaptainR 20:88e137b9ea46 5 //
CaptainR 20:88e137b9ea46 6 // Picaso_4DGL-32PTU is free software: you can redistribute it and/or modify
CaptainR 20:88e137b9ea46 7 // it under the terms of the GNU General Public License as published by
CaptainR 20:88e137b9ea46 8 // the Free Software Foundation, either version 3 of the License, or
CaptainR 20:88e137b9ea46 9 // (at your option) any later version.
CaptainR 20:88e137b9ea46 10 //
CaptainR 20:88e137b9ea46 11 // Picaso_4DGL-32PTU is distributed in the hope that it will be useful,
CaptainR 20:88e137b9ea46 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
CaptainR 20:88e137b9ea46 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
CaptainR 20:88e137b9ea46 14 // GNU General Public License for more details.
CaptainR 20:88e137b9ea46 15 //
CaptainR 20:88e137b9ea46 16 // You can see GNU General Public License at <http://www.gnu.org/licenses/>.
CaptainR 20:88e137b9ea46 17 //
CaptainR 20:88e137b9ea46 18
CaptainR 20:88e137b9ea46 19 #include "mbed.h"
CaptainR 20:88e137b9ea46 20 #include "Picaso_4DGL-32PTU.h"
CaptainR 20:88e137b9ea46 21
CaptainR 20:88e137b9ea46 22 //**************************************************************************
CaptainR 20:88e137b9ea46 23 // Starts up the FAT16 disk file services and allocates a small 32 byte control block
CaptainR 20:88e137b9ea46 24 // for subsequent use. When you open a file using the “File Open” command
CaptainR 20:88e137b9ea46 25 // further 512 + 44 = 556 bytes are attached to the FAT16 file control block.
CaptainR 20:88e137b9ea46 26 // When you close a file using the “File Close” command, the 556 byte allocation
CaptainR 20:88e137b9ea46 27 // is released leaving the 32 byte file control block.
CaptainR 20:88e137b9ea46 28 // The File Mount command must be called before any other FAT16 file related
CaptainR 20:88e137b9ea46 29 // functions can be used. The control block and all FAT16 file resources are
CaptainR 20:88e137b9ea46 30 // completely released with the “File Unmount” command.
CaptainR 20:88e137b9ea46 31 //**************************************************************************
CaptainR 20:88e137b9ea46 32 bool PICASO_4DGL :: file_Mount() {
CaptainR 20:88e137b9ea46 33
CaptainR 20:88e137b9ea46 34 char command[2] = "";
CaptainR 20:88e137b9ea46 35
CaptainR 20:88e137b9ea46 36 command[0] = (FILE_MOUNT >> (8*1)) & 0xff;
CaptainR 20:88e137b9ea46 37 command[1] = (FILE_MOUNT >> (8*0)) & 0xff;
CaptainR 20:88e137b9ea46 38
CaptainR 20:88e137b9ea46 39 writeCOMMAND(command, 2);
CaptainR 20:88e137b9ea46 40 bool success = fileMountResponse();
CaptainR 20:88e137b9ea46 41 #ifdef DEBUGMODE
CaptainR 20:88e137b9ea46 42 pc.printf("\n\r DEBUG: FAT16 Mount: %s\n\r", success ? "true" : "false");
CaptainR 20:88e137b9ea46 43 #endif
CaptainR 20:88e137b9ea46 44 return success;
CaptainR 20:88e137b9ea46 45 }
CaptainR 21:ea68a8a3cea4 46
CaptainR 21:ea68a8a3cea4 47 //**************************************************************************
CaptainR 21:ea68a8a3cea4 48 // Returns the most recent error code or 0 if there were no errors.
CaptainR 21:ea68a8a3cea4 49 // Returns Error Number.
CaptainR 21:ea68a8a3cea4 50 // 1 IDE command execution error
CaptainR 21:ea68a8a3cea4 51 // 2 CARD not present
CaptainR 21:ea68a8a3cea4 52 // 3 WRONG partition type, not FAT16
CaptainR 21:ea68a8a3cea4 53 // 4 MBR sector invalid signature
CaptainR 21:ea68a8a3cea4 54 // 5 Boot Record invalid signature
CaptainR 21:ea68a8a3cea4 55 // 6 Media not mounted
CaptainR 21:ea68a8a3cea4 56 // 7 File not found in open for read
CaptainR 21:ea68a8a3cea4 57 // 8 File not open
CaptainR 21:ea68a8a3cea4 58 // 9 Fat attempt to read beyond EOF
CaptainR 21:ea68a8a3cea4 59 // 10 Reached the end of file
CaptainR 21:ea68a8a3cea4 60 // 11 Invalid cluster value > maxcls
CaptainR 21:ea68a8a3cea4 61 // 12 All root dir entry are taken
CaptainR 21:ea68a8a3cea4 62 // 13 All clusters in partition are taken
CaptainR 21:ea68a8a3cea4 63 // 14 A file with same name exist already
CaptainR 21:ea68a8a3cea4 64 // 15 Cannot init the CARD
CaptainR 21:ea68a8a3cea4 65 // 16 Cannot read the MBR
CaptainR 21:ea68a8a3cea4 66 // 17 Malloc could not allocate the FILE struct
CaptainR 21:ea68a8a3cea4 67 // 18 Mode was not r.w.
CaptainR 21:ea68a8a3cea4 68 // 19 Failure during FILE search
CaptainR 21:ea68a8a3cea4 69 // 20 Invalid Filename
CaptainR 21:ea68a8a3cea4 70 // 21 bad media
CaptainR 21:ea68a8a3cea4 71 // 22 Sector Read fail
CaptainR 21:ea68a8a3cea4 72 // 23 Sector write fail
CaptainR 21:ea68a8a3cea4 73 //**************************************************************************
CaptainR 21:ea68a8a3cea4 74 short PICASO_4DGL :: file_Error() {
CaptainR 21:ea68a8a3cea4 75
CaptainR 21:ea68a8a3cea4 76 char command[2] = "";
CaptainR 21:ea68a8a3cea4 77
CaptainR 21:ea68a8a3cea4 78 command[0] = (FILE_ERROR >> (8*1)) & 0xff;
CaptainR 21:ea68a8a3cea4 79 command[1] = (FILE_ERROR >> (8*0)) & 0xff;
CaptainR 21:ea68a8a3cea4 80
CaptainR 21:ea68a8a3cea4 81 writeCOMMAND(command, 2);
CaptainR 21:ea68a8a3cea4 82 short error = fileErrorResponse();
CaptainR 21:ea68a8a3cea4 83 #ifdef DEBUGMODE
CaptainR 21:ea68a8a3cea4 84 pc.printf("\n\r DEBUG: FAT16 Error: %i\n\r", error);
CaptainR 21:ea68a8a3cea4 85 #endif
CaptainR 21:ea68a8a3cea4 86 return error;
CaptainR 21:ea68a8a3cea4 87 }
CaptainR 21:ea68a8a3cea4 88
CaptainR 21:ea68a8a3cea4 89
CaptainR 21:ea68a8a3cea4 90
CaptainR 21:ea68a8a3cea4 91