KRITSADA

pins_arduino.h in hardware\arduino\avr\variants for UNO R3B

Jul 29th, 2016
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.99 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.  
  7.   This library is free software; you can redistribute it and/or
  8.   modify it under the terms of the GNU Lesser General Public
  9.   License as published by the Free Software Foundation; either
  10.   version 2.1 of the License, or (at your option) any later version.
  11.  
  12.   This library is distributed in the hope that it will be useful,
  13.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.   Lesser General Public License for more details.
  16.  
  17.   You should have received a copy of the GNU Lesser General
  18.   Public License along with this library; if not, write to the
  19.   Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  20.   Boston, MA  02111-1307  USA
  21. */
  22.  
  23. #ifndef Pins_Arduino_h
  24. #define Pins_Arduino_h
  25.  
  26. #include <avr/pgmspace.h>
  27.  
  28. #define NUM_DIGITAL_PINS           24
  29. #define NUM_ANALOG_INPUTS          8
  30. #define analogInputToDigitalPin(p) ((p < 8) ? (p) + 14 : -1)
  31.  
  32. #define digitalPinHasPWM(p)        ((p) == 0 || (p) == 1 || (p) == 2 || (p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11)
  33.  
  34. static const uint8_t SS   = 10;
  35. static const uint8_t MOSI = 11;
  36. static const uint8_t MISO = 12;
  37. static const uint8_t SCK  = 13;
  38.  
  39. static const uint8_t SDA = 18;
  40. static const uint8_t SCL = 19;
  41.  
  42. static const uint8_t SS1   = 20;
  43. static const uint8_t MOSI1 = 21;
  44. static const uint8_t MISO1 = 14;
  45. static const uint8_t SCK1  = 15;
  46.  
  47. static const uint8_t SDA1 = 22;
  48. static const uint8_t SCL1 = 23;
  49.  
  50. #define LED_BUILTIN 13
  51.  
  52. static const uint8_t A0 = 14;
  53. static const uint8_t A1 = 15;
  54. static const uint8_t A2 = 16;
  55. static const uint8_t A3 = 17;
  56. static const uint8_t A4 = 18;
  57. static const uint8_t A5 = 19;
  58. static const uint8_t A6 = 20;
  59. static const uint8_t A7 = 21;
  60.  
  61. #define digitalPinToPCICR(p)    (((p) >= 0 && (p) <= 23) ? (&PCICR) : ((uint8_t *)0))
  62. #define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1))
  63. #define digitalPinToPCMSK(p)    (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 23) ? (&PCMSK1) : ((uint8_t *)0))))
  64. #define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14)))
  65.  
  66. #define digitalPinToInterrupt(p)  ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
  67.  
  68. #ifdef ARDUINO_MAIN
  69.  
  70. // these arrays map port names (e.g. port B) to the
  71. // appropriate addresses for various functions (e.g. reading
  72. // and writing)
  73. const uint16_t PROGMEM port_to_mode_PGM[] = {
  74.     NOT_A_PORT,
  75.     NOT_A_PORT,
  76.     (uint16_t) &DDRB,
  77.     (uint16_t) &DDRC,
  78.     (uint16_t) &DDRD,
  79.     (uint16_t) &DDRE,
  80. };
  81.  
  82. const uint16_t PROGMEM port_to_output_PGM[] = {
  83.     NOT_A_PORT,
  84.     NOT_A_PORT,
  85.     (uint16_t) &PORTB,
  86.     (uint16_t) &PORTC,
  87.     (uint16_t) &PORTD,
  88.     (uint16_t) &PORTE,
  89. };
  90.  
  91. const uint16_t PROGMEM port_to_input_PGM[] = {
  92.     NOT_A_PORT,
  93.     NOT_A_PORT,
  94.     (uint16_t) &PINB,
  95.     (uint16_t) &PINC,
  96.     (uint16_t) &PIND,
  97.     (uint16_t) &PINE,
  98. };
  99.  
  100. const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
  101.     PD, /* 0 */
  102.     PD,
  103.     PD,
  104.     PD,
  105.     PD,
  106.     PD,
  107.     PD,
  108.     PD,
  109.     PB, /* 8 */
  110.     PB,
  111.     PB,
  112.     PB,
  113.     PB,
  114.     PB,
  115.     PC, /* 14 */
  116.     PC,
  117.     PC,
  118.     PC,
  119.     PC,
  120.     PC,
  121.     PE, /* 20 */
  122.     PE,
  123.     PE,
  124.     PE,
  125. };
  126.  
  127. const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
  128.     _BV(0), /* 0, port D */
  129.     _BV(1),
  130.     _BV(2),
  131.     _BV(3),
  132.     _BV(4),
  133.     _BV(5),
  134.     _BV(6),
  135.     _BV(7),
  136.     _BV(0), /* 8, port B */
  137.     _BV(1),
  138.     _BV(2),
  139.     _BV(3),
  140.     _BV(4),
  141.     _BV(5),
  142.     _BV(0), /* 14, port C */
  143.     _BV(1),
  144.     _BV(2),
  145.     _BV(3),
  146.     _BV(4),
  147.     _BV(5),
  148.     _BV(2), /* 20, port E */
  149.     _BV(3),
  150.     _BV(0),
  151.     _BV(1),
  152. };
  153.  
  154. const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
  155.     TIMER3A, /* 0 - port D */
  156.     TIMER4A,
  157.     TIMER3B, //TIMER4B
  158. //  TIMER4B,
  159.     TIMER2B,
  160.     NOT_ON_TIMER,
  161.     TIMER0B,
  162.     TIMER0A,
  163.     NOT_ON_TIMER,
  164.     NOT_ON_TIMER, /* 8 - port B */
  165.     TIMER1A,
  166.     TIMER1B,
  167.     TIMER2A,
  168.     NOT_ON_TIMER,
  169.     NOT_ON_TIMER,
  170.     NOT_ON_TIMER,
  171.     NOT_ON_TIMER, /* 14 - port C */
  172.     NOT_ON_TIMER,
  173.     NOT_ON_TIMER,
  174.     NOT_ON_TIMER,
  175.     NOT_ON_TIMER,
  176.     NOT_ON_TIMER, /* 20 - port E */
  177.     NOT_ON_TIMER,
  178.     NOT_ON_TIMER,
  179.     NOT_ON_TIMER,
  180. };
  181.  
  182. #endif
  183.  
  184. // These serial port names are intended to allow libraries and architecture-neutral
  185. // sketches to automatically default to the correct port name for a particular type
  186. // of use.  For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
  187. // the first hardware serial port whose RX/TX pins are not dedicated to another use.
  188. //
  189. // SERIAL_PORT_MONITOR        Port which normally prints to the Arduino Serial Monitor
  190. //
  191. // SERIAL_PORT_USBVIRTUAL     Port which is USB virtual serial
  192. //
  193. // SERIAL_PORT_LINUXBRIDGE    Port which connects to a Linux system via Bridge library
  194. //
  195. // SERIAL_PORT_HARDWARE       Hardware serial port, physical RX & TX pins.
  196. //
  197. // SERIAL_PORT_HARDWARE_OPEN  Hardware serial ports which are open for use.  Their RX & TX
  198. //                            pins are NOT connected to anything by default.
  199. #define SERIAL_PORT_MONITOR   Serial
  200. #define SERIAL_PORT_HARDWARE  Serial
  201.  
  202. #endif
Advertisement
Add Comment
Please, Sign In to add comment