Test arduino code

Dependents:   DR14_4D7S_US

Fork of ArduinoHAL by René Bohne

Committer:
fblanc
Date:
Thu Feb 12 10:19:00 2015 +0000
Revision:
5:52ed7aa62e95
Parent:
4:40396527a068
ArduinoHAL->ArduinoFB; delay(); px->Dx;

Who changed what in which revision?

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