JM9 XRCU Board
0.1.1
Libraries API Reference
Loading...
Searching...
No Matches
wiring_constants.h
1
/*
2
Copyright (c) 2011 Arduino. All right reserved.
3
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) any later version.
8
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
See the GNU Lesser General Public License for more details.
13
14
You should have received a copy of the GNU Lesser General Public
15
License along with this library; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
19
#ifndef _WIRING_CONSTANTS_
20
#define _WIRING_CONSTANTS_
21
22
#include <stdbool.h>
23
#include <stdint.h>
24
25
#ifdef __cplusplus
26
#include <algorithm>
27
using
std::min;
28
using
std::max;
29
#else
// C
30
#include <stdlib.h>
31
#ifndef abs
32
#define abs(x) ((x)>0?(x):-(x))
33
#endif
// abs
34
35
#ifndef min
36
#define min(a,b) ((a)<(b)?(a):(b))
37
#endif
// min
38
39
#ifndef max
40
#define max(a,b) ((a)>(b)?(a):(b))
41
#endif
// max
42
43
#endif
// __cplusplus
44
45
/* Official Arduino */
46
#define INPUT 0x0
47
#define OUTPUT 0x1
48
#define INPUT_PULLUP 0x2
49
/* STM32 extension */
50
#define INPUT_FLOATING INPUT
51
#define INPUT_PULLDOWN 0x3
52
#define INPUT_ANALOG 0x4
53
#define OUTPUT_OPEN_DRAIN 0x5
54
55
#define PI 3.1415926535897932384626433832795
56
#define HALF_PI 1.5707963267948966192313216916398
57
#define TWO_PI 6.283185307179586476925286766559
58
#define DEG_TO_RAD 0.017453292519943295769236907684886
59
#define RAD_TO_DEG 57.295779513082320876798154814105
60
#define EULER 2.718281828459045235360287471352
61
62
#define SERIAL 0x0
63
#define DISPLAY 0x1
64
65
enum
BitOrder {
66
LSBFIRST = 0,
67
MSBFIRST = 1
68
};
69
70
#define LOW 0x0
71
#define HIGH 0x1
72
#define CHANGE 0x2
73
#define FALLING 0x3
74
#define RISING 0x4
75
76
#define DEFAULT 1
77
#define EXTERNAL 0
78
79
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
80
81
#define radians(deg) ((deg)*DEG_TO_RAD)
82
#define degrees(rad) ((rad)*RAD_TO_DEG)
83
#define sq(x) ((x)*(x))
84
85
#define interrupts() __enable_irq()
86
#define noInterrupts() __disable_irq()
87
88
#define lowByte(w) ((uint8_t) ((w) & 0xff))
89
#define highByte(w) ((uint8_t) ((w) >> 8))
90
91
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
92
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
93
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
94
#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet((value), (bit)) : bitClear((value), (bit) ))
95
96
#define bit(b) (1UL << (b))
97
//macro added for compatibility
98
#ifndef _BV
99
#define _BV(bit) (1 << (bit))
100
#endif
101
#ifndef cbi
102
#define cbi(reg, bitmask) *reg &= ~bitmask
103
#endif
104
#ifndef sbi
105
#define sbi(reg, bitmask) *reg |= bitmask
106
#endif
107
108
typedef
unsigned
int
word;
109
110
typedef
bool
boolean
__attribute__((deprecated));
111
112
typedef
uint8_t byte ;
113
114
#endif
/* _WIRING_CONSTANTS_ */
cores
arduino
wiring_constants.h
Generated by
1.13.2