From 5381b6187f965555191e42de57fda585973acc03 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 18 Nov 2024 20:42:06 +0100 Subject: [PATCH 1/2] boards/wemos-zero: fix Arduio I/O Map Two pins were incorrectly mapped because D2 and D4 are swapped on the WeMos zero compared to the Arduino Zero. This takes the difference into account. --- .../common/arduino-zero/include/arduino_iomap.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/boards/common/arduino-zero/include/arduino_iomap.h b/boards/common/arduino-zero/include/arduino_iomap.h index f6696705bb02..2761cbdb0a8a 100644 --- a/boards/common/arduino-zero/include/arduino_iomap.h +++ b/boards/common/arduino-zero/include/arduino_iomap.h @@ -64,11 +64,22 @@ extern "C" { * @name Mapping of MCU pins to Arduino pins * @{ */ + +/* The WeMos Zero / HW-819 has D2 and D4 swapped compared to official Arduino + * Zero, so we have to handle D2 and D4 differently depending on board */ +#ifdef BOARD_WEMOS_ZERO +# define ARDUINO_PIN_2 GPIO_PIN(PA, 8) +# define ARDUINO_PIN_4 GPIO_PIN(PA, 14) +#else /* Official Arduino Zero or fully compatible: */ +# define ARDUINO_PIN_2 GPIO_PIN(PA, 14) +# define ARDUINO_PIN_4 GPIO_PIN(PA, 8) +#endif + +/* all other pins are identical for all currently supported Arduino Zero + * compatible boards */ #define ARDUINO_PIN_0 GPIO_PIN(PA, 11) #define ARDUINO_PIN_1 GPIO_PIN(PA, 10) -#define ARDUINO_PIN_2 GPIO_PIN(PA, 14) #define ARDUINO_PIN_3 GPIO_PIN(PA, 9) -#define ARDUINO_PIN_4 GPIO_PIN(PA, 8) #define ARDUINO_PIN_5 GPIO_PIN(PA, 15) #define ARDUINO_PIN_6 GPIO_PIN(PA, 20) #define ARDUINO_PIN_7 GPIO_PIN(PA, 21) From fd233fe82a77c220978d49025ee202fefcb91561 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 18 Nov 2024 21:05:19 +0100 Subject: [PATCH 2/2] boards/wemos-zero: add note for identification The variant with HW-819 is easier to buy these days and identical to the original wemos-zero variant including the swapped D2/D4 pins. Co-authored-by: mguetschow --- boards/wemos-zero/doc.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/boards/wemos-zero/doc.txt b/boards/wemos-zero/doc.txt index 782d07710329..15aa8dbee63d 100644 --- a/boards/wemos-zero/doc.txt +++ b/boards/wemos-zero/doc.txt @@ -6,13 +6,14 @@ ## Overview The WeMos Zero is a cheap clone of Arduino Zero featuring a ATSAMD21G18A. +These boards either have a silkscreen "WeMos" or "HW-910" label on their back. Unlike the original Zero, it does not include an embedded debugger/programmer. Instead, the [UF2 Bootloader](https://github.com/microsoft/uf2-samdx1) is used to program this board. The SAMD21 is a ARM Cortex-M0+ micro-controller. It has 256KiB of flash memory and 32KiB of RAM. -Note: The official Arduino Zero using the native USB port and the Adafruit -Metro M0 Express should also work with board definition. +@note The official Arduino Zero using the native USB port and the Adafruit + Metro M0 Express should also work with this board definition. ## Hardware