00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef Wiring_h
00022 #define Wiring_h
00023
00024 #include <avr/io.h>
00025 #include <avr/sleep.h>
00026 #include <avr/wdt.h>
00027 #include "binary.h"
00028
00029 #ifdef __cplusplus
00030 extern "C"{
00031 #endif
00032
00033 #define HIGH 0x1
00034 #define LOW 0x0
00035
00036 #define INPUT 0x0
00037 #define OUTPUT 0x1
00038
00039 #define true 0x1
00040 #define false 0x0
00041
00042 #define PI 3.14159265
00043 #define HALF_PI 1.57079
00044 #define TWO_PI 6.283185
00045
00046 #define SERIAL 0x0
00047 #define DISPLAY 0x1
00048
00049 #define LSBFIRST 0
00050 #define MSBFIRST 1
00051
00052 #define CHANGE 1
00053 #define FALLING 2
00054 #define RISING 3
00055
00056 #define min(a,b) ((a)<(b)?(a):(b))
00057 #define max(a,b) ((a)>(b)?(a):(b))
00058 #define abs(x) ((x)>0?(x):-(x))
00059 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
00060 #define radians(deg) ((deg)*DEG_TO_RAD)
00061 #define degrees(rad) ((rad)*RAD_TO_DEG)
00062 #define sq(x) ((x)*(x))
00063
00064 #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
00065 #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
00066
00067
00068
00069 typedef uint8_t boolean;
00070 typedef uint8_t byte;
00071
00072 void init(void);
00073
00074 void pinMode(uint8_t, uint8_t);
00075 void digitalWrite(uint8_t, uint8_t);
00076 int digitalRead(uint8_t);
00077 int analogRead(uint8_t);
00078 void analogWrite(uint8_t, int);
00079
00080 void beginSerial(long, uint8_t);
00081 void closeSerial(uint8_t);
00082 void serialWrite(unsigned char, uint8_t);
00083 int serialAvailable(uint8_t);
00084 int serialRead(uint8_t);
00085 void serialFlush(uint8_t);
00086 void printMode(int, uint8_t);
00087 void printByte(unsigned char c, uint8_t);
00088 void printNewline(uint8_t);
00089 void printString(const char *s, uint8_t);
00090 void printInteger(long n, uint8_t);
00091 void printHex(unsigned long n, uint8_t);
00092 void printOctal(unsigned long n, uint8_t);
00093 void printBinary(unsigned long n, uint8_t);
00094 void printIntegerInBase(unsigned long n, unsigned long base, uint8_t);
00095
00096 unsigned long millis(void);
00097 unsigned long millisTim2(void);
00098 void delay(unsigned long);
00099 void delayMicroseconds(unsigned int us);
00100
00101 void wait(uint8_t);
00102 void waitFor (uint8_t, uint8_t);
00103 unsigned long pulseIn(uint8_t pin, uint8_t state);
00104
00105 void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val);
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 void attachInterrupt(uint8_t, void (*)(void), int mode);
00116 void detachInterrupt(uint8_t);
00117 void enableInterrupts(uint16_t);
00118 void disableInterrupts(uint16_t);
00119
00120
00121
00122 void onHAIwakeUP(void);
00123 void onLAIwakeUP(void);
00124 void clearIntFlag();
00125
00126
00127
00128 void wakeUpNowDefault(void);
00129
00130 void setup_watchdog(uint8_t);
00131 void off_watchdog(void);
00132
00133 void setIPF_(uint8_t peripheral);
00134 void resetIPF_(uint8_t peripheral);
00135
00136 void setup(void);
00137 void loop(void);
00138
00139 #ifdef __cplusplus
00140 }
00141 #endif
00142
00143 #endif