PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Arduino.h
Go to the documentation of this file.
1 
9 #ifndef Arduino_h
10 #define Arduino_h
11 
12 #include <stdlib.h>
13 #include <string.h>
14 #include <math.h>
15 #include <propeller.h>
16 
17 #include "binary.h"
18 
19 #ifdef __cplusplus
20 extern "C"{
21 #endif
22 
23 #define ARDUINO 100
24 
25 #define HIGH 0x1
26 #define LOW 0x0
27 
28 #define INPUT 0x0
29 #define OUTPUT 0x1
30 #define INPUT_PULLUP 0x2
31 
32 #define true 0x1
33 #define false 0x0
34 
35 #define PI 3.1415926535897932384626433832795
36 #define HALF_PI 1.5707963267948966192313216916398
37 #define TWO_PI 6.283185307179586476925286766559
38 #define DEG_TO_RAD 0.017453292519943295769236907684886
39 #define RAD_TO_DEG 57.295779513082320876798154814105
40 
41 #define SERIAL 0x0
42 #define DISPLAY 0x1
43 
44 #define LSBFIRST 0
45 #define MSBFIRST 1
46 
47 // Extend the Arduino shiftin/out functions with different bit order features
48 #define MSBPRE 2
49 #define LSBPRE 3
50 #define MSBPOST 4
51 #define LSBPOST 5
52 #define MSBPRE 2
53 
54 #define CHANGE 1
55 #define FALLING 2
56 #define RISING 3
57 
58 // undefine stdlib's abs if encountered
59 #ifdef abs
60 #undef abs
61 #endif
62 
63 #define min(a,b) ((a)<(b)?(a):(b))
64 #define max(a,b) ((a)>(b)?(a):(b))
65 #define abs(x) ((x)>0?(x):-(x))
66 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
67 #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
68 #define radians(deg) ((deg)*DEG_TO_RAD)
69 #define degrees(rad) ((rad)*RAD_TO_DEG)
70 #define sq(x) ((x)*(x))
71 
72 #define clockCyclesPerMicrosecond() ( CLKFREQ / 1000000L )
73 #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
74 #define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
75 
76 #define lowByte(w) ((uint8_t) ((w) & 0xff))
77 #define highByte(w) ((uint8_t) ((w) >> 8))
78 
79 #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
80 #define bitSet(value, bit) ((value) |= (1UL << (bit)))
81 #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
82 #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
83 
84 typedef uint16_t word;
85 
86 #define bit(b) (1UL << (b))
87 
88 typedef uint8_t boolean;
89 typedef uint8_t byte;
90 
91 void pinMode(uint8_t, uint8_t);
92 void digitalWrite(uint8_t, uint8_t);
93 int digitalRead(uint8_t);
94 int analogRead(uint8_t);
95 void analogReference(uint8_t mode);
96 void analogWrite(uint8_t, int);
97 
98 unsigned long millis(void);
99 unsigned long micros(void);
100 void delay(unsigned long);
101 void delayMicroseconds(uint16_t us);
102 unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
103 void pulseOut(uint8_t pin, unsigned long duration);
104 
105 void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
106 uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
107 
108 void setup(void);
109 void loop(void);
110 
111 #define pgm_read_byte(ptr) *(ptr)
112 #define A0 0
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 
119 #ifdef __cplusplus
120 //#include "WCharacter.h"
121 #include "WString.h"
122 #include "Print.h"
123 #include "Serial.h"
124 
125 uint16_t makeWord(uint16_t w);
126 uint16_t makeWord(byte h, byte l);
127 
128 #define word(...) makeWord(__VA_ARGS__)
129 
130 unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
131 
132 void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
133 void noTone(uint8_t _pin);
134 
135 // WMath prototypes
136 long random(long);
137 long random(long, long);
138 void randomSeed(unsigned int);
139 long map(long, long, long, long, long);
140 
141 #endif
142 
143 #endif
144 // _ARDUINO_H_
us
int us
Propeller system clock ticks in 1 millisecond (us).
Definition: abcalibrate.c:36
timeout
int timeout(int time)
Compares the time against the time elapsed since mark (deprecated).
Definition: timeout.c:19
L
#define L
For selecting the left of the two RGB LEDs. Example: rgb(L, RED) would set the left RGB LED to the co...
Definition: badgetools.h:88
random
int random(int limitLow, int limitHigh)
Generates a pseudo-random integer value that falls in a range from limitLow to limitHigh....
Definition: random.c:22
Serial.h
Provides Arduino Serial funtions on the Propeller.