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 Macros_LCD.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) 2015, 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 #ifndef LCDMACROS_H
Pokitto 0:e8b8f36b4505 38 #define LCDMACROS_H
Pokitto 0:e8b8f36b4505 39
Pokitto 0:e8b8f36b4505 40 /**************************************************************************/
Pokitto 0:e8b8f36b4505 41 /** PINS AND PORTS **/
Pokitto 0:e8b8f36b4505 42 /**************************************************************************/
Pokitto 0:e8b8f36b4505 43
Pokitto 0:e8b8f36b4505 44 #if POK_BOARDREV == 1
Pokitto 0:e8b8f36b4505 45 /** 2-layer board version 1.3 **/
Pokitto 0:e8b8f36b4505 46 #define LCD_CD_PORT 0
Pokitto 0:e8b8f36b4505 47 #define LCD_CD_PIN 2
Pokitto 0:e8b8f36b4505 48 #define LCD_WR_PORT 1
Pokitto 0:e8b8f36b4505 49 #define LCD_WR_PIN 23
Pokitto 0:e8b8f36b4505 50 #define LCD_RD_PORT 1
Pokitto 0:e8b8f36b4505 51 #define LCD_RD_PIN 24
Pokitto 0:e8b8f36b4505 52 #define LCD_RES_PORT 1
Pokitto 0:e8b8f36b4505 53 #define LCD_RES_PIN 28
Pokitto 0:e8b8f36b4505 54 #else
Pokitto 0:e8b8f36b4505 55 /** 4-layer board version 2.1 **/
Pokitto 0:e8b8f36b4505 56 #define LCD_CD_PORT 0
Pokitto 0:e8b8f36b4505 57 #define LCD_CD_PIN 2
Pokitto 0:e8b8f36b4505 58 #define LCD_WR_PORT 1
Pokitto 0:e8b8f36b4505 59 #define LCD_WR_PIN 12
Pokitto 0:e8b8f36b4505 60 #define LCD_RD_PORT 1
Pokitto 0:e8b8f36b4505 61 #define LCD_RD_PIN 24
Pokitto 0:e8b8f36b4505 62 #define LCD_RES_PORT 1
Pokitto 0:e8b8f36b4505 63 #define LCD_RES_PIN 0
Pokitto 0:e8b8f36b4505 64 #endif
Pokitto 0:e8b8f36b4505 65
Pokitto 0:e8b8f36b4505 66 /**************************************************************************/
Pokitto 0:e8b8f36b4505 67 /** LCD CONTROL MACROS **/
Pokitto 0:e8b8f36b4505 68 /**************************************************************************/
Pokitto 0:e8b8f36b4505 69
Pokitto 0:e8b8f36b4505 70 #define CLR_RESET LPC_GPIO_PORT->CLR[LCD_RES_PORT] = 1 << LCD_RES_PIN; //RST = (0); // Clear pin
Pokitto 0:e8b8f36b4505 71 #define SET_RESET LPC_GPIO_PORT->SET[LCD_RES_PORT] = 1 << LCD_RES_PIN; // RST = (1); // Set pin
Pokitto 0:e8b8f36b4505 72
Pokitto 0:e8b8f36b4505 73 #define CLR_CD LPC_GPIO_PORT->CLR[LCD_CD_PORT] = 1 << LCD_CD_PIN; // RS = (0); // Clear pin
Pokitto 0:e8b8f36b4505 74 #define SET_CD LPC_GPIO_PORT->SET[LCD_CD_PORT] = 1 << LCD_CD_PIN; // RS = (1); // Set pin
Pokitto 0:e8b8f36b4505 75
Pokitto 0:e8b8f36b4505 76 #define CLR_WR { LPC_GPIO_PORT->CLR[LCD_WR_PORT] = 1 << LCD_WR_PIN; __asm("nop");}//WR = (0); // Clear pin
Pokitto 0:e8b8f36b4505 77 #define SET_WR LPC_GPIO_PORT->SET[LCD_WR_PORT] = 1 << LCD_WR_PIN; //WR = (1); // Set pin
Pokitto 0:e8b8f36b4505 78
Pokitto 0:e8b8f36b4505 79 #define CLR_RD LPC_GPIO_PORT->CLR[LCD_RD_PORT] = 1 << LCD_RD_PIN; //RD = (0); // Clear pin
Pokitto 0:e8b8f36b4505 80 #define SET_RD LPC_GPIO_PORT->SET[LCD_RD_PORT] = 1 << LCD_RD_PIN; //RD = (1); // Set pin
Pokitto 0:e8b8f36b4505 81
Pokitto 0:e8b8f36b4505 82 #define SET_CS //CS tied to ground
Pokitto 0:e8b8f36b4505 83 #define CLR_CS
Pokitto 0:e8b8f36b4505 84
Pokitto 0:e8b8f36b4505 85 #define CLR_CS_CD_SET_RD_WR {CLR_CD; SET_RD; SET_WR;}
Pokitto 0:e8b8f36b4505 86 #define CLR_CS_SET_CD_RD_WR {SET_CD; SET_RD; SET_WR;}
Pokitto 0:e8b8f36b4505 87 #define SET_CD_RD_WR {SET_CD; SET_RD; SET_WR;}
Pokitto 0:e8b8f36b4505 88 #define SET_WR_CS SET_WR;
Pokitto 0:e8b8f36b4505 89
Pokitto 0:e8b8f36b4505 90 #define SET_MASK_P2 LPC_GPIO_PORT->MASK[2] = ~(0x7FFF8); //mask P2_3 ...P2_18
Pokitto 0:e8b8f36b4505 91 #define CLR_MASK_P2 LPC_GPIO_PORT->MASK[2] = 0; // all on
Pokitto 0:e8b8f36b4505 92
Pokitto 0:e8b8f36b4505 93 /**************************************************************************/
Pokitto 0:e8b8f36b4505 94 /** OTHER MACROS **/
Pokitto 0:e8b8f36b4505 95 /**************************************************************************/
Pokitto 0:e8b8f36b4505 96
Pokitto 0:e8b8f36b4505 97 #define write_command w_cmd_16
Pokitto 0:e8b8f36b4505 98 #define write_data w_data_16
Pokitto 0:e8b8f36b4505 99
Pokitto 0:e8b8f36b4505 100 #define AB_JUMP 1024 // jump one 1-bit Arduboy screen forward to get next color bit
Pokitto 0:e8b8f36b4505 101 #define GB_JUMP 504 // jump one 1-bit Gamebuino screen forward to get next color bit
Pokitto 0:e8b8f36b4505 102
Pokitto 0:e8b8f36b4505 103 #endif // LCDMACROS_H
Pokitto 0:e8b8f36b4505 104