28 #include <avr/pgmspace.h> 30 #include <avr/interrupt.h> 45 #define INPUT_PULLUP 0x2 47 #define PI 3.1415926535897932384626433832795 48 #define HALF_PI 1.5707963267948966192313216916398 49 #define TWO_PI 6.283185307179586476925286766559 50 #define DEG_TO_RAD 0.017453292519943295769236907684886 51 #define RAD_TO_DEG 57.295779513082320876798154814105 52 #define EULER 2.718281828459045235360287471352 64 #if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) 68 #define INTERNAL INTERNAL1V1 69 #elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) 73 #define INTERNAL INTERNAL1V1 74 #define INTERNAL2V56 9 75 #define INTERNAL2V56_EXTCAP 13 77 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) 79 #define INTERNAL2V56 3 92 #define min(a,b) ((a)<(b)?(a):(b)) 93 #define max(a,b) ((a)>(b)?(a):(b)) 94 #define abs(x) ((x)>0?(x):-(x)) 95 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) 96 #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) 97 #define radians(deg) ((deg)*DEG_TO_RAD) 98 #define degrees(rad) ((rad)*RAD_TO_DEG) 99 #define sq(x) ((x)*(x)) 101 #define interrupts() sei() 102 #define noInterrupts() cli() 104 #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) 105 #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) 106 #define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) 108 #define lowByte(w) ((uint8_t) ((w) & 0xff)) 109 #define highByte(w) ((uint8_t) ((w) >> 8)) 111 #define bitRead(value, bit) (((value) >> (bit)) & 0x01) 112 #define bitSet(value, bit) ((value) |= (1UL << (bit))) 113 #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) 114 #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) 118 #define _NOP() do { __asm__ volatile ("nop"); } while (0) 123 #define bit(b) (1UL << (b)) 131 int atexit(
void (*func)()) __attribute__((weak));
133 void pinMode(uint8_t, uint8_t);
140 unsigned long millis(
void);
141 unsigned long micros(
void);
142 void delay(
unsigned long);
144 unsigned long pulseIn(uint8_t pin, uint8_t state,
unsigned long timeout);
145 unsigned long pulseInLong(uint8_t pin, uint8_t state,
unsigned long timeout);
147 void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t
val);
148 uint8_t
shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
159 #define analogInPinToBit(P) (P) 177 #define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) ) 178 #define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) ) 179 #define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) ) 180 #define analogInPinToBit(P) (P) 181 #define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) ) 182 #define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) ) 183 #define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) ) 188 #define NOT_AN_INTERRUPT -1 204 #define NOT_ON_TIMER 0 234 #if defined(HAVE_HWSERIAL0) && defined(HAVE_CDCSERIAL) 235 #error "Targets with both UART0 and CDC serial not supported" 241 #define word(...) makeWord(__VA_ARGS__) 243 unsigned long pulseIn(uint8_t pin, uint8_t state,
unsigned long timeout = 1000000L);
244 unsigned long pulseInLong(uint8_t pin, uint8_t state,
unsigned long timeout = 1000000L);
246 void tone(uint8_t _pin,
unsigned int frequency,
unsigned long duration = 0);
247 void noTone(uint8_t _pin);
253 long map(
long,
long,
long,
long,
long);
257 #include "pins_arduino.h"
void pinMode(uint8_t, uint8_t)
void delayMicroseconds(unsigned int us)
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
const uint8_t PROGMEM digital_pin_to_port_PGM[]
GLubyte GLubyte GLubyte GLubyte w
void randomSeed(unsigned long seed)
const uint16_t PROGMEM port_to_input_PGM[]
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
void detachInterrupt(uint8_t)
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder)
unsigned long micros(void)
void analogWrite(uint8_t, int)
void attachInterrupt(uint8_t, void(*)(void), int mode)
void analogReference(uint8_t mode)
void noTone(uint8_t _pin)
const uint8_t PROGMEM digital_pin_to_timer_PGM[]
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout)
const uint16_t PROGMEM port_to_output_PGM[]
void delay(unsigned long)
unsigned long millis(void)
long map(long x, long in_min, long in_max, long out_min, long out_max)
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[]
void digitalWrite(uint8_t, uint8_t)
const uint16_t PROGMEM port_to_mode_PGM[]
int atexit(void(*func)()) __attribute__((weak))
unsigned int makeWord(unsigned int w)
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)