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:
7:72f87b7c7400
direct lcd stuff used by sensitive

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 7:72f87b7c7400 1 /**************************************************************************/
Pokitto 7:72f87b7c7400 2 /*!
Pokitto 7:72f87b7c7400 3 @file PokittoHW.cpp
Pokitto 7:72f87b7c7400 4 @author Jonne Valola
Pokitto 7:72f87b7c7400 5
Pokitto 7:72f87b7c7400 6 @section LICENSE
Pokitto 7:72f87b7c7400 7
Pokitto 7:72f87b7c7400 8 Software License Agreement (BSD License)
Pokitto 7:72f87b7c7400 9
Pokitto 7:72f87b7c7400 10 Copyright (c) 2015, Jonne Valola
Pokitto 7:72f87b7c7400 11 All rights reserved.
Pokitto 7:72f87b7c7400 12
Pokitto 7:72f87b7c7400 13 Redistribution and use in source and binary forms, with or without
Pokitto 7:72f87b7c7400 14 modification, are permitted provided that the following conditions are met:
Pokitto 7:72f87b7c7400 15 1. Redistributions of source code must retain the above copyright
Pokitto 7:72f87b7c7400 16 notice, this list of conditions and the following disclaimer.
Pokitto 7:72f87b7c7400 17 2. Redistributions in binary form must reproduce the above copyright
Pokitto 7:72f87b7c7400 18 notice, this list of conditions and the following disclaimer in the
Pokitto 7:72f87b7c7400 19 documentation and/or other materials provided with the distribution.
Pokitto 7:72f87b7c7400 20 3. Neither the name of the copyright holders nor the
Pokitto 7:72f87b7c7400 21 names of its contributors may be used to endorse or promote products
Pokitto 7:72f87b7c7400 22 derived from this software without specific prior written permission.
Pokitto 7:72f87b7c7400 23
Pokitto 7:72f87b7c7400 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
Pokitto 7:72f87b7c7400 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Pokitto 7:72f87b7c7400 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Pokitto 7:72f87b7c7400 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
Pokitto 7:72f87b7c7400 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Pokitto 7:72f87b7c7400 29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Pokitto 7:72f87b7c7400 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
Pokitto 7:72f87b7c7400 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Pokitto 7:72f87b7c7400 32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Pokitto 7:72f87b7c7400 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Pokitto 7:72f87b7c7400 34 */
Pokitto 7:72f87b7c7400 35 /**************************************************************************/
Pokitto 7:72f87b7c7400 36
Pokitto 7:72f87b7c7400 37 #include "PokittoCore.h"
Pokitto 7:72f87b7c7400 38 #include "pinmap.h"
Pokitto 7:72f87b7c7400 39 #include "HWLCD.h"
Pokitto 7:72f87b7c7400 40 #include "loader.h"
Pokitto 7:72f87b7c7400 41
Pokitto 7:72f87b7c7400 42
Pokitto 7:72f87b7c7400 43 using namespace Pokitto;
Pokitto 7:72f87b7c7400 44
Pokitto 7:72f87b7c7400 45
Pokitto 7:72f87b7c7400 46 void Core::quit() {
Pokitto 7:72f87b7c7400 47 run_state = false;
Pokitto 7:72f87b7c7400 48 }
Pokitto 7:72f87b7c7400 49
Pokitto 7:72f87b7c7400 50 void Core::initRandom() {
Pokitto 7:72f87b7c7400 51 //TODO: hook random seed to battery level
Pokitto 7:72f87b7c7400 52 }
Pokitto 7:72f87b7c7400 53
Pokitto 7:72f87b7c7400 54 void Core::initGPIO() {
Pokitto 7:72f87b7c7400 55 /** control lines **/
Pokitto 7:72f87b7c7400 56 LPC_GPIO_PORT->DIR[LCD_CD_PORT] |= (1 << LCD_CD_PIN );
Pokitto 7:72f87b7c7400 57 LPC_GPIO_PORT->DIR[LCD_WR_PORT] |= (1 << LCD_WR_PIN );
Pokitto 7:72f87b7c7400 58 LPC_GPIO_PORT->DIR[LCD_RD_PORT] |= (1 << LCD_RD_PIN );
Pokitto 7:72f87b7c7400 59 LPC_GPIO_PORT->DIR[LCD_RES_PORT] |= (1 << LCD_RES_PIN );
Pokitto 7:72f87b7c7400 60 /** data lines **/
Pokitto 7:72f87b7c7400 61 LPC_GPIO_PORT->DIR[2] |= (0xFFFF << 3); // P2_3...P2_18 as output
Pokitto 7:72f87b7c7400 62
Pokitto 7:72f87b7c7400 63 pin_mode(P2_3,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 64 pin_mode(P2_4,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 65 pin_mode(P2_5,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 66 pin_mode(P2_6,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 67
Pokitto 7:72f87b7c7400 68 pin_mode(P2_7,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 69 pin_mode(P2_8,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 70 pin_mode(P2_9,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 71 pin_mode(P2_10,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 72
Pokitto 7:72f87b7c7400 73 pin_mode(P2_11,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 74 pin_mode(P2_12,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 75 pin_mode(P2_13,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 76 pin_mode(P2_14,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 77
Pokitto 7:72f87b7c7400 78 pin_mode(P2_15,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 79 pin_mode(P2_16,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 80 pin_mode(P2_17,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 81 pin_mode(P2_18,PullNone); // turn off pull-up
Pokitto 7:72f87b7c7400 82 }
Pokitto 7:72f87b7c7400 83
Pokitto 7:72f87b7c7400 84
Pokitto 7:72f87b7c7400 85
Pokitto 7:72f87b7c7400 86
Pokitto 7:72f87b7c7400 87