-
-
Notifications
You must be signed in to change notification settings - Fork 284
/
Copy pathArduino.h
119 lines (93 loc) · 2.96 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifndef Arduino_h
#define Arduino_h
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef bool boolean;
typedef uint8_t byte;
typedef uint16_t word;
// some libraries and sketches depend on this AVR stuff,
// assuming Arduino.h or WProgram.h automatically includes it...
#include "avr/pgmspace.h"
#include "avr/interrupt.h"
#include "itoa.h"
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
#include "wiring_constants.h"
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )
void yield( void );
/* sketch */
void setup( void );
void loop( void );
#include "WVariant.h"
#ifdef __cplusplus
} // extern "C"
#endif
// The following headers are for C++ only compilation
#ifdef __cplusplus
#include "WCharacter.h"
#include "WString.h"
// #include "Tone.h"
#include "WMath.h"
#include "HardwareSerial.h"
#include "pulse.h"
#endif
#include "delay.h"
#include "binary.h"
#ifdef __cplusplus
#include "Uart.h"
#endif
// Include board variant
#include "variant.h"
#include "wiring.h"
#include "wiring_digital.h"
#include "wiring_analog.h"
#include "wiring_shift.h"
#include "WInterrupts.h"
// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif // abs
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))
#define interrupts() __enable_irq()
#define noInterrupts() __disable_irq()
#define lowByte(w) ((uint8_t) ((w) & 0xff))
#define highByte(w) ((uint8_t) ((w) >> 8))
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
#define bit(b) (1UL << (b))
#define digitalPinToPort(P) ( NRF_GPIO ) // NRF_P0 = P0.00 - P0.31, NRF_P1 = P1.00 - P1.15 (e.g. nRF52840)
#define digitalPinToBitMask(P) ( 1 << g_ADigitalPinMap[P] )
//#define analogInPinToBit(P) ( )
#define portOutputRegister(port) ( &(port->OUT) )
#define portInputRegister(port) ( &(port->IN) )
#define portModeRegister(port) ( &(port->DIR) )
#define digitalPinHasPWM(P) ( true )
/*
* digitalPinToTimer(..) is AVR-specific and is not defined for nRF52
* architecture. If you need to check if a pin supports PWM you must
* use digitalPinHasPWM(..).
*
* https://github.com/arduino/Arduino/issues/1833
*/
// #define digitalPinToTimer(P)
// Interrupts
#define digitalPinToInterrupt(P) ( P )
#ifdef __cplusplus
#include "Uart.h"
#endif // __cplusplus
#endif // Arduino_h