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

Dependents:   Sensitive

Fork of PokittoLib by Jonne Valola

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pins_arduino.h Source File

pins_arduino.h

00001 /*
00002   pins_arduino.h - Pin definition functions for Arduino
00003   Part of Arduino - http://www.arduino.cc/
00004 
00005   Copyright (c) 2007 David A. Mellis
00006 
00007   This library is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Lesser General Public
00009   License as published by the Free Software Foundation; either
00010   version 2.1 of the License, or (at your option) any later version.
00011 
00012   This library is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   Lesser General Public License for more details.
00016 
00017   You should have received a copy of the GNU Lesser General
00018   Public License along with this library; if not, write to the
00019   Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00020   Boston, MA  02111-1307  USA
00021 
00022   $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
00023 */
00024 
00025 #ifndef Pins_Arduino_h
00026 #define Pins_Arduino_h
00027 
00028 #include "PokittoFakeavr.h "
00029 
00030 #define NUM_DIGITAL_PINS            20
00031 #define NUM_ANALOG_INPUTS           6
00032 #define analogInputToDigitalPin(p)  ((p < 6) ? (p) + 14 : -1)
00033 
00034 #if defined(__AVR_ATmega8__)
00035 #define digitalPinHasPWM(p)         ((p) == 9 || (p) == 10 || (p) == 11)
00036 #else
00037 #define digitalPinHasPWM(p)         ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11)
00038 #endif
00039 
00040 const static uint8_t SS   = 10;
00041 const static uint8_t MOSI = 11;
00042 const static uint8_t MISO = 12;
00043 const static uint8_t SCK  = 13;
00044 
00045 //const static uint8_t SDA = 18;
00046 //const static uint8_t SCL = 19;
00047 const static uint8_t LED_BUILTIN = 13;
00048 
00049 /*const static uint8_t A0 = 14;
00050 const static uint8_t A1 = 15;
00051 const static uint8_t A2 = 16;
00052 const static uint8_t A3 = 17;
00053 const static uint8_t A4 = 18;
00054 const static uint8_t A5 = 19;
00055 const static uint8_t A6 = 20;
00056 const static uint8_t A7 = 21;*/
00057 
00058 #define digitalPinToPCICR(p)    (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)0))
00059 #define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1))
00060 #define digitalPinToPCMSK(p)    (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))
00061 #define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14)))
00062 
00063 #ifdef ARDUINO_MAIN
00064 
00065 // On the Arduino board, digital pins are also used
00066 // for the analog output (software PWM).  Analog input
00067 // pins are a separate set.
00068 
00069 // ATMEL ATMEGA8 & 168 / ARDUINO
00070 //
00071 //                  +-\/-+
00072 //            PC6  1|    |28  PC5 (AI 5)
00073 //      (D 0) PD0  2|    |27  PC4 (AI 4)
00074 //      (D 1) PD1  3|    |26  PC3 (AI 3)
00075 //      (D 2) PD2  4|    |25  PC2 (AI 2)
00076 // PWM+ (D 3) PD3  5|    |24  PC1 (AI 1)
00077 //      (D 4) PD4  6|    |23  PC0 (AI 0)
00078 //            VCC  7|    |22  GND
00079 //            GND  8|    |21  AREF
00080 //            PB6  9|    |20  AVCC
00081 //            PB7 10|    |19  PB5 (D 13)
00082 // PWM+ (D 5) PD5 11|    |18  PB4 (D 12)
00083 // PWM+ (D 6) PD6 12|    |17  PB3 (D 11) PWM
00084 //      (D 7) PD7 13|    |16  PB2 (D 10) PWM
00085 //      (D 8) PB0 14|    |15  PB1 (D 9) PWM
00086 //                  +----+
00087 //
00088 // (PWM+ indicates the additional PWM pins on the ATmega168.)
00089 
00090 // ATMEL ATMEGA1280 / ARDUINO
00091 //
00092 // 0-7 PE0-PE7   works
00093 // 8-13 PB0-PB5  works
00094 // 14-21 PA0-PA7 works
00095 // 22-29 PH0-PH7 works
00096 // 30-35 PG5-PG0 works
00097 // 36-43 PC7-PC0 works
00098 // 44-51 PJ7-PJ0 works
00099 // 52-59 PL7-PL0 works
00100 // 60-67 PD7-PD0 works
00101 // A0-A7 PF0-PF7
00102 // A8-A15 PK0-PK7
00103 
00104 
00105 // these arrays map port names (e.g. port B) to the
00106 // appropriate addresses for various functions (e.g. reading
00107 // and writing)
00108 
00109 uint8_t NULL_DATA = 0;
00110 
00111 const uint8_t* PROGMEM port_to_mode_PGM[] = {
00112     &NULL_DATA,
00113     &NULL_DATA,
00114     &DDRB,
00115     &DDRC,
00116     &DDRD,
00117 };
00118 
00119 const uint8_t* PROGMEM port_to_output_PGM[] = {
00120     &NULL_DATA,
00121     &NULL_DATA,
00122     &PORTB,
00123     &PORTC,
00124     &PORTD,
00125 };
00126 
00127 const uint8_t* PROGMEM port_to_input_PGM[] = {
00128     &NULL_DATA,
00129     &NULL_DATA,
00130     &PINB,
00131     &PINC,
00132     &PIND,
00133 };
00134 
00135 
00136 const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
00137     PD, /* 0 */
00138     PD,
00139     PD,
00140     PD,
00141     PD,
00142     PD,
00143     PD,
00144     PD,
00145     PB, /* 8 */
00146     PB,
00147     PB,
00148     PB,
00149     PB,
00150     PB,
00151     PC, /* 14 */
00152     PC,
00153     PC,
00154     PC,
00155     PC,
00156     PC,
00157 };
00158 
00159 const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
00160     _BV(0), /* 0, port D */
00161     _BV(1),
00162     _BV(2),
00163     _BV(3),
00164     _BV(4),
00165     _BV(5),
00166     _BV(6),
00167     _BV(7),
00168     _BV(0), /* 8, port B */
00169     _BV(1),
00170     _BV(2),
00171     _BV(3),
00172     _BV(4),
00173     _BV(5),
00174     _BV(0), /* 14, port C */
00175     _BV(1),
00176     _BV(2),
00177     _BV(3),
00178     _BV(4),
00179     _BV(5),
00180 };
00181 
00182 const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
00183     NOT_ON_TIMER, /* 0 - port D */
00184     NOT_ON_TIMER,
00185     NOT_ON_TIMER,
00186     // on the ATmega168, digital pin 3 has hardware pwm
00187 #if defined(__AVR_ATmega8__)
00188     NOT_ON_TIMER,
00189 #else
00190     TIMER2B,
00191 #endif
00192     NOT_ON_TIMER,
00193     // on the ATmega168, digital pins 5 and 6 have hardware pwm
00194 #if defined(__AVR_ATmega8__)
00195     NOT_ON_TIMER,
00196     NOT_ON_TIMER,
00197 #else
00198     TIMER0B,
00199     TIMER0A,
00200 #endif
00201     NOT_ON_TIMER,
00202     NOT_ON_TIMER, /* 8 - port B */
00203     TIMER1A,
00204     TIMER1B,
00205 #if defined(__AVR_ATmega8__)
00206     TIMER2,
00207 #else
00208     TIMER2A,
00209 #endif
00210     NOT_ON_TIMER,
00211     NOT_ON_TIMER,
00212     NOT_ON_TIMER,
00213     NOT_ON_TIMER, /* 14 - port C */
00214     NOT_ON_TIMER,
00215     NOT_ON_TIMER,
00216     NOT_ON_TIMER,
00217     NOT_ON_TIMER,
00218 };
00219 
00220 #endif
00221 
00222 #endif