diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2007-10-06 14:47:50 +0000 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2007-10-06 14:47:50 +0000 |
commit | 5f3976696ddf5d02ea7e6f805ce655e1f281e6ed (patch) | |
tree | 547c97780b4a79c5fac43ebcd017ddfb9b73971c /cores/arduino/pins_arduino.h | |
parent | 72e9f39fbde96b484338cbbd785680e5ab4a2e72 (diff) |
Moving hardware/targets to hardware/cores.
Diffstat (limited to 'cores/arduino/pins_arduino.h')
-rw-r--r-- | cores/arduino/pins_arduino.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/cores/arduino/pins_arduino.h b/cores/arduino/pins_arduino.h new file mode 100644 index 0000000..e0b7add --- /dev/null +++ b/cores/arduino/pins_arduino.h @@ -0,0 +1,65 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include <avr/pgmspace.h> + +#define NOT_A_PIN 0 +#define NOT_A_PORT 0 + +#define NOT_ON_TIMER 0 +#define TIMER0A 1 +#define TIMER0B 2 +#define TIMER1A 3 +#define TIMER1B 4 +#define TIMER2 5 +#define TIMER2A 6 +#define TIMER2B 7 + +extern const uint8_t PROGMEM port_to_mode_PGM[]; +extern const uint8_t PROGMEM port_to_input_PGM[]; +extern const uint8_t PROGMEM port_to_output_PGM[]; + +extern const uint8_t PROGMEM digital_pin_to_port_PGM[]; +extern const uint8_t PROGMEM digital_pin_to_bit_PGM[]; +extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[]; + +extern const uint8_t PROGMEM digital_pin_to_timer_PGM[]; + +// Get the bit location within the hardware port of the given virtual pin. +// This comes from the pins_*.c file for the active board configuration. +// +// These perform slightly better as macros compared to inline functions +// +#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) ) +#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) ) +#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) ) +#define analogInPinToBit(P) (P) +#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_output_PGM + (P))) ) +#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_input_PGM + (P))) ) +#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_mode_PGM + (P))) ) + +#endif |