Skip to content

Commit 216ef04

Browse files
authored
Merge pull request #21665 from gschorcht/boards/common/nucleo144/fix_complete_pin_config
boards/common/nucleo144: fix and complete Arduino configuration
2 parents 0a8b9d0 + b889024 commit 216ef04

File tree

2 files changed

+72
-22
lines changed

2 files changed

+72
-22
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Various common features of Nucleo-144 boards
22
FEATURES_PROVIDED += arduino_analog
3+
FEATURES_PROVIDED += arduino_i2c
34
FEATURES_PROVIDED += arduino_pins
45
FEATURES_PROVIDED += arduino_shield_mega
56
FEATURES_PROVIDED += arduino_shield_uno
7+
FEATURES_PROVIDED += arduino_spi
8+
FEATURES_PROVIDED += arduino_uart

boards/common/nucleo144/include/arduino_iomap.h

Lines changed: 69 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,54 @@
2525
extern "C" {
2626
#endif
2727

28+
/**
29+
* @name Arduino's UART devices
30+
* @{
31+
*/
32+
#define ARDUINO_UART_D0D1 UART_DEV(1)
33+
/** @} */
34+
35+
/**
36+
* @name Arduino's SPI buses
37+
* @{
38+
*/
39+
#if !defined(ARDUINO_SPI_D11D12D13) && defined(SPI_NUMOF)
40+
/**
41+
* @brief SPI_DEV(0) is connected to D11/D12/D13 for most Nucleo-144 boards
42+
*
43+
* This can be overwritten in `boards/nucleo-<foobar>/include/periph_conf.h` by
44+
* providing a custom `ARDUINO_SPI_D11D12D13`.
45+
*/
46+
# define ARDUINO_SPI_D11D12D13 SPI_DEV(0)
47+
#endif
48+
/** @} */
49+
50+
/**
51+
* @name Arduino's I2C buses
52+
* @{
53+
*/
54+
/**
55+
* @brief The first I2C bus is where shields for the Arduino UNO expect it
56+
*/
57+
#define ARDUINO_I2C_UNO I2C_DEV(0)
58+
/** @} */
59+
2860
/**
2961
* @name Mapping of MCU pins to Arduino pins
3062
* @{
3163
*/
3264
#if defined(CPU_MODEL_STM32F303ZE)
33-
#define ARDUINO_PIN_0 GPIO_PIN(PORT_C, 5)
34-
#define ARDUINO_PIN_1 GPIO_PIN(PORT_C, 4)
65+
# define ARDUINO_PIN_0 GPIO_PIN(PORT_C, 5)
66+
# define ARDUINO_PIN_1 GPIO_PIN(PORT_C, 4)
67+
#elif defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32L5)
68+
# define ARDUINO_PIN_0 GPIO_PIN(PORT_D, 9)
69+
# define ARDUINO_PIN_1 GPIO_PIN(PORT_D, 8)
70+
#elif defined(CPU_FAM_STM32U5)
71+
# define ARDUINO_PIN_0 GPIO_PIN(PORT_G, 8)
72+
# define ARDUINO_PIN_1 GPIO_PIN(PORT_G, 7)
3573
#else
36-
#define ARDUINO_PIN_0 GPIO_PIN(PORT_G, 9)
37-
#define ARDUINO_PIN_1 GPIO_PIN(PORT_G, 14)
74+
# define ARDUINO_PIN_0 GPIO_PIN(PORT_G, 9)
75+
# define ARDUINO_PIN_1 GPIO_PIN(PORT_G, 14)
3876
#endif
3977
#define ARDUINO_PIN_2 GPIO_PIN(PORT_F, 15)
4078
#define ARDUINO_PIN_3 GPIO_PIN(PORT_E, 13)
@@ -50,25 +88,34 @@ extern "C" {
5088
#define ARDUINO_PIN_12 GPIO_PIN(PORT_A, 6)
5189
#define ARDUINO_PIN_13 GPIO_PIN(PORT_A, 5)
5290

53-
#define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 8)
54-
#define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 9)
55-
56-
#define ARDUINO_PIN_16 GPIO_PIN(PORT_A, 3)
57-
#define ARDUINO_PIN_17 GPIO_PIN(PORT_C, 0)
58-
#define ARDUINO_PIN_18 GPIO_PIN(PORT_C, 3)
59-
#if defined(CPU_MODEL_STM32F413ZH) || defined(CPU_MODEL_STM32F412ZG) || \
60-
defined(CPU_MODEL_STM32L496ZG)
61-
# define ARDUINO_PIN_19 GPIO_PIN(PORT_C, 1)
62-
# define ARDUINO_PIN_20 GPIO_PIN(PORT_C, 4)
63-
# define ARDUINO_PIN_21 GPIO_PIN(PORT_C, 5)
64-
#elif defined(CPU_MODEL_STM32F303ZE)
65-
# define ARDUINO_PIN_19 GPIO_PIN(PORT_D, 11)
66-
# define ARDUINO_PIN_20 GPIO_PIN(PORT_D, 12)
67-
# define ARDUINO_PIN_21 GPIO_PIN(PORT_D, 13)
91+
#define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 9)
92+
#define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 8)
93+
94+
#if defined(CPU_FAM_STM32L5) || defined(CPU_FAM_STM32U5)
95+
# define ARDUINO_PIN_16 GPIO_PIN(PORT_A, 3)
96+
# define ARDUINO_PIN_17 GPIO_PIN(PORT_A, 2)
97+
# define ARDUINO_PIN_18 GPIO_PIN(PORT_C, 3)
98+
# define ARDUINO_PIN_19 GPIO_PIN(PORT_B, 0)
99+
# define ARDUINO_PIN_20 GPIO_PIN(PORT_C, 1)
100+
# define ARDUINO_PIN_21 GPIO_PIN(PORT_C, 0)
68101
#else
69-
# define ARDUINO_PIN_19 GPIO_PIN(PORT_F, 3)
70-
# define ARDUINO_PIN_20 GPIO_PIN(PORT_F, 5)
71-
# define ARDUINO_PIN_21 GPIO_PIN(PORT_F, 10)
102+
# define ARDUINO_PIN_16 GPIO_PIN(PORT_A, 3)
103+
# define ARDUINO_PIN_17 GPIO_PIN(PORT_C, 0)
104+
# define ARDUINO_PIN_18 GPIO_PIN(PORT_C, 3)
105+
# if defined(CPU_MODEL_STM32F413ZH) || defined(CPU_MODEL_STM32F412ZG) || \
106+
defined(CPU_FAM_STM32L4)
107+
# define ARDUINO_PIN_19 GPIO_PIN(PORT_C, 1)
108+
# define ARDUINO_PIN_20 GPIO_PIN(PORT_C, 4)
109+
# define ARDUINO_PIN_21 GPIO_PIN(PORT_C, 5)
110+
# elif defined(CPU_MODEL_STM32F303ZE)
111+
# define ARDUINO_PIN_19 GPIO_PIN(PORT_D, 11)
112+
# define ARDUINO_PIN_20 GPIO_PIN(PORT_D, 12)
113+
# define ARDUINO_PIN_21 GPIO_PIN(PORT_D, 13)
114+
# else
115+
# define ARDUINO_PIN_19 GPIO_PIN(PORT_F, 3)
116+
# define ARDUINO_PIN_20 GPIO_PIN(PORT_F, 5)
117+
# define ARDUINO_PIN_21 GPIO_PIN(PORT_F, 10)
118+
# endif
72119
#endif
73120

74121
#define ARDUINO_PIN_LAST 21

0 commit comments

Comments
 (0)