PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Dependents:   YATTT sd_map_test cPong SnowDemo ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Arduino.h Source File

Arduino.h

00001 #ifndef Arduino_h
00002 #define Arduino_h
00003 
00004 #include <stdlib.h>
00005 #include <string.h>
00006 #include <math.h>
00007 
00008 #include "PokittoFakeavr.h "
00009 
00010 #include <stdint.h>
00011 
00012 #include "binary.h"
00013 
00014 #ifdef __cplusplus
00015 extern "C"{
00016 #endif
00017 
00018 #define HIGH 0x1
00019 #define LOW  0x0
00020 
00021 //#define INPUT 0x0
00022 //#define OUTPUT 0x1
00023 //#define INPUT_PULLUP 0x2
00024 
00025 #define true 0x1
00026 #define false 0x0
00027 
00028 #define PI 3.1415926535897932384626433832795
00029 #define HALF_PI 1.5707963267948966192313216916398
00030 #define TWO_PI 6.283185307179586476925286766559
00031 #define DEG_TO_RAD 0.017453292519943295769236907684886
00032 #define RAD_TO_DEG 57.295779513082320876798154814105
00033 
00034 #define SERIAL  0x0
00035 #define DISPLAY 0x1
00036 
00037 #define LSBFIRST 0
00038 #define MSBFIRST 1
00039 
00040 #define CHANGE 1
00041 #define FALLING 2
00042 #define RISING 3
00043 
00044 #if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
00045 #define DEFAULT 0
00046 #define EXTERNAL 1
00047 #define INTERNAL 2
00048 #else
00049 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
00050 #define INTERNAL1V1 2
00051 #define INTERNAL2V56 3
00052 #else
00053 #define INTERNAL 3
00054 #endif
00055 #define DEFAULT 1
00056 #define EXTERNAL 0
00057 #endif
00058 
00059 // undefine stdlib's abs if encountered
00060 #ifdef abs
00061 #undef abs
00062 #endif
00063 
00064 #define min(a,b) ((a)<(b)?(a):(b))
00065 //#define max(a,b) ((a)>(b)?(a):(b))
00066 #define abs(x) ((x)>0?(x):-(x))
00067 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
00068 #define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
00069 #define radians(deg) ((deg)*DEG_TO_RAD)
00070 #define degrees(rad) ((rad)*RAD_TO_DEG)
00071 #define sq(x) ((x)*(x))
00072 
00073 #define interrupts() sei()
00074 #define noInterrupts() cli()
00075 
00076 #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
00077 #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
00078 #define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
00079 
00080 #define lowByte(w) ((uint8_t) ((w) & 0xff))
00081 #define highByte(w) ((uint8_t) ((w) >> 8))
00082 
00083 #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
00084 #define bitSet(value, bit) ((value) |= (1UL << (bit)))
00085 #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
00086 #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
00087 
00088 
00089 typedef unsigned int word;
00090 
00091 #define bit(b) (1UL << (b))
00092 
00093 typedef bool boolean;
00094 typedef uint8_t byte;
00095 
00096 void init(void);
00097 
00098 void pinMode(uint8_t, uint8_t);
00099 void digitalWrite(uint8_t, uint8_t);
00100 int digitalRead(uint8_t);
00101 int analogRead(uint8_t);
00102 void analogReference(uint8_t mode);
00103 void analogWrite(uint8_t, int);
00104 
00105 unsigned long millis(void);
00106 unsigned long micros(void);
00107 void delay(unsigned long);
00108 void delayMicroseconds(unsigned int us);
00109 unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
00110 
00111 void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
00112 uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
00113 
00114 void attachInterrupt(uint8_t, void (*)(void), int mode);
00115 void detachInterrupt(uint8_t);
00116 
00117 //extern void setup(void);
00118 //extern void loop(void);
00119 
00120 // Get the bit location within the hardware port of the given virtual pin.
00121 // This comes from the pins_*.c file for the active board configuration.
00122 
00123 #define analogInPinToBit(P) (P)
00124 
00125 // On the ATmega1280, the addresses of some of the port registers are
00126 // greater than 255, so we can't store them in uint8_t's.
00127 
00128 #define PROGMEM
00129 
00130 extern const uint8_t* PROGMEM port_to_mode_PGM[];
00131 extern const uint8_t* PROGMEM port_to_input_PGM[];
00132 extern const uint8_t* PROGMEM port_to_output_PGM[];
00133 
00134 extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
00135 // extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
00136 extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
00137 extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
00138 
00139 // Get the bit location within the hardware port of the given virtual pin.
00140 // This comes from the pins_*.c file for the active board configuration.
00141 //
00142 // These perform slightly better as macros compared to inline functions
00143 //
00144 #define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
00145 #define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
00146 #define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
00147 #define analogInPinToBit(P) (P)
00148 #define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
00149 #define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
00150 #define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
00151 
00152 #define NOT_A_PIN 0
00153 #define NOT_A_PORT 0
00154 
00155 #ifdef ARDUINO_MAIN
00156 #define PA 1
00157 #define PB 2
00158 #define PC 3
00159 #define PD 4
00160 #define PE 5
00161 #define PF 6
00162 #define PG 7
00163 #define PH 8
00164 #define PJ 10
00165 #define PK 11
00166 #define PL 12
00167 #endif
00168 
00169 #define NOT_ON_TIMER 0
00170 #define TIMER0A 1
00171 #define TIMER0B 2
00172 #define TIMER1A 3
00173 #define TIMER1B 4
00174 #define TIMER2  5
00175 #define TIMER2A 6
00176 #define TIMER2B 7
00177 
00178 #define TIMER3A 8
00179 #define TIMER3B 9
00180 #define TIMER3C 10
00181 #define TIMER4A 11
00182 #define TIMER4B 12
00183 #define TIMER4C 13
00184 #define TIMER4D 14
00185 #define TIMER5A 15
00186 #define TIMER5B 16
00187 #define TIMER5C 17
00188 
00189 #ifdef __cplusplus
00190 } // extern "C"
00191 #endif
00192 
00193 #ifdef __cplusplus
00194 #include "WCharacter.h"
00195 #include "WString.h"
00196 //#include "HardwareSerial.h"
00197 
00198 uint16_t makeWord(uint16_t w);
00199 uint16_t makeWord(byte h, byte l);
00200 
00201 #define word(...) makeWord(__VA_ARGS__)
00202 
00203 unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
00204 
00205 void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
00206 void noTone(uint8_t _pin);
00207 
00208 // WMath prototypes
00209 long random(long);
00210 long random(long, long);
00211 void randomSeed(unsigned int);
00212 long map(long, long, long, long, long);
00213 
00214 #endif
00215 
00216 #include "pins_arduino.h"
00217 
00218 #endif
00219