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:
Wed Dec 25 23:59:52 2019 +0000
Revision:
71:531419862202
Parent:
61:123aefc978a7
Changed Mode2 C++ refresh code (graphical errors)

Who changed what in which revision?

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