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
- Import this library to online compiler (see button "import" on the right hand side
- DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
- Change My_settings.h according to your project
- Start coding!
POKITTO_HW/HWButtons.h@39:e8bb18900c34, 2018-04-22 (annotated)
- Committer:
- Pokitto
- Date:
- Sun Apr 22 23:55:36 2018 +0000
- Revision:
- 39:e8bb18900c34
Button handling and initRandom fixed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pokitto | 39:e8bb18900c34 | 1 | /**************************************************************************/ |
Pokitto | 39:e8bb18900c34 | 2 | /*! |
Pokitto | 39:e8bb18900c34 | 3 | @file HWButtons.h |
Pokitto | 39:e8bb18900c34 | 4 | @author Jonne Valola |
Pokitto | 39:e8bb18900c34 | 5 | |
Pokitto | 39:e8bb18900c34 | 6 | @section LICENSE |
Pokitto | 39:e8bb18900c34 | 7 | |
Pokitto | 39:e8bb18900c34 | 8 | Software License Agreement (BSD License) |
Pokitto | 39:e8bb18900c34 | 9 | |
Pokitto | 39:e8bb18900c34 | 10 | Copyright (c) 2016, Jonne Valola |
Pokitto | 39:e8bb18900c34 | 11 | All rights reserved. |
Pokitto | 39:e8bb18900c34 | 12 | |
Pokitto | 39:e8bb18900c34 | 13 | Redistribution and use in source and binary forms, with or without |
Pokitto | 39:e8bb18900c34 | 14 | modification, are permitted provided that the following conditions are met: |
Pokitto | 39:e8bb18900c34 | 15 | 1. Redistributions of source code must retain the above copyright |
Pokitto | 39:e8bb18900c34 | 16 | notice, this list of conditions and the following disclaimer. |
Pokitto | 39:e8bb18900c34 | 17 | 2. Redistributions in binary form must reproduce the above copyright |
Pokitto | 39:e8bb18900c34 | 18 | notice, this list of conditions and the following disclaimer in the |
Pokitto | 39:e8bb18900c34 | 19 | documentation and/or other materials provided with the distribution. |
Pokitto | 39:e8bb18900c34 | 20 | 3. Neither the name of the copyright holders nor the |
Pokitto | 39:e8bb18900c34 | 21 | names of its contributors may be used to endorse or promote products |
Pokitto | 39:e8bb18900c34 | 22 | derived from this software without specific prior written permission. |
Pokitto | 39:e8bb18900c34 | 23 | |
Pokitto | 39:e8bb18900c34 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY |
Pokitto | 39:e8bb18900c34 | 25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Pokitto | 39:e8bb18900c34 | 26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Pokitto | 39:e8bb18900c34 | 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY |
Pokitto | 39:e8bb18900c34 | 28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Pokitto | 39:e8bb18900c34 | 29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Pokitto | 39:e8bb18900c34 | 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
Pokitto | 39:e8bb18900c34 | 31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Pokitto | 39:e8bb18900c34 | 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Pokitto | 39:e8bb18900c34 | 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Pokitto | 39:e8bb18900c34 | 34 | */ |
Pokitto | 39:e8bb18900c34 | 35 | /**************************************************************************/ |
Pokitto | 39:e8bb18900c34 | 36 | #ifndef HWBUTTONS_H |
Pokitto | 39:e8bb18900c34 | 37 | #define HWBUTTONS_H |
Pokitto | 39:e8bb18900c34 | 38 | |
Pokitto | 39:e8bb18900c34 | 39 | #include "mbed.h" |
Pokitto | 39:e8bb18900c34 | 40 | #include "Pokitto_settings.h" |
Pokitto | 39:e8bb18900c34 | 41 | |
Pokitto | 39:e8bb18900c34 | 42 | #define BTN_UP 1 |
Pokitto | 39:e8bb18900c34 | 43 | #define BTN_RIGHT 2 |
Pokitto | 39:e8bb18900c34 | 44 | #define BTN_DOWN 3 |
Pokitto | 39:e8bb18900c34 | 45 | #define BTN_LEFT 0 |
Pokitto | 39:e8bb18900c34 | 46 | #define BTN_A 4 |
Pokitto | 39:e8bb18900c34 | 47 | #define BTN_B 5 |
Pokitto | 39:e8bb18900c34 | 48 | #define BTN_C 6 |
Pokitto | 39:e8bb18900c34 | 49 | #define NUM_BTN 7 |
Pokitto | 39:e8bb18900c34 | 50 | |
Pokitto | 39:e8bb18900c34 | 51 | typedef struct { /*!< PIN_INT Structure */ |
Pokitto | 39:e8bb18900c34 | 52 | __IO uint32_t ISEL; /*!< Pin Interrupt Mode register */ |
Pokitto | 39:e8bb18900c34 | 53 | __IO uint32_t IENR; /*!< Pin Interrupt Enable (Rising) register */ |
Pokitto | 39:e8bb18900c34 | 54 | __IO uint32_t SIENR; /*!< Set Pin Interrupt Enable (Rising) register */ |
Pokitto | 39:e8bb18900c34 | 55 | __IO uint32_t CIENR; /*!< Clear Pin Interrupt Enable (Rising) register */ |
Pokitto | 39:e8bb18900c34 | 56 | __IO uint32_t IENF; /*!< Pin Interrupt Enable Falling Edge / Active Level register */ |
Pokitto | 39:e8bb18900c34 | 57 | __IO uint32_t SIENF; /*!< Set Pin Interrupt Enable Falling Edge / Active Level register */ |
Pokitto | 39:e8bb18900c34 | 58 | __IO uint32_t CIENF; /*!< Clear Pin Interrupt Enable Falling Edge / Active Level address */ |
Pokitto | 39:e8bb18900c34 | 59 | __IO uint32_t RISE; /*!< Pin Interrupt Rising Edge register */ |
Pokitto | 39:e8bb18900c34 | 60 | __IO uint32_t FALL; /*!< Pin Interrupt Falling Edge register */ |
Pokitto | 39:e8bb18900c34 | 61 | __IO uint32_t IST; /*!< Pin Interrupt Status register */ |
Pokitto | 39:e8bb18900c34 | 62 | __IO uint32_t PMCTRL; /*!< GPIO pattern match interrupt control register */ |
Pokitto | 39:e8bb18900c34 | 63 | __IO uint32_t PMSRC; /*!< GPIO pattern match interrupt bit-slice source register */ |
Pokitto | 39:e8bb18900c34 | 64 | __IO uint32_t PMCFG; /*!< GPIO pattern match interrupt bit slice configuration register */ |
Pokitto | 39:e8bb18900c34 | 65 | } LPC_PIN_INT_T; |
Pokitto | 39:e8bb18900c34 | 66 | |
Pokitto | 39:e8bb18900c34 | 67 | #define LPC_PININT 0xA0004000 |
Pokitto | 39:e8bb18900c34 | 68 | #define PININTCH(ch) (1 << (ch)) |
Pokitto | 39:e8bb18900c34 | 69 | |
Pokitto | 39:e8bb18900c34 | 70 | namespace Pokitto { |
Pokitto | 39:e8bb18900c34 | 71 | |
Pokitto | 39:e8bb18900c34 | 72 | extern uint8_t heldStates[]; |
Pokitto | 39:e8bb18900c34 | 73 | extern void initButtons(); |
Pokitto | 39:e8bb18900c34 | 74 | extern void pollButtons(); |
Pokitto | 39:e8bb18900c34 | 75 | |
Pokitto | 39:e8bb18900c34 | 76 | |
Pokitto | 39:e8bb18900c34 | 77 | } // namespace Pokitto |
Pokitto | 39:e8bb18900c34 | 78 | |
Pokitto | 39:e8bb18900c34 | 79 | #endif //HWBUTTONS |
Pokitto | 39:e8bb18900c34 | 80 | |
Pokitto | 39:e8bb18900c34 | 81 |