|
| 1 | +/* |
| 2 | + Arduino.h - Main include file for the Arduino SDK |
| 3 | + Copyright (c) 2005-2013 Arduino Team. All right reserved. |
| 4 | +
|
| 5 | + This library is free software; you can redistribute it and/or |
| 6 | + modify it under the terms of the GNU Lesser General Public |
| 7 | + License as published by the Free Software Foundation; either |
| 8 | + version 2.1 of the License, or (at your option) any later version. |
| 9 | +
|
| 10 | + This library is distributed in the hope that it will be useful, |
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | + Lesser General Public License for more details. |
| 14 | +
|
| 15 | + You should have received a copy of the GNU Lesser General Public |
| 16 | + License along with this library; if not, write to the Free Software |
| 17 | + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | +*/ |
| 19 | + |
| 20 | + |
| 21 | +#ifndef Arduino_h |
| 22 | +#define Arduino_h |
| 23 | + |
| 24 | +#include <stdlib.h> |
| 25 | +#include <stdbool.h> |
| 26 | +#include <string.h> |
| 27 | +#include <math.h> |
| 28 | +#include <stdint.h> |
| 29 | +#include <stdio.h> |
| 30 | +#include "pins_arduino.h" |
| 31 | +#include "./include/driver/wm_hal.h" |
| 32 | + |
| 33 | + |
| 34 | +#ifdef __cplusplus |
| 35 | +extern "C" { |
| 36 | +#endif |
| 37 | + |
| 38 | +//Macro-based digital IO fucntions |
| 39 | +//#include "wiring_digita.h" |
| 40 | + |
| 41 | +//!!!!#include "binary.h" |
| 42 | + |
| 43 | +// FIXME: workarounds for missing features or unimplemented functions |
| 44 | +// cancel out the PROGMEM attribute - used only for atmel CPUs |
| 45 | +#define PROGMEM |
| 46 | +void yield(void); |
| 47 | + |
| 48 | +// we use pre-defined IRQ function the way wiring does |
| 49 | +#define WIRING |
| 50 | + |
| 51 | +#define HIGH 0x1 |
| 52 | +#define LOW 0x0 |
| 53 | + |
| 54 | +#define INPUT 0x0 |
| 55 | +#define OUTPUT 0x1 |
| 56 | +#define INPUT_PULLUP 0x2 |
| 57 | +#define OUTPUT_OD 0x03 |
| 58 | + |
| 59 | +// undefine mathlib's pi if encountered |
| 60 | +#ifdef PI |
| 61 | +#undef PI |
| 62 | +#endif |
| 63 | +#ifdef HALF_PI |
| 64 | +#undef HALF_PI |
| 65 | +#endif |
| 66 | +#ifdef TWO_PI |
| 67 | +#undef TWO_PI |
| 68 | +#endif |
| 69 | + |
| 70 | +#define PI 3.1415926535897932384626433832795 |
| 71 | +#define HALF_PI 1.5707963267948966192313216916398 |
| 72 | +#define TWO_PI 6.283185307179586476925286766559 |
| 73 | +#define DEG_TO_RAD 0.017453292519943295769236907684886 |
| 74 | +#define RAD_TO_DEG 57.295779513082320876798154814105 |
| 75 | +#define EULER 2.718281828459045235360287471352 |
| 76 | + |
| 77 | +#define SERIAL 0x0 |
| 78 | +#define DISPLAY 0x1 |
| 79 | + |
| 80 | +#define LSBFIRST 0 |
| 81 | +#define MSBFIRST 1 |
| 82 | + |
| 83 | +#define FALLING 1 |
| 84 | + |
| 85 | +/* |
| 86 | +#define INTERNAL1V1 2 |
| 87 | +#define INTERNAL2V56 3 |
| 88 | +#define INTERNAL 3 |
| 89 | +#define DEFAULT 1 |
| 90 | +#define EXTERNAL 0 |
| 91 | +*/ |
| 92 | + |
| 93 | +// undefine stdlib's abs if encountered |
| 94 | +#ifdef abs |
| 95 | +#undef abs |
| 96 | +#endif |
| 97 | + |
| 98 | +#define min(a,b) ((a)<(b)?(a):(b)) |
| 99 | +#define max(a,b) ((a)>(b)?(a):(b)) |
| 100 | +#define abs(x) ((x)>0?(x):-(x)) |
| 101 | +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) |
| 102 | +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) |
| 103 | +#define radians(deg) ((deg)*DEG_TO_RAD) |
| 104 | +#define degrees(rad) ((rad)*RAD_TO_DEG) |
| 105 | +#define sq(x) ((x)*(x)) |
| 106 | + |
| 107 | +#define interrupts() sei() |
| 108 | +#define noInterrupts() cli() |
| 109 | + |
| 110 | +#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) |
| 111 | +#define clockCyclesPerMillisecond() ( F_CPU / 1000L ) |
| 112 | +#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) |
| 113 | +#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) |
| 114 | + |
| 115 | +#define byte(w) ((uint8_t)(w)) |
| 116 | +#define lowByte(w) ((uint8_t) ((w) & 0xff)) |
| 117 | +#define highByte(w) ((uint8_t) ((w) >> 8)) |
| 118 | + |
| 119 | +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) |
| 120 | +#define bitSet(value, bit) ((value) |= (1UL << (bit))) |
| 121 | +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) |
| 122 | +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) |
| 123 | + |
| 124 | +#define maskSet(value, mask) ((value) |= (mask)) |
| 125 | +#define maskClear(value, mask) ((value) &= ~(mask)) |
| 126 | + |
| 127 | + |
| 128 | +// avr-libc defines _NOP() since 1.6.2 |
| 129 | +#ifndef _NOP |
| 130 | +//#define _NOP() do { __asm__ volatile ("nop"); } while (0) |
| 131 | +#endif |
| 132 | + |
| 133 | +#define BEGIN_CRITICAL __critical { |
| 134 | +#define END_CRITICAL } |
| 135 | + |
| 136 | + |
| 137 | +typedef unsigned int word; |
| 138 | + |
| 139 | +#define bit(b) (1UL << (b)) |
| 140 | + |
| 141 | +typedef unsigned char boolean; |
| 142 | +typedef unsigned char byte; |
| 143 | +//typedef uint8_t byte; |
| 144 | + |
| 145 | +void init(void); |
| 146 | +//void initVariant(void); // weak |
| 147 | + |
| 148 | +//int atexit(void (*func)()); // __attribute__((weak)); |
| 149 | +//void serialEvent(void); // weak |
| 150 | +//extern unsigned char runSerialEvent; |
| 151 | + |
| 152 | +//void pinMode(uint8_t pin, __xdata uint8_t mode); |
| 153 | +//void digitalWrite(uint8_t pin, __xdata uint8_t val); |
| 154 | +uint8_t digitalRead(uint8_t pin); |
| 155 | +//void analogWrite(uint8_t pin, __xdata uint16_t val); |
| 156 | + |
| 157 | +//uint32_t millis(void); |
| 158 | +//uint32_t micros(void); |
| 159 | +//void delay(uint32_t ms); |
| 160 | +//void delayMicroseconds(uint16_t us); |
| 161 | +//unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); |
| 162 | +//unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout); |
| 163 | + |
| 164 | +//void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); |
| 165 | +//uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); |
| 166 | + |
| 167 | +//void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), __xdata uint8_t mode); |
| 168 | +//void detachInterrupt(uint8_t interruptNum); |
| 169 | + |
| 170 | +void setup(void); |
| 171 | +void loop(void); |
| 172 | + |
| 173 | +#ifdef __cplusplus |
| 174 | +} |
| 175 | +#endif |
| 176 | +#endif |
| 177 | + |
| 178 | + |
0 commit comments