Advertisement
Guest User

Untitled

a guest
Apr 18th, 2020
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.81 KB | None | 0 0
  1. /*
  2.   pins_arduino.h - Pin definition functions for Arduino
  3.   Part of Arduino - http://www.arduino.cc/
  4.  
  5.   Copyright (c) 2007 David A. Mellis
  6.   Copyright 2015~2018 Spence Konde
  7.  
  8.   This library is free software; you can redistribute it and/or
  9.   modify it under the terms of the GNU Lesser General Public
  10.   License as published by the Free Software Foundation; either
  11.   version 2.1 of the License, or (at your option) any later version.
  12.  
  13.   This library is distributed in the hope that it will be useful,
  14.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.   Lesser General Public License for more details.
  17.  
  18.   You should have received a copy of the GNU Lesser General
  19.   Public License along with this library; if not, write to the
  20.   Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  21.   Boston, MA  02111-1307  USA
  22.  
  23.   $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
  24. */
  25.  
  26. #ifndef Pins_Arduino_h
  27. #define Pins_Arduino_h
  28.  
  29. #define ATTINYX4 1
  30. #define __AVR_ATtinyX4__
  31. #define USE_SOFTWARE_SPI 1
  32.  
  33. #include <avr/pgmspace.h>
  34.  
  35. #define NUM_DIGITAL_PINS            12
  36. #define NUM_ANALOG_INPUTS           8
  37.  
  38. #define analogInputToDigitalPin(p)  (p)
  39.  
  40. #define digitalPinHasPWM(p)         ((p) == 5 || (p) == 6 || (p) == 7 || (p) == 8)
  41.  
  42. //This part has a USI, not an SPI module. Accordingly, there is no MISO/MOSI in hardware. There's a DI and a DO. When the chip is used as master, DI is used as MISO, DO is MOSI; the defines here specify the pins for master mode, as SPI master is much more commonly used in Arduino-land than SPI slave, and these defines are required for compatibility. Be aware of this when using the USI SPI fucntionality (and also, be aware that the MISO and MOSI markings on the pinout diagram in the datasheet are for ISP programming, where the chip is a slave. The pinout diagram included with this core attempts to clarify this)
  43.  
  44. #define ADC_TEMPERATURE 34
  45.  
  46. #define SS   3
  47. #define MOSI 5
  48. #define MISO 6
  49. #define SCK  4
  50.  
  51.  
  52. #define USI_DDR_PORT DDRA
  53. #define USI_SCK_PORT DDRA
  54. #define USCK_DD_PIN DDA4
  55. #define DO_DD_PIN DDA5
  56. #define DI_DD_PIN DDA6
  57. #  define DDR_USI DDRA
  58. #  define PORT_USI PORTA
  59. #  define PIN_USI PINA
  60. #  define PORT_USI_SDA PORTA6
  61. #  define PORT_USI_SCL PORTA4
  62. #  define PIN_USI_SDA PINA6
  63. #  define PIN_USI_SCL PINA4
  64. #  define USI_START_VECTOR USI_START_vect
  65. #  define USI_OVERFLOW_VECTOR USI_OVF_vect
  66. #  define DDR_USI_CL DDR_USI
  67. #  define PORT_USI_CL PORT_USI
  68. #  define PIN_USI_CL PIN_USI
  69. #ifndef USI_START_COND_INT
  70. #  define USI_START_COND_INT USISIF
  71. #endif
  72.  
  73. static const uint8_t SDA = 6;
  74. static const uint8_t SCL = 4;
  75.  
  76. //Ax constants should not be used for digitalRead/digitalWrite/analogWrite functions, only analogRead().
  77. //#define ANALOG_PINS_ARE_ADC_NUMBERS 1
  78. static const uint8_t A0 = 0x80 | 0;
  79. static const uint8_t A1 = 0x80 | 1;
  80. static const uint8_t A2 = 0x80 | 2;
  81. static const uint8_t A3 = 0x80 | 3;
  82. static const uint8_t A4 = 0x80 | 4;
  83. static const uint8_t A5 = 0x80 | 5;
  84. static const uint8_t A6 = 0x80 | 6;
  85. static const uint8_t A7 = 0x80 | 7;
  86. #define PIN_A0  (0)
  87. #define PIN_A1  ( 1)
  88. #define PIN_A2  ( 2)
  89. #define PIN_A3  ( 3)
  90. #define PIN_A4  ( 4)
  91. #define PIN_A5  ( 5)
  92. #define PIN_A6  ( 6)
  93. #define PIN_A7  ( 7)
  94. #define PIN_B0  ( 10)
  95. #define PIN_B1  ( 9)
  96. #define PIN_B2  ( 8)
  97. #define PIN_B3  (11)  /* RESET */
  98. #define LED_BUILTIN (8)
  99.  
  100. //----------------------------------------------------------
  101. //----------------------------------------------------------
  102. //Core Configuration (used to be in core_build_options.h)
  103.  
  104. //If Software Serial communications doesn't work, run the TinyTuner sketch provided with the core to give you a calibrated OSCCAL value.
  105. //Change the value here with the tuned value. By default this option uses the default value which the compiler will optimise out.
  106. #define TUNED_OSCCAL_VALUE                        OSCCAL
  107. //e.g
  108. //#define TUNED_OSCCAL_VALUE                        0x57
  109.  
  110. //Choosing not to initialise saves power and flash. 1 = initialise.
  111. #define INITIALIZE_ANALOG_TO_DIGITAL_CONVERTER    1
  112. #define INITIALIZE_SECONDARY_TIMERS               1
  113. /*
  114.   The old standby ... millis on Timer 0.
  115. */
  116. #define TIMER_TO_USE_FOR_MILLIS                   0
  117.  
  118. /*
  119.   Where to put the software serial? (Arduino Digital pin numbers)
  120. */
  121. //WARNING, if using software, TX is on AIN0, RX is on AIN1. Comparator is favoured to use its interrupt for the RX pin.
  122. #define USE_SOFTWARE_SERIAL           1
  123. //Please define the port on which the analog comparator is found.
  124. #define ANALOG_COMP_DDR               DDRA
  125. #define ANALOG_COMP_PORT              PORTA
  126. #define ANALOG_COMP_PIN               PINA
  127. #define ANALOG_COMP_AIN0_BIT          3
  128. #define ANALOG_COMP_AIN1_BIT          1
  129.  
  130.  
  131. /*
  132.   Analog reference bit masks.
  133. */
  134. // VCC used as analog reference, disconnected from PA0 (AREF)
  135. #define DEFAULT (0)
  136. // External voltage reference at PA0 (AREF) pin, internal reference turned off
  137. #define EXTERNAL (1)
  138. // Internal 1.1V voltage reference
  139. #define INTERNAL (2)
  140. #define INTERNAL1V1 INTERNAL
  141.  
  142. //----------------------------------------------------------
  143. //----------------------------------------------------------
  144. //----------------------------------------------------------
  145. //----------------------------------------------------------
  146.  
  147.  
  148. // PCICR = Pin Change Interrupt Control Register
  149. #define digitalPinToPCICR(p)    (((p) >= 0 && (p) <= 11) ? (&GIMSK) : ((uint8_t *)NULL))
  150. #define digitalPinToPCICRbit(p) ( ((p) <= 7) ? PCIE0 : PCIE1 )
  151. #define digitalPinToPCMSK(p)    ( ((p) <= 7) ? (&PCMSK0) : (((p) <= 10) ? (&PCMSK1) : ((uint8_t *)NULL)) )
  152. #define digitalPinToPCMSKbit(p) ( ((p) <= 7) ? (p) : (10 - (p)) )
  153.  
  154. #define digitalPinToInterrupt(p)  ((p) == 8 ? 0 : NOT_AN_INTERRUPT)
  155. #ifdef ARDUINO_MAIN
  156. #warning "This is the CLOCKWISE pin mapping - make sure you're using the pinout diagram with the pins in clockwise order"
  157. // ATMEL ATTINY84 / ARDUINO
  158. //
  159. //                           +-\/-+
  160. //                     VCC  1|    |14  GND
  161. //            (D  10)  PB0  2|    |13  PA0  (D  0)        AREF
  162. //             (D  9)  PB1  3|    |12  PA1  (D  1)
  163. //             (D 11)  PB3  4|    |11  PA2  (D  2)
  164. //  PWM  INT0  (D  8)  PB2  5|    |10  PA3  (D  3)
  165. //  PWM        (D  7)  PA7  6|    |9   PA4  (D  4)
  166. //  PWM        (D  6)  PA6  7|    |8   PA5  (D  5)        PWM
  167. //                           +----+
  168. const uint16_t PROGMEM port_to_mode_PGM[] =
  169. {
  170.   NOT_A_PORT,
  171.   (uint16_t)&DDRA,
  172.   (uint16_t)&DDRB,
  173. };
  174.  
  175. const uint16_t PROGMEM port_to_output_PGM[] =
  176. {
  177.   NOT_A_PORT,
  178.   (uint16_t)&PORTA,
  179.   (uint16_t)&PORTB,
  180. };
  181.  
  182. const uint16_t PROGMEM port_to_input_PGM[] =
  183. {
  184.   NOT_A_PORT,
  185.   (uint16_t)&PINA,
  186.   (uint16_t)&PINB,
  187. };
  188.  
  189. const uint8_t PROGMEM digital_pin_to_port_PGM[] =
  190. {
  191.   PA, /* 0 */
  192.   PA,
  193.   PA,
  194.   PA,
  195.   PA,
  196.   PA,
  197.   PA,
  198.   PA,
  199.   PB, /* 8 */
  200.   PB,
  201.   PB,
  202.   PB, /* 11 */
  203. };
  204.  
  205.  
  206.  
  207. const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
  208. {
  209.   _BV(0), /* port A */
  210.   _BV(1),
  211.   _BV(2),
  212.   _BV(3),
  213.   _BV(4),
  214.   _BV(5),
  215.   _BV(6),
  216.   _BV(7),
  217.   _BV(2), /* port B */
  218.   _BV(1),
  219.   _BV(0),
  220.   _BV(3),
  221. };
  222.  
  223. const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
  224. {
  225.   NOT_ON_TIMER,
  226.   NOT_ON_TIMER,
  227.   NOT_ON_TIMER,
  228.   NOT_ON_TIMER,
  229.   NOT_ON_TIMER,
  230.   TIMER1B, /* OC1B */
  231.   TIMER1A, /* OC1A */
  232.   TIMER0B, /* OC0B */
  233.   TIMER0A, /* OC0A */
  234.   NOT_ON_TIMER,
  235.   NOT_ON_TIMER,
  236.   NOT_ON_TIMER,
  237. };
  238.  
  239. #endif
  240.  
  241. #endif
  242.  
  243.  
  244.  
  245.  
  246. //Old code, just here for temporary backup until I decide it is not needed.
  247. /*
  248. //WARNING, if using software, RX must be on a pin which has a Pin change interrupt <= 7 (e.g. PCINT6, or PCINT1, but not PCINT8)
  249. #define USE_SOFTWARE_SERIAL             1
  250. //These are set to match Optiboot pins.
  251. #define SOFTWARE_SERIAL_PORT            PORTA
  252. #define SOFTWARE_SERIAL_TX              9
  253. #define SOFTWARE_SERIAL_PIN             PINA
  254. #define SOFTWARE_SERIAL_RX              8*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement