L(dr) and P(ir) readings
[Arduino] / libraries / LCD4Bit_mod / wiring.h
1 /*\r
2   wiring.h - Partial implementation of the Wiring API for the ATmega8.\r
3   Part of Arduino - http://www.arduino.cc/\r
4 \r
5   Copyright (c) 2005-2006 David A. Mellis\r
6 \r
7   This library is free software; you can redistribute it and/or\r
8   modify it under the terms of the GNU Lesser General Public\r
9   License as published by the Free Software Foundation; either\r
10   version 2.1 of the License, or (at your option) any later version.\r
11 \r
12   This library is distributed in the hope that it will be useful,\r
13   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
15   Lesser General Public License for more details.\r
16 \r
17   You should have received a copy of the GNU Lesser General\r
18   Public License along with this library; if not, write to the\r
19   Free Software Foundation, Inc., 59 Temple Place, Suite 330,\r
20   Boston, MA  02111-1307  USA\r
21 \r
22   $Id$\r
23 */\r
24 \r
25 #ifndef Wiring_h\r
26 #define Wiring_h\r
27 \r
28 #include <avr/io.h>\r
29 #include <stdlib.h>\r
30 #include "binary.h"\r
31 \r
32 #ifdef __cplusplus\r
33 extern "C"{\r
34 #endif\r
35 \r
36 #define HIGH 0x1\r
37 #define LOW  0x0\r
38 \r
39 #define INPUT 0x0\r
40 #define OUTPUT 0x1\r
41 \r
42 #define true 0x1\r
43 #define false 0x0\r
44 \r
45 #define PI 3.1415926535897932384626433832795\r
46 #define HALF_PI 1.5707963267948966192313216916398\r
47 #define TWO_PI 6.283185307179586476925286766559\r
48 #define DEG_TO_RAD 0.017453292519943295769236907684886\r
49 #define RAD_TO_DEG 57.295779513082320876798154814105\r
50 \r
51 #define SERIAL  0x0\r
52 #define DISPLAY 0x1\r
53 \r
54 #define LSBFIRST 0\r
55 #define MSBFIRST 1\r
56 \r
57 #define CHANGE 1\r
58 #define FALLING 2\r
59 #define RISING 3\r
60 \r
61 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)\r
62 #define INTERNAL1V1 2\r
63 #define INTERNAL2V56 3\r
64 #else\r
65 #define INTERNAL 3\r
66 #endif\r
67 #define DEFAULT 1\r
68 #define EXTERNAL 0\r
69 \r
70 // undefine stdlib's abs if encountered\r
71 #ifdef abs\r
72 #undef abs\r
73 #endif\r
74 \r
75 #define min(a,b) ((a)<(b)?(a):(b))\r
76 #define max(a,b) ((a)>(b)?(a):(b))\r
77 #define abs(x) ((x)>0?(x):-(x))\r
78 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))\r
79 #define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))\r
80 #define radians(deg) ((deg)*DEG_TO_RAD)\r
81 #define degrees(rad) ((rad)*RAD_TO_DEG)\r
82 #define sq(x) ((x)*(x))\r
83 \r
84 #define interrupts() sei()\r
85 #define noInterrupts() cli()\r
86 \r
87 #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )\r
88 #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )\r
89 #define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )\r
90 \r
91 #define lowByte(w) ((uint8_t) ((w) & 0xff))\r
92 #define highByte(w) ((uint8_t) ((w) >> 8))\r
93 \r
94 #define bitRead(value, bit) (((value) >> (bit)) & 0x01)\r
95 #define bitSet(value, bit) ((value) |= (1UL << (bit)))\r
96 #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))\r
97 #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))\r
98 \r
99 typedef unsigned int word;\r
100 \r
101 #define bit(b) (1UL << (b))\r
102 \r
103 typedef uint8_t boolean;\r
104 typedef uint8_t byte;\r
105 \r
106 void init(void);\r
107 \r
108 void pinMode(uint8_t, uint8_t);\r
109 void digitalWrite(uint8_t, uint8_t);\r
110 int digitalRead(uint8_t);\r
111 int analogRead(uint8_t);\r
112 void analogReference(uint8_t mode);\r
113 void analogWrite(uint8_t, int);\r
114 \r
115 unsigned long millis(void);\r
116 unsigned long micros(void);\r
117 void delay(unsigned long);\r
118 void delayMicroseconds(unsigned int us);\r
119 unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);\r
120 \r
121 void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);\r
122 uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);\r
123 \r
124 void attachInterrupt(uint8_t, void (*)(void), int mode);\r
125 void detachInterrupt(uint8_t);\r
126 \r
127 void setup(void);\r
128 void loop(void);\r
129 \r
130 #ifdef __cplusplus\r
131 } // extern "C"\r
132 #endif\r
133 \r
134 #endif\r