24
24
#include < stdint.h>
25
25
#include < stdlib.h>
26
26
#include < string.h>
27
- // Wacky deprecated AVR compatibility functions
28
- #include " stdlib_noniso.h"
29
-
27
+ #include " stdlib_noniso.h" // Wacky deprecated AVR compatibility functions
30
28
#include " api/ArduinoAPI.h"
29
+ #include " api/itoa.h" // ARM toolchain doesn't provide itoa etc, provide them
31
30
#include < pins_arduino.h>
32
-
33
-
34
- // Required for the port*Register mac
8000
ros
35
- #include " hardware/gpio.h"
36
-
31
+ #include " hardware/gpio.h" // Required for the port*Register macros
37
32
#include " debug_internal.h"
38
33
39
34
// Try and make the best of the old Arduino abs() macro. When in C++, use
44
39
#endif // abs
45
40
#ifdef __cplusplus
46
41
using std::abs;
42
+ using std::round;
47
43
#else
48
- #define abs (x ) ((x)>0 ?(x):-(x))
44
+ #define abs (x ) ({ __typeof__ (x) _x = (x); _x >= 0 ? _x : -_x; })
45
+ #define round (x ) ({ __typeof__ (x) _x = (x); _x >= 0 ? (long )(_x + 0.5 ) : (long )(_x - 0.5 ); })
49
46
#endif
50
47
51
48
#ifdef __cplusplus
@@ -61,10 +58,6 @@ extern "C" {
61
58
void interrupts();
62
59
void noInterrupts ();
63
60
64
- // GPIO change/value interrupts
65
- void attachInterrupt (pin_size_t pin, voidFuncPtr callback, PinStatus mode);
66
- void detachInterrupt (pin_size_t pin);
67
-
68
61
// AVR compatibility macros...naughty and accesses the HW directly
69
62
#define digitalPinToPort (pin ) (0 )
70
63
#define digitalPinToBitMask (pin ) (1UL << (pin))
@@ -75,28 +68,14 @@ void detachInterrupt(pin_size_t pin);
75
68
#define portInputRegister (port ) ((volatile uint32_t *) sio_hw->gpio_in)
76
69
#define portModeRegister (port ) ((volatile uint32_t *) sio_hw->gpio_oe)
77
70
78
- // IO config
79
- void pinMode (pin_size_t pinNumber, PinMode pinMode);
80
-
81
- // SIO (GPIO)
82
- void digitalWrite (pin_size_t pinNumber, PinStatus status);
83
- PinStatus digitalRead (pin_size_t pinNumber);
84
-
85
- // ADC
86
- int analogRead (pin_size_t pinNumber);
71
+ // ADC RP2040-specific calls
87
72
float analogReadTemp (); // Returns core temp in Centigrade
88
73
89
- // PWM
90
- void analogWrite (pin_size_t pinNumber, int value);
74
+ // PWM RP2040-specific calls
91
75
void analogWriteFreq (uint32_t freq);
92
76
void analogWriteRange (uint32_t range);
93
77
void analogWriteResolution (int res);
94
78
95
- // Timing
96
- void delay (unsigned long );
97
- void delayMicroseconds (unsigned int us);
98
- unsigned long millis ();
99
-
100
79
#ifdef __cplusplus
101
80
} // extern "C"
102
81
#endif
@@ -127,8 +106,4 @@ constexpr uint32_t __bitset(const int (&a)[N], size_t i = 0U) {
127
106
}
128
107
#endif
129
108
130
-
131
- // ARM toolchain doesn't provide itoa etc, provide them
132
- #include " api/itoa.h"
133
-
134
109
#endif // Arduino_h
0 commit comments