00001
00008 #ifndef _ARDUINO_H
00009 #define _ARDUINO_H
00010
00011 #include <avr/io.h>
00012
00013
00014
00015
00016
00017
00019 #define _READ(IO) (IO ## _RPORT & _BV(IO ## _PIN))
00020
00021 #define _WRITE(IO, v) do { \
00022 if (v) { IO ## _WPORT |= _BV(IO ## _PIN); }\
00023 else { IO ## _WPORT &= ~_BV(IO ## _PIN); };\
00024 } while (0)
00025
00026 #define _TOGGLE(IO) do { IO ## _RPORT = _BV(IO ## _PIN); } while (0)
00027
00029 #define _SET_INPUT(IO) do { IO ## _DDR &= ~_BV(IO ## _PIN); } while (0)
00030
00031 #define _SET_OUTPUT(IO) do { IO ## _DDR |= _BV(IO ## _PIN); } while (0)
00032
00034 #define _GET_INPUT(IO) ((IO ## _DDR & _BV(IO ## _PIN)) == 0)
00035
00036 #define _GET_OUTPUT(IO) ((IO ## _DDR & _BV(IO ## _PIN)) != 0)
00037
00038
00040 #define READ(IO) _READ(IO)
00041
00042 #define WRITE(IO, v) _WRITE(IO, v)
00043
00044 #define TOGGLE(IO) _TOGGLE(IO)
00045
00047 #define SET_INPUT(IO) _SET_INPUT(IO)
00048
00049 #define SET_OUTPUT(IO) _SET_OUTPUT(IO)
00050
00052 #define GET_INPUT(IO) _GET_INPUT(IO)
00053
00054 #define GET_OUTPUT(IO) _GET_OUTPUT(IO)
00055
00056
00057
00058
00059
00060
00061 #if defined (__AVR_ATmega168__) || defined (__AVR_ATmega328__) || \
00062 defined (__AVR_ATmega328P__)
00063 # include "arduino_168_328p.h"
00064 #endif
00065
00066 #if defined (__AVR_ATmega644__) || defined (__AVR_ATmega644P__) || \
00067 defined (__AVR_ATmega644PA__) || defined (__AVR_ATmega1284__) || \
00068 defined (__AVR_ATmega1284P__)
00069 # include "arduino_644.h"
00070 #endif
00071
00072 #if defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__)
00073 # include "arduino_1280.h"
00074 #endif
00075
00076 #if defined (__AVR_AT90USB1287__)
00077 # include "arduino_usb1287.h"
00078 #endif
00079
00080 #ifndef DIO0_PIN
00081 # error pins for this chip not defined in arduino.h! If you write an appropriate pin definition and have this firmware work on your chip, please tell us via the forum thread
00082 #endif
00083
00084 #endif