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

Dependents:   Sensitive

Fork of PokittoLib by Jonne Valola

Committer:
Pokitto
Date:
Thu Oct 12 10:36:40 2017 +0000
Revision:
9:754a7af30890
Fake Arduino lib added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 9:754a7af30890 1 /*
Pokitto 9:754a7af30890 2 pins_arduino.h - Pin definition functions for Arduino
Pokitto 9:754a7af30890 3 Part of Arduino - http://www.arduino.cc/
Pokitto 9:754a7af30890 4
Pokitto 9:754a7af30890 5 Copyright (c) 2007 David A. Mellis
Pokitto 9:754a7af30890 6
Pokitto 9:754a7af30890 7 This library is free software; you can redistribute it and/or
Pokitto 9:754a7af30890 8 modify it under the terms of the GNU Lesser General Public
Pokitto 9:754a7af30890 9 License as published by the Free Software Foundation; either
Pokitto 9:754a7af30890 10 version 2.1 of the License, or (at your option) any later version.
Pokitto 9:754a7af30890 11
Pokitto 9:754a7af30890 12 This library is distributed in the hope that it will be useful,
Pokitto 9:754a7af30890 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
Pokitto 9:754a7af30890 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Pokitto 9:754a7af30890 15 Lesser General Public License for more details.
Pokitto 9:754a7af30890 16
Pokitto 9:754a7af30890 17 You should have received a copy of the GNU Lesser General
Pokitto 9:754a7af30890 18 Public License along with this library; if not, write to the
Pokitto 9:754a7af30890 19 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Pokitto 9:754a7af30890 20 Boston, MA 02111-1307 USA
Pokitto 9:754a7af30890 21
Pokitto 9:754a7af30890 22 $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
Pokitto 9:754a7af30890 23 */
Pokitto 9:754a7af30890 24
Pokitto 9:754a7af30890 25 #ifndef Pins_Arduino_h
Pokitto 9:754a7af30890 26 #define Pins_Arduino_h
Pokitto 9:754a7af30890 27
Pokitto 9:754a7af30890 28 #include "PokittoFakeavr.h"
Pokitto 9:754a7af30890 29
Pokitto 9:754a7af30890 30 #define NUM_DIGITAL_PINS 20
Pokitto 9:754a7af30890 31 #define NUM_ANALOG_INPUTS 6
Pokitto 9:754a7af30890 32 #define analogInputToDigitalPin(p) ((p < 6) ? (p) + 14 : -1)
Pokitto 9:754a7af30890 33
Pokitto 9:754a7af30890 34 #if defined(__AVR_ATmega8__)
Pokitto 9:754a7af30890 35 #define digitalPinHasPWM(p) ((p) == 9 || (p) == 10 || (p) == 11)
Pokitto 9:754a7af30890 36 #else
Pokitto 9:754a7af30890 37 #define digitalPinHasPWM(p) ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11)
Pokitto 9:754a7af30890 38 #endif
Pokitto 9:754a7af30890 39
Pokitto 9:754a7af30890 40 const static uint8_t SS = 10;
Pokitto 9:754a7af30890 41 const static uint8_t MOSI = 11;
Pokitto 9:754a7af30890 42 const static uint8_t MISO = 12;
Pokitto 9:754a7af30890 43 const static uint8_t SCK = 13;
Pokitto 9:754a7af30890 44
Pokitto 9:754a7af30890 45 //const static uint8_t SDA = 18;
Pokitto 9:754a7af30890 46 //const static uint8_t SCL = 19;
Pokitto 9:754a7af30890 47 const static uint8_t LED_BUILTIN = 13;
Pokitto 9:754a7af30890 48
Pokitto 9:754a7af30890 49 /*const static uint8_t A0 = 14;
Pokitto 9:754a7af30890 50 const static uint8_t A1 = 15;
Pokitto 9:754a7af30890 51 const static uint8_t A2 = 16;
Pokitto 9:754a7af30890 52 const static uint8_t A3 = 17;
Pokitto 9:754a7af30890 53 const static uint8_t A4 = 18;
Pokitto 9:754a7af30890 54 const static uint8_t A5 = 19;
Pokitto 9:754a7af30890 55 const static uint8_t A6 = 20;
Pokitto 9:754a7af30890 56 const static uint8_t A7 = 21;*/
Pokitto 9:754a7af30890 57
Pokitto 9:754a7af30890 58 #define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)0))
Pokitto 9:754a7af30890 59 #define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1))
Pokitto 9:754a7af30890 60 #define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))
Pokitto 9:754a7af30890 61 #define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14)))
Pokitto 9:754a7af30890 62
Pokitto 9:754a7af30890 63 #ifdef ARDUINO_MAIN
Pokitto 9:754a7af30890 64
Pokitto 9:754a7af30890 65 // On the Arduino board, digital pins are also used
Pokitto 9:754a7af30890 66 // for the analog output (software PWM). Analog input
Pokitto 9:754a7af30890 67 // pins are a separate set.
Pokitto 9:754a7af30890 68
Pokitto 9:754a7af30890 69 // ATMEL ATMEGA8 & 168 / ARDUINO
Pokitto 9:754a7af30890 70 //
Pokitto 9:754a7af30890 71 // +-\/-+
Pokitto 9:754a7af30890 72 // PC6 1| |28 PC5 (AI 5)
Pokitto 9:754a7af30890 73 // (D 0) PD0 2| |27 PC4 (AI 4)
Pokitto 9:754a7af30890 74 // (D 1) PD1 3| |26 PC3 (AI 3)
Pokitto 9:754a7af30890 75 // (D 2) PD2 4| |25 PC2 (AI 2)
Pokitto 9:754a7af30890 76 // PWM+ (D 3) PD3 5| |24 PC1 (AI 1)
Pokitto 9:754a7af30890 77 // (D 4) PD4 6| |23 PC0 (AI 0)
Pokitto 9:754a7af30890 78 // VCC 7| |22 GND
Pokitto 9:754a7af30890 79 // GND 8| |21 AREF
Pokitto 9:754a7af30890 80 // PB6 9| |20 AVCC
Pokitto 9:754a7af30890 81 // PB7 10| |19 PB5 (D 13)
Pokitto 9:754a7af30890 82 // PWM+ (D 5) PD5 11| |18 PB4 (D 12)
Pokitto 9:754a7af30890 83 // PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM
Pokitto 9:754a7af30890 84 // (D 7) PD7 13| |16 PB2 (D 10) PWM
Pokitto 9:754a7af30890 85 // (D 8) PB0 14| |15 PB1 (D 9) PWM
Pokitto 9:754a7af30890 86 // +----+
Pokitto 9:754a7af30890 87 //
Pokitto 9:754a7af30890 88 // (PWM+ indicates the additional PWM pins on the ATmega168.)
Pokitto 9:754a7af30890 89
Pokitto 9:754a7af30890 90 // ATMEL ATMEGA1280 / ARDUINO
Pokitto 9:754a7af30890 91 //
Pokitto 9:754a7af30890 92 // 0-7 PE0-PE7 works
Pokitto 9:754a7af30890 93 // 8-13 PB0-PB5 works
Pokitto 9:754a7af30890 94 // 14-21 PA0-PA7 works
Pokitto 9:754a7af30890 95 // 22-29 PH0-PH7 works
Pokitto 9:754a7af30890 96 // 30-35 PG5-PG0 works
Pokitto 9:754a7af30890 97 // 36-43 PC7-PC0 works
Pokitto 9:754a7af30890 98 // 44-51 PJ7-PJ0 works
Pokitto 9:754a7af30890 99 // 52-59 PL7-PL0 works
Pokitto 9:754a7af30890 100 // 60-67 PD7-PD0 works
Pokitto 9:754a7af30890 101 // A0-A7 PF0-PF7
Pokitto 9:754a7af30890 102 // A8-A15 PK0-PK7
Pokitto 9:754a7af30890 103
Pokitto 9:754a7af30890 104
Pokitto 9:754a7af30890 105 // these arrays map port names (e.g. port B) to the
Pokitto 9:754a7af30890 106 // appropriate addresses for various functions (e.g. reading
Pokitto 9:754a7af30890 107 // and writing)
Pokitto 9:754a7af30890 108
Pokitto 9:754a7af30890 109 uint8_t NULL_DATA = 0;
Pokitto 9:754a7af30890 110
Pokitto 9:754a7af30890 111 const uint8_t* PROGMEM port_to_mode_PGM[] = {
Pokitto 9:754a7af30890 112 &NULL_DATA,
Pokitto 9:754a7af30890 113 &NULL_DATA,
Pokitto 9:754a7af30890 114 &DDRB,
Pokitto 9:754a7af30890 115 &DDRC,
Pokitto 9:754a7af30890 116 &DDRD,
Pokitto 9:754a7af30890 117 };
Pokitto 9:754a7af30890 118
Pokitto 9:754a7af30890 119 const uint8_t* PROGMEM port_to_output_PGM[] = {
Pokitto 9:754a7af30890 120 &NULL_DATA,
Pokitto 9:754a7af30890 121 &NULL_DATA,
Pokitto 9:754a7af30890 122 &PORTB,
Pokitto 9:754a7af30890 123 &PORTC,
Pokitto 9:754a7af30890 124 &PORTD,
Pokitto 9:754a7af30890 125 };
Pokitto 9:754a7af30890 126
Pokitto 9:754a7af30890 127 const uint8_t* PROGMEM port_to_input_PGM[] = {
Pokitto 9:754a7af30890 128 &NULL_DATA,
Pokitto 9:754a7af30890 129 &NULL_DATA,
Pokitto 9:754a7af30890 130 &PINB,
Pokitto 9:754a7af30890 131 &PINC,
Pokitto 9:754a7af30890 132 &PIND,
Pokitto 9:754a7af30890 133 };
Pokitto 9:754a7af30890 134
Pokitto 9:754a7af30890 135
Pokitto 9:754a7af30890 136 const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
Pokitto 9:754a7af30890 137 PD, /* 0 */
Pokitto 9:754a7af30890 138 PD,
Pokitto 9:754a7af30890 139 PD,
Pokitto 9:754a7af30890 140 PD,
Pokitto 9:754a7af30890 141 PD,
Pokitto 9:754a7af30890 142 PD,
Pokitto 9:754a7af30890 143 PD,
Pokitto 9:754a7af30890 144 PD,
Pokitto 9:754a7af30890 145 PB, /* 8 */
Pokitto 9:754a7af30890 146 PB,
Pokitto 9:754a7af30890 147 PB,
Pokitto 9:754a7af30890 148 PB,
Pokitto 9:754a7af30890 149 PB,
Pokitto 9:754a7af30890 150 PB,
Pokitto 9:754a7af30890 151 PC, /* 14 */
Pokitto 9:754a7af30890 152 PC,
Pokitto 9:754a7af30890 153 PC,
Pokitto 9:754a7af30890 154 PC,
Pokitto 9:754a7af30890 155 PC,
Pokitto 9:754a7af30890 156 PC,
Pokitto 9:754a7af30890 157 };
Pokitto 9:754a7af30890 158
Pokitto 9:754a7af30890 159 const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
Pokitto 9:754a7af30890 160 _BV(0), /* 0, port D */
Pokitto 9:754a7af30890 161 _BV(1),
Pokitto 9:754a7af30890 162 _BV(2),
Pokitto 9:754a7af30890 163 _BV(3),
Pokitto 9:754a7af30890 164 _BV(4),
Pokitto 9:754a7af30890 165 _BV(5),
Pokitto 9:754a7af30890 166 _BV(6),
Pokitto 9:754a7af30890 167 _BV(7),
Pokitto 9:754a7af30890 168 _BV(0), /* 8, port B */
Pokitto 9:754a7af30890 169 _BV(1),
Pokitto 9:754a7af30890 170 _BV(2),
Pokitto 9:754a7af30890 171 _BV(3),
Pokitto 9:754a7af30890 172 _BV(4),
Pokitto 9:754a7af30890 173 _BV(5),
Pokitto 9:754a7af30890 174 _BV(0), /* 14, port C */
Pokitto 9:754a7af30890 175 _BV(1),
Pokitto 9:754a7af30890 176 _BV(2),
Pokitto 9:754a7af30890 177 _BV(3),
Pokitto 9:754a7af30890 178 _BV(4),
Pokitto 9:754a7af30890 179 _BV(5),
Pokitto 9:754a7af30890 180 };
Pokitto 9:754a7af30890 181
Pokitto 9:754a7af30890 182 const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
Pokitto 9:754a7af30890 183 NOT_ON_TIMER, /* 0 - port D */
Pokitto 9:754a7af30890 184 NOT_ON_TIMER,
Pokitto 9:754a7af30890 185 NOT_ON_TIMER,
Pokitto 9:754a7af30890 186 // on the ATmega168, digital pin 3 has hardware pwm
Pokitto 9:754a7af30890 187 #if defined(__AVR_ATmega8__)
Pokitto 9:754a7af30890 188 NOT_ON_TIMER,
Pokitto 9:754a7af30890 189 #else
Pokitto 9:754a7af30890 190 TIMER2B,
Pokitto 9:754a7af30890 191 #endif
Pokitto 9:754a7af30890 192 NOT_ON_TIMER,
Pokitto 9:754a7af30890 193 // on the ATmega168, digital pins 5 and 6 have hardware pwm
Pokitto 9:754a7af30890 194 #if defined(__AVR_ATmega8__)
Pokitto 9:754a7af30890 195 NOT_ON_TIMER,
Pokitto 9:754a7af30890 196 NOT_ON_TIMER,
Pokitto 9:754a7af30890 197 #else
Pokitto 9:754a7af30890 198 TIMER0B,
Pokitto 9:754a7af30890 199 TIMER0A,
Pokitto 9:754a7af30890 200 #endif
Pokitto 9:754a7af30890 201 NOT_ON_TIMER,
Pokitto 9:754a7af30890 202 NOT_ON_TIMER, /* 8 - port B */
Pokitto 9:754a7af30890 203 TIMER1A,
Pokitto 9:754a7af30890 204 TIMER1B,
Pokitto 9:754a7af30890 205 #if defined(__AVR_ATmega8__)
Pokitto 9:754a7af30890 206 TIMER2,
Pokitto 9:754a7af30890 207 #else
Pokitto 9:754a7af30890 208 TIMER2A,
Pokitto 9:754a7af30890 209 #endif
Pokitto 9:754a7af30890 210 NOT_ON_TIMER,
Pokitto 9:754a7af30890 211 NOT_ON_TIMER,
Pokitto 9:754a7af30890 212 NOT_ON_TIMER,
Pokitto 9:754a7af30890 213 NOT_ON_TIMER, /* 14 - port C */
Pokitto 9:754a7af30890 214 NOT_ON_TIMER,
Pokitto 9:754a7af30890 215 NOT_ON_TIMER,
Pokitto 9:754a7af30890 216 NOT_ON_TIMER,
Pokitto 9:754a7af30890 217 NOT_ON_TIMER,
Pokitto 9:754a7af30890 218 };
Pokitto 9:754a7af30890 219
Pokitto 9:754a7af30890 220 #endif
Pokitto 9:754a7af30890 221
Pokitto 9:754a7af30890 222 #endif