PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PokittoHW.cpp Source File

PokittoHW.cpp

Go to the documentation of this file.
00001 /**************************************************************************/
00002 /*!
00003     @file     PokittoHW.cpp
00004     @author   Jonne Valola
00005 
00006     @section LICENSE
00007 
00008     Software License Agreement (BSD License)
00009 
00010     Copyright (c) 2015, Jonne Valola
00011     All rights reserved.
00012 
00013     Redistribution and use in source and binary forms, with or without
00014     modification, are permitted provided that the following conditions are met:
00015     1. Redistributions of source code must retain the above copyright
00016     notice, this list of conditions and the following disclaimer.
00017     2. Redistributions in binary form must reproduce the above copyright
00018     notice, this list of conditions and the following disclaimer in the
00019     documentation and/or other materials provided with the distribution.
00020     3. Neither the name of the copyright holders nor the
00021     names of its contributors may be used to endorse or promote products
00022     derived from this software without specific prior written permission.
00023 
00024     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
00025     EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00026     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
00028     DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00031     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00033     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 */
00035 /**************************************************************************/
00036 
00037 #include "PokittoCore.h "
00038 #include "pinmap.h"
00039 #include "HWLCD.h "
00040 
00041 
00042 using namespace Pokitto;
00043 
00044 
00045 void Core::quit() {
00046     run_state = false;
00047 }
00048 
00049 void Core::initRandom() {
00050     time_t seconds = time(NULL);
00051     Pokitto::Battery::update();
00052     srand((unsigned int) (Pokitto::Battery::level + (seconds)));
00053     for (int i=0; i < rand()*100; i++) random(100);
00054 }
00055 
00056 void Core::initGPIO() {
00057     /** control lines **/
00058     LPC_GPIO_PORT->DIR[LCD_CD_PORT] |= (1  << LCD_CD_PIN );
00059     LPC_GPIO_PORT->DIR[LCD_WR_PORT] |= (1  << LCD_WR_PIN );
00060     LPC_GPIO_PORT->DIR[LCD_RD_PORT] |= (1  << LCD_RD_PIN );
00061     LPC_GPIO_PORT->DIR[LCD_RES_PORT] |= (1  << LCD_RES_PIN );
00062     /** data lines **/
00063     LPC_GPIO_PORT->DIR[2] |= (0xFFFF  << 3);  // P2_3...P2_18 as output
00064 
00065     pin_mode(P2_3,PullNone); // turn off pull-up
00066     pin_mode(P2_4,PullNone); // turn off pull-up
00067     pin_mode(P2_5,PullNone); // turn off pull-up
00068     pin_mode(P2_6,PullNone); // turn off pull-up
00069 
00070     pin_mode(P2_7,PullNone); // turn off pull-up
00071     pin_mode(P2_8,PullNone); // turn off pull-up
00072     pin_mode(P2_9,PullNone); // turn off pull-up
00073     pin_mode(P2_10,PullNone); // turn off pull-up
00074 
00075     pin_mode(P2_11,PullNone); // turn off pull-up
00076     pin_mode(P2_12,PullNone); // turn off pull-up
00077     pin_mode(P2_13,PullNone); // turn off pull-up
00078     pin_mode(P2_14,PullNone); // turn off pull-up
00079 
00080     pin_mode(P2_15,PullNone); // turn off pull-up
00081     pin_mode(P2_16,PullNone); // turn off pull-up
00082     pin_mode(P2_17,PullNone); // turn off pull-up
00083     pin_mode(P2_18,PullNone); // turn off pull-up
00084 }
00085 
00086 
00087 
00088 
00089 
00090