Test arduino code
Fork of ArduinoHAL by
Embed:
(wiki syntax)
Show/hide line numbers
wiring.h
00001 /* 00002 wiring.h - Partial implementation of the Wiring API for the ATmega8. 00003 Part of Arduino - http://www.arduino.cc/ 00004 00005 Copyright (c) 2005-2006 David A. Mellis 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General 00018 Public License along with this library; if not, write to the 00019 Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00020 Boston, MA 02111-1307 USA 00021 00022 $Id$ 00023 */ 00024 00025 #ifndef Wiring_h 00026 #define Wiring_h 00027 00028 #include "binary.h" 00029 00030 00031 #define uint8_t int 00032 #define boolean int 00033 #define byte int 00034 00035 #define HIGH 0x1 00036 #define LOW 0x0 00037 00038 #define INPUT 0x0 00039 #define OUTPUT 0x1 00040 00041 #define true 0x1 00042 #define false 0x0 00043 00044 #define PI 3.1415926535897932384626433832795 00045 #define HALF_PI 1.5707963267948966192313216916398 00046 #define TWO_PI 6.283185307179586476925286766559 00047 #define DEG_TO_RAD 0.017453292519943295769236907684886 00048 #define RAD_TO_DEG 57.295779513082320876798154814105 00049 00050 #define SERIAL 0x0 00051 #define DISPLAY 0x1 00052 00053 #define LSBFIRST 0 00054 #define MSBFIRST 1 00055 00056 #define CHANGE 1 00057 #define FALLING 2 00058 #define RISING 3 00059 00060 // undefine stdlib's abs if encountered 00061 #ifdef abs 00062 #undef abs 00063 #endif 00064 00065 #define min(a,b) ((a)<(b)?(a):(b)) 00066 #define max(a,b) ((a)>(b)?(a):(b)) 00067 #define abs(x) ((x)>0?(x):-(x)) 00068 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) 00069 #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) 00070 #define radians(deg) ((deg)*DEG_TO_RAD) 00071 #define degrees(rad) ((rad)*RAD_TO_DEG) 00072 #define sq(x) ((x)*(x)) 00073 00074 #define interrupts() sei() 00075 #define noInterrupts() cli() 00076 00077 #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) 00078 #define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) ) 00079 #define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L ) 00080 00081 #define lowByte(w) ((uint8_t) ((w) & 0xff)) 00082 #define highByte(w) ((uint8_t) ((w) >> 8)) 00083 00084 #define bitRead(value, bit) (((value) >> (bit)) & 0x01) 00085 #define bitSet(value, bit) ((value) |= (1UL << (bit))) 00086 #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) 00087 #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) 00088 00089 00090 #define bit(b) (1UL << (b)) 00091 00092 /** Macro for delay() 00093 * 00094 * @param void 00095 */ 00096 #define delay(x) (wait_ms(x)) 00097 00098 void init(void); 00099 00100 void pinMode(uint8_t, uint8_t); 00101 void digitalWrite(uint8_t, uint8_t); 00102 int digitalRead(uint8_t); 00103 int analogRead(uint8_t); 00104 void analogReference(uint8_t mode); 00105 void analogWrite(uint8_t, int); 00106 00107 unsigned long millis(void); 00108 unsigned long micros(void); 00109 void delay(unsigned long); 00110 void delayMicroseconds(unsigned int us); 00111 unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); 00112 00113 void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); 00114 uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); 00115 00116 void attachInterrupt(uint8_t, void (*)(void), int mode); 00117 void detachInterrupt(uint8_t); 00118 00119 void setup(void); 00120 void loop(void); 00121 00122 00123 #endif
Generated on Tue Jul 12 2022 19:24:26 by
1.7.2
frederic blanc
