-
Notifications
You must be signed in to change notification settings - Fork 34
/
Arduino.h
71 lines (50 loc) · 1.92 KB
/
Arduino.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
/*
Mock Arduino.h library.
Where possible, variable names from the Arduino library are used to avoid conflicts
*/
// signal to the developer that we are in an arduino_ci mocked environment
#define ARDUINO_CI_COMPILATION_MOCKS
// Chars and strings
#include "ArduinoDefines.h"
#include "IPAddress.h"
#include "WCharacter.h"
#include "WString.h"
#include "Print.h"
#include "Stream.h"
#include "HardwareSerial.h"
typedef bool boolean;
typedef uint8_t byte;
#include "binary.h"
// Math and Trig
#include "AvrMath.h"
#include "Godmode.h"
// Bits and Bytes
#define bit(b) (1UL << (b))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
#define highByte(w) ((uint8_t) ((w) >> 8))
#define lowByte(w) ((uint8_t) ((w) & 0xff))
// using #define for these makes it impossible for other code to use as function
// names!
inline void yield() { _NOP(); }
inline void interrupts() { _NOP(); }
inline void noInterrupts() { _NOP(); }
// TODO: correctly establish this per-board!
#define F_CPU 1000000UL
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
typedef unsigned int word;
#define _BV(bit) (1 << (bit))
// Get the bit location within the hardware port of the given virtual pin.
// This comes from the pins_*.c file for the active board configuration.
#define analogInPinToBit(P) (P)
#define digitalPinToInterrupt(P) (P)
// uint16_t makeWord(uint16_t w);
// uint16_t makeWord(byte h, byte l);
inline unsigned int makeWord(unsigned int w) { return w; }
inline unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }
#define word(...) makeWord(__VA_ARGS__)