Skip to content

Commit 1895f6c

Browse files
authored
Merge pull request #488 from Space48121111/Space48121111-patch-1
Arduino Uno Wifi Rev 2 Configured For Firmata
2 parents ee2ae4e + 0595a29 commit 1895f6c

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

Boards.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ writePort(port, value, bitmask): Write an 8 bit port.
675675
// Sanguino/Melzi, e.g. Creality Ender-3
676676
#elif defined(__AVR_ATmega1284P__)
677677
#define TOTAL_ANALOG_PINS 8
678-
#define TOTAL_PINS 32
678+
#define TOTAL_PINS 32
679679
#define VERSION_BLINK_PIN 13
680680
#define PIN_SERIAL1_RX 8 //PD0
681681
#define PIN_SERIAL1_TX 9 //PD1
@@ -999,6 +999,31 @@ writePort(port, value, bitmask): Write an 8 bit port.
999999
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
10001000
#define PIN_TO_SERVO(p) (p) // deprecated since v2.4
10011001

1002+
//Arduino Uno Wifi Rev2
1003+
#elif defined(__AVR_ATmega4809__)
1004+
#define TOTAL_ANALOG_PINS NUM_ANALOG_INPUTS //6
1005+
#define TOTAL_PINS 41 // 14 digital + 6 analog + 6 reserved + 10 internal used + 2 I2C + 3 SPI
1006+
#define TOTAL_PORTS 3
1007+
#define VERSION_BLINK_PIN LED_BUILTIN //25
1008+
#define PIN_SERIAL1_RX 0
1009+
#define PIN_SERIAL1_TX 1
1010+
#define PIN_SERIAL2_RX 23
1011+
#define PIN_SERIAL2_TX 24
1012+
#define PIN_SERIAL0_RX 26
1013+
#define PIN_SERIAL0_TX 27
1014+
#define IS_PIN_DIGITAL(p) (((p) >= 0 && (p) < 20) || (p) == 25)
1015+
#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 19)
1016+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
1017+
#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
1018+
#define IS_PIN_I2C(p) ((p) == 20 || (p) == 21)
1019+
#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
1020+
#define IS_PIN_SERIAL(p) ((p) == 23 || (p) == 24 || (p) == 26 || (p) == 27)
1021+
#define PIN_TO_DIGITAL(p) (p)
1022+
#define PIN_TO_ANALOG(p) ((p) - 14)
1023+
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
1024+
#define PIN_TO_SERVO(p) (p)
1025+
1026+
10021027
// anything else
10031028
#else
10041029
#error "Please edit Boards.h with a hardware abstraction for this board"

utility/SerialFirmata.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
// a) continuous streaming at higher baud rates: enable but set to 0 (receive buffer store & forward)
4949
// b) messages: set to a value below min. inter message delay (message store & forward)
5050
// c) continuous streaming at lower baud rates or random characters: undefine or set to -1 (disable)
51-
// 3) Smaller delays may not have the desired effect, especially with less powerful CPUs,
51+
// 3) Smaller delays may not have the desired effect, especially with less powerful CPUs,
5252
// if set to a value near or below the average Firmata main loop duration.
53-
// 4) The Firmata stream write buffer size must be equal or greater than the max.
53+
// 4) The Firmata stream write buffer size must be equal or greater than the max.
5454
// serial buffer/message size and the Firmata frame size (4 bytes) to prevent fragmentation
5555
// on the transport layer.
5656
//#define FIRMATA_SERIAL_RX_DELAY 50 // [ms]
@@ -78,6 +78,8 @@
7878
#define SERIAL_READ_ARR_LEN 12
7979

8080
// map configuration query response resolution value to serial pin type
81+
#define RES_RX0 0x00
82+
#define RES_TX0 0x01
8183
#define RES_RX1 0x02
8284
#define RES_TX1 0x03
8385
#define RES_RX2 0x04
@@ -121,6 +123,10 @@ namespace {
121123
#if defined(PIN_SERIAL_RX)
122124
// TODO when use of HW_SERIAL0 is enabled
123125
#endif
126+
#if defined(PIN_SERIAL0_RX)
127+
if (pin == PIN_SERIAL0_RX) return RES_RX0;
128+
if (pin == PIN_SERIAL0_TX) return RES_TX0;
129+
#endif
124130
#if defined(PIN_SERIAL1_RX)
125131
if (pin == PIN_SERIAL1_RX) return RES_RX1;
126132
if (pin == PIN_SERIAL1_TX) return RES_TX1;
@@ -163,6 +169,12 @@ namespace {
163169
// // TODO when use of HW_SERIAL0 is enabled
164170
// break;
165171
#endif
172+
#if defined(PIN_SERIAL0_RX)
173+
case HW_SERIAL0:
174+
pins.rx = PIN_SERIAL0_RX;
175+
pins.tx = PIN_SERIAL0_TX;
176+
break;
177+
#endif
166178
#if defined(PIN_SERIAL1_RX)
167179
case HW_SERIAL1:
168180
pins.rx = PIN_SERIAL1_RX;

0 commit comments

Comments
 (0)