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