Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 64ab58d

Browse files
committed
improved compatibility
1 parent 9eba9b1 commit 64ab58d

File tree

3 files changed

+27
-60
lines changed

3 files changed

+27
-60
lines changed

cores/arduino/io.h

+3-59
Original file line numberDiff line numberDiff line change
@@ -43,72 +43,16 @@
4343
#include "adc.h"
4444

4545
#include "wiring_time.h"
46-
47-
/**
48-
* Specifies a GPIO pin behavior.
49-
* @see pinMode()
50-
*/
51-
typedef enum WiringPinMode {
52-
INPUT, /**< Basic digital input. The pin voltage is sampled; when
53-
it is closer to 3.3v (Vcc) the pin status is high, and
54-
when it is closer to 0v (ground) it is low. If no
55-
external circuit is pulling the pin voltage to high or
56-
low, it will tend to randomly oscillate and be very
57-
sensitive to noise (e.g., a breath of air across the pin
58-
might cause the state to flip). */
59-
60-
OUTPUT, /**< Basic digital output: when the pin is HIGH, the
61-
voltage is held at +3.3v (Vcc) and when it is LOW, it
62-
is pulled down to ground. */
63-
64-
OUTPUT_OPENDRAIN, /**< In open drain mode, the pin indicates
65-
"low" by accepting current flow to ground
66-
and "high" by providing increased
67-
impedance. An example use would be to
68-
connect a pin to a bus line (which is pulled
69-
up to a positive voltage by a separate
70-
supply through a large resistor). When the
71-
pin is high, not much current flows through
72-
to ground and the line stays at positive
73-
voltage; when the pin is low, the bus
74-
"drains" to ground with a small amount of
75-
current constantly flowing through the large
76-
resistor from the external supply. In this
77-
mode, no current is ever actually sourced
78-
from the pin. */
79-
80-
81-
82-
INPUT_PULLUP, /**< The state of the pin in this mode is reported
83-
the same way as with INPUT, but the pin voltage
84-
is gently "pulled up" towards +3.3v. This means
85-
the state will be high unless an external device
86-
is specifically pulling the pin down to ground,
87-
in which case the "gentle" pull-up will not
88-
affect the state of the input. */
89-
90-
INPUT_PULLDOWN, /**< The state of the pin in this mode is reported
91-
the same way as with INPUT, but the pin voltage
92-
is gently "pulled down" towards 0v. This means
93-
the state will be low unless an external device
94-
is specifically pulling the pin up to 3.3v, in
95-
which case the "gentle" pull-down will not
96-
affect the state of the input. */
97-
98-
INPUT_FLOAT, /**< Synonym for INPUT. */
99-
100-
OUTPUT_DAC, /**< This is a special mode for when the pin will be used for
101-
PWM output (a special case of digital output). */
102-
} WiringPinMode;
46+
#include "wiring_constants.h"
10347

10448
/**
10549
* Configure behavior of a GPIO pin.
10650
*
10751
* @param pin Number of pin to configure.
10852
* @param mode Mode corresponding to desired pin behavior.
109-
* @see WiringPinMode
53+
* @see PinMode
11054
*/
111-
void pinMode(uint8 pin, WiringPinMode mode);
55+
void pinMode(uint8 pin, uint8 mode);
11256

11357
/**
11458
* Writes a (digital) value to a pin. The pin must have its

cores/arduino/wiring_constants.h

+23
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@
4141
extern "C"{
4242
#endif
4343

44+
#define INPUT 0x0
45+
#define OUTPUT 0x1
46+
#define INPUT_PULLUP 0x2
47+
#define OUTPUT_OPENDRAIN 0x3
48+
#define INPUT_PULLUP 0x4
49+
#define INPUT_PULLDOWN 0x5
50+
#define INPUT_FLOAT 0x6
51+
#define OUTPUT_DAC 0x7
52+
53+
#define true 0x1
54+
#define false 0x0
55+
56+
#define PI 3.1415926535897932384626433832795
57+
#define HALF_PI 1.5707963267948966192313216916398
58+
#define TWO_PI 6.283185307179586476925286766559
59+
#define DEG_TO_RAD 0.017453292519943295769236907684886
60+
#define RAD_TO_DEG 57.295779513082320876798154814105
61+
#define EULER 2.718281828459045235360287471352
62+
63+
#define SERIAL 0x0
64+
#define DISPLAY 0x1
65+
66+
4467
typedef unsigned short word;
4568

4669
enum BitOrder {

cores/arduino/wiring_digital.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "Arduino.h"
3939
#include "dac.h"
4040

41-
void pinMode(uint8 pin, WiringPinMode mode)
41+
void pinMode(uint8 pin, uint8 mode)
4242
{
4343
gpio_pin_mode outputMode;
4444
boolean pwm = false;

0 commit comments

Comments
 (0)