Advertisement
Boelle

Untitled

Dec 16th, 2014
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.69 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. $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
  23.  
  24. Changelog
  25. -----------
  26. 11/25/11 - ryan@ryanmsutton.com - Add pins for Sanguino 644P and 1284P
  27. 07/15/12 - ryan@ryanmsutton.com - Updated for arduino0101
  28.  
  29. Improvements by Kristian Lauszus, kristianl@tkjelectronics.dk
  30. */
  31.  
  32. #ifndef Pins_Arduino_h
  33. #define Pins_Arduino_h
  34.  
  35. #include <avr/pgmspace.h>
  36.  
  37. const static uint8_t SS = 4;
  38. const static uint8_t MOSI = 5;
  39. const static uint8_t MISO = 6;
  40. const static uint8_t SCK = 7;
  41.  
  42. static const uint8_t SDA = 17;
  43. static const uint8_t SCL = 16;
  44.  
  45. #define LED_BUILTIN 0
  46.  
  47. static const uint8_t A0 = 31;
  48. static const uint8_t A1 = 30;
  49. static const uint8_t A2 = 29;
  50. static const uint8_t A3 = 28;
  51. static const uint8_t A4 = 27;
  52. static const uint8_t A5 = 26;
  53. static const uint8_t A6 = 25;
  54. static const uint8_t A7 = 24;
  55.  
  56. // ATMEL ATMEGA644/ATMEGA1284 / SANGUINO
  57. //
  58. // +---\/---+
  59. // (D 0) PB0 1| |40 PA0 (AI 0 / D31)
  60. // (D 1) PB1 2| |39 PA1 (AI 1 / D30)
  61. // INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29)
  62. // PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28)
  63. // SS PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27)
  64. // MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26)
  65. // MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25)
  66. // SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24)
  67. // RST 9| |32 AREF
  68. // VCC 10| |31 GND
  69. // GND 11| |30 AVCC
  70. // XTAL2 12| |29 PC7 (D 23)
  71. // XTAL1 13| |28 PC6 (D 22)
  72. // RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
  73. // TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
  74. // INT0 RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS
  75. // INT1 TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK
  76. // PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
  77. // PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
  78. // PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
  79. // +--------+
  80. //
  81. #define NUM_DIGITAL_PINS 24
  82. #define NUM_ANALOG_INPUTS 8
  83.  
  84. #define analogInputToDigitalPin(p) ((p < 8) ? 31 - (p): -1)
  85. #define analogPinToChannel(p) ((p < 8) ? (p) : 31 - (p))
  86.  
  87. #define digitalPinHasPWM(p) ((p) == 3 || (p) == 4 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15 )
  88.  
  89. #define digitalPinToPCICR(p) ( (((p) >= 0) && ((p) <= 31)) ? (&PCICR) : ((uint8_t *)0) )
  90.  
  91. #define digitalPinToPCICRbit(p) ( (((p) >= 24) && ((p) <= 31)) ? 0 : \
  92. ( (((p) >= 0) && ((p) <= 7)) ? 1 : \
  93. ( (((p) >= 16) && ((p) <= 23)) ? 2 : \
  94. ( (((p) >= 8) && ((p) <= 15)) ? 3 : \
  95. 0 ) ) ) )
  96.  
  97. #define digitalPinToPCMSK(p) ( (((p) >= 24) && ((p) <= 31)) ? (&PCMSK0) : \
  98. ( (((p) >= 0) && ((p) <= 7)) ? (&PCMSK1) : \
  99. ( (((p) >= 16) && ((p) <= 23)) ? (&PCMSK2) : \
  100. ( (((p) >= 8) && ((p) <= 15)) ? (&PCMSK3) : \
  101. ((uint8_t *)0) ) ) ) )
  102.  
  103.  
  104. #define digitalPinToPCMSKbit(p) ( (((p) >= 24) && ((p) <= 31)) ? (31 - (p)) : \
  105. ( (((p) >= 0) && ((p) <= 7)) ? (p) : \
  106. ( (((p) >= 16) && ((p) <= 23)) ? ((p) - 16) : \
  107. ( (((p) >= 8) && ((p) <= 15)) ? ((p) - 8) : \
  108. 0 ) ) ) )
  109.  
  110. #define digitalPinToInterrupt(p) ((p) == 10 ? 0 : ((p) == 11 ? 1 : ((p) == 2 ? 2 : NOT_AN_INTERRUPT)))
  111.  
  112. #ifdef ARDUINO_MAIN
  113. // these arrays map port names (e.g. port B) to the
  114. // appropriate addresses for various functions (e.g. reading
  115. // and writing)
  116. const uint16_t PROGMEM port_to_mode_PGM[] =
  117. {
  118. NOT_A_PORT,
  119. (uint16_t) &DDRA,
  120. (uint16_t) &DDRB,
  121. (uint16_t) &DDRC,
  122. (uint16_t) &DDRD,
  123. };
  124.  
  125. const uint16_t PROGMEM port_to_output_PGM[] =
  126. {
  127. NOT_A_PORT,
  128. (uint16_t) &PORTA,
  129. (uint16_t) &PORTB,
  130. (uint16_t) &PORTC,
  131. (uint16_t) &PORTD,
  132. };
  133. const uint16_t PROGMEM port_to_input_PGM[] =
  134. {
  135. NOT_A_PORT,
  136. (uint16_t) &PINA,
  137. (uint16_t) &PINB,
  138. (uint16_t) &PINC,
  139. (uint16_t) &PIND,
  140. };
  141. const uint8_t PROGMEM digital_pin_to_port_PGM[] =
  142. {
  143. PB, /* 0 */
  144. PB,
  145. PB,
  146. PB,
  147. PB,
  148. PB,
  149. PB,
  150. PB,
  151. PD, /* 8 */
  152. PD,
  153. PD,
  154. PD,
  155. PD,
  156. PD,
  157. PD,
  158. PD,
  159. PC, /* 16 */
  160. PC,
  161. PC,
  162. PC,
  163. PC,
  164. PC,
  165. PC,
  166. PC,
  167. PA, /* 24 */
  168. PA,
  169. PA,
  170. PA,
  171. PA,
  172. PA,
  173. PA,
  174. PA /* 31 */
  175. };
  176. const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
  177. {
  178. _BV(0), /* 0, port B */
  179. _BV(1),
  180. _BV(2),
  181. _BV(3),
  182. _BV(4),
  183. _BV(5),
  184. _BV(6),
  185. _BV(7),
  186. _BV(0), /* 8, port D */
  187. _BV(1),
  188. _BV(2),
  189. _BV(3),
  190. _BV(4),
  191. _BV(5),
  192. _BV(6),
  193. _BV(7),
  194. _BV(0), /* 16, port C */
  195. _BV(1),
  196. _BV(2),
  197. _BV(3),
  198. _BV(4),
  199. _BV(5),
  200. _BV(6),
  201. _BV(7),
  202. _BV(7), /* 24, port A */
  203. _BV(6),
  204. _BV(5),
  205. _BV(4),
  206. _BV(3),
  207. _BV(2),
  208. _BV(1),
  209. _BV(0)
  210. };
  211. const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
  212. {
  213. NOT_ON_TIMER, /* 0 - PB0 */
  214. NOT_ON_TIMER, /* 1 - PB1 */
  215. NOT_ON_TIMER, /* 2 - PB2 */
  216. TIMER0A, /* 3 - PB3 */
  217. TIMER0B, /* 4 - PB4 */
  218. NOT_ON_TIMER, /* 5 - PB5 */
  219. NOT_ON_TIMER, /* 6 - PB6 */
  220. NOT_ON_TIMER, /* 7 - PB7 */
  221. NOT_ON_TIMER, /* 8 - PD0 */
  222. NOT_ON_TIMER, /* 9 - PD1 */
  223. NOT_ON_TIMER, /* 10 - PD2 */
  224. NOT_ON_TIMER, /* 11 - PD3 */
  225. TIMER1B, /* 12 - PD4 */
  226. TIMER1A, /* 13 - PD5 */
  227. TIMER2B, /* 14 - PD6 */
  228. TIMER2A, /* 15 - PD7 */
  229. NOT_ON_TIMER, /* 16 - PC0 */
  230. NOT_ON_TIMER, /* 17 - PC1 */
  231. NOT_ON_TIMER, /* 18 - PC2 */
  232. NOT_ON_TIMER, /* 19 - PC3 */
  233. NOT_ON_TIMER, /* 20 - PC4 */
  234. NOT_ON_TIMER, /* 21 - PC5 */
  235. NOT_ON_TIMER, /* 22 - PC6 */
  236. NOT_ON_TIMER, /* 23 - PC7 */
  237. NOT_ON_TIMER, /* 24 - PA0 */
  238. NOT_ON_TIMER, /* 25 - PA1 */
  239. NOT_ON_TIMER, /* 26 - PA2 */
  240. NOT_ON_TIMER, /* 27 - PA3 */
  241. NOT_ON_TIMER, /* 28 - PA4 */
  242. NOT_ON_TIMER, /* 29 - PA5 */
  243. NOT_ON_TIMER, /* 30 - PA6 */
  244. NOT_ON_TIMER /* 31 - PA7 */
  245. };
  246. #endif
  247.  
  248. // These serial port names are intended to allow libraries and architecture-neutral
  249. // sketches to automatically default to the correct port name for a particular type
  250. // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
  251. // the first hardware serial port whose RX/TX pins are not dedicated to another use.
  252. //
  253. // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
  254. //
  255. // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
  256. //
  257. // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
  258. //
  259. // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
  260. //
  261. // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
  262. // pins are NOT connected to anything by default.
  263.  
  264. #define SERIAL_PORT_MONITOR Serial
  265. #define SERIAL_PORT_HARDWARE Serial
  266. #define SERIAL_PORT_HARDWARE1 Serial1
  267. #define SERIAL_PORT_HARDWARE_OPEN Serial1
  268.  
  269. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement