Skip to content

Commit d3ff345

Browse files
committed
Review pins numbering and signals pins numbering
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 85af38d commit d3ff345

File tree

2 files changed

+146
-141
lines changed

2 files changed

+146
-141
lines changed

variants/NUCLEO_F207ZG/variant.cpp

Lines changed: 124 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -35,107 +35,113 @@ extern "C" {
3535
#endif
3636

3737
// Pin number
38-
// This array allows to wrap Arduino pin number(Dx or x)
39-
// to STM32 PinName (PYx)
38+
// Match Table Table 16. NUCLEO-F207ZG pin assignments
39+
// from UM1974 STM32 Nucleo-144 board
4040
const PinName digitalPin[] = {
41-
//PYx, //Dx
42-
P, //D0
43-
P, //D1
44-
P, //D2
45-
P, //D3
46-
P, //D4
47-
P, //D5
48-
P, //D6
49-
P, //D7
50-
P, //D8
51-
P, //D9
52-
P, //D10
53-
P, //D11
54-
P, //D12
55-
P, //D13
56-
P, //D14
57-
P, //D15
58-
P, //D16
59-
P, //D17
60-
P, //D18
61-
P, //D19
62-
P, //D20
63-
P, //D21
64-
P, //D22
65-
P, //D23
66-
P, //D24
67-
P, //D25
68-
P, //D26
69-
P, //D27
70-
P, //D28
71-
P, //D29
72-
P, //D30
73-
P, //D31
74-
P, //D32
75-
P, //D33
76-
P, //D34
77-
P, //D35
78-
P, //D36
79-
P, //D37
80-
P, //D38
81-
P, //D39
82-
P, //D40
83-
P, //D41
84-
P, //D42
85-
P, //D43
86-
P, //D44
87-
P, //D45
88-
P, //D46
89-
P, //D47
90-
P, //D48
91-
P, //D49
92-
P, //D50
93-
P, //D51
94-
P, //D52
95-
P, //D53
96-
P, //D54
97-
P, //D55
98-
P, //D56
99-
P, //D57
100-
P, //D58
101-
P, //D59
102-
P, //D60
103-
P, //D61
104-
P, //D62
105-
P, //D63
106-
P, //D64
107-
P, //D65
108-
P, //D66
109-
P, //D67
110-
P, //D68
111-
P, //D69
112-
P, //D70
113-
P, //D71
114-
P, //D72
115-
P, //D73
116-
P, //D74
117-
P, //D75
118-
P, //D76
119-
P, //D77
120-
P, //D78/A0
121-
P, //D79/A1
122-
P, //D80/A2
123-
P, //D81/A3
124-
P, //D82/A4
125-
P, //D83/A5
126-
P, //D84/A6
127-
P, //D85/A7
128-
P, //D86/A8
129-
P, //D87/A9
41+
PG9, //D0
42+
PG14, //D1
43+
PF15, //D2
44+
PE13, //D3
45+
PF14, //D4
46+
PE11, //D5
47+
PE9, //D6
48+
PF13, //D7
49+
PF12, //D8
50+
PD15, //D9
51+
PD14, //D10
52+
PA7, //D11 - If SB121, SB122 (ON,OFF) connected to PA7 (default, see D71)
53+
// else SB121, SB122 (OFF,ON) connected to PB5 (D22)
54+
PA6, //D12
55+
PA5, //D13
56+
PB9, //D14
57+
PB8, //D15
58+
PC6, //D16
59+
PB15, //D17
60+
PB13, //D18 - used as I2S_A_CK and connected to CN7 pin 5 by default, if JP7 is ON,
61+
// it is also connected to Ethernet PHY as RMII_TXD1. In this case only
62+
// one function of Ethernet or I2S_A must be used.
63+
PB12, //D19
64+
PA15, //D20
65+
PC7, //D21
66+
PB5, //D22 - D11 if SB121 off, SB122 on
67+
PB3, //D23
68+
PA4, //D24
69+
PB4, //D25
70+
PB6, //D26
71+
PB2, //D27
72+
PD13, //D28
73+
PD12, //D29
74+
PD11, //D30
75+
PE2, //D31 - PE2 is connected to both CN9 pin 14 (I/O) and CN10 pin 25 (I/O).
76+
// Only one connector pin must be used at one time.
77+
PA0, //D32
78+
PB0, //D33 - LED1
79+
PE0, //D34
80+
PB11, //D35
81+
PB10, //D36
82+
PE15, //D37
83+
PE14, //D38
84+
PE12, //D39
85+
PE10, //D40
86+
PE7, //D41
87+
PE8, //D42
88+
PC8, //D43
89+
PC9, //D44
90+
PC10, //D45
91+
PC11, //D46
92+
PC12, //D47
93+
PD2, //D48
94+
PG2, //D49
95+
PG3, //D50
96+
PD7, //D51
97+
PD6, //D52
98+
PD5, //D53
99+
PD4, //D54
100+
PD3, //D55
101+
PE2, //D56 - connected to both CN9 pin 14 (I/O) and CN10 pin 25 (I/O).
102+
// Only one connector pin must be used at one time
103+
PE4, //D57
104+
PE5, //D58
105+
PE6, //D59
106+
PE3, //D60
107+
PF8, //D61
108+
PF7, //D62
109+
PF9, //D63
110+
PG1, //D64
111+
PG0, //D65
112+
PD1, //D66
113+
PD0, //D67
114+
PF0, //D68
115+
PF1, //D69
116+
PF2, //D70
117+
PA7, //D71 - used as D11 and connected to CN7 pin 14 by default, if JP6 is ON,
118+
// it is also connected to both Ethernet PHY as RMII_DV and CN9 pin 15.
119+
// In this case only one function of the Ethernet or D11 must be used.
120+
NC, //D72
121+
PB7, //D73 - LED_BLUE
122+
PB14, //D74 - LED_RED
123+
PC13, //D75 - USER_BTN
124+
PD9, //D76 - Serial Rx
125+
PD8, //D77 - Serial Tx
126+
PA3, //D78/A0
127+
PC0, //D79/A1
128+
PC3, //D80/A2
129+
PF3, //D81/A3
130+
PF5, //D82/A4
131+
PF10, //D83/A5
132+
PB1, //D84/A6
133+
PC2, //D85/A7
134+
PF4, //D86/A8
135+
PF6, //D87/A9
130136
// Duplicated pins in order to be aligned with PinMap_ADC
131-
P, //D88/A10 = D
132-
P, //D89/A11 = D
133-
P, //D90/A12 = D
134-
P, //D91/A13 = D
135-
P, //D92/A14 = D
136-
P, //D93/A15 = D
137-
P, //D94/A16 = D
138-
P //D95/A17 = D
137+
PA7, //D88/A10 = D11/D71
138+
PA6, //D89/A11 = D12
139+
PA5, //D90/A12 = D13
140+
PA4, //D91/A13 = D24
141+
PA0, //D92/A14 = D32
142+
PF8, //D93/A15 = D61
143+
PF7, //D94/A16 = D62
144+
PF9 //D95/A17 = D63
139145
};
140146

141147
#ifdef __cplusplus
@@ -145,29 +151,34 @@ const PinName digitalPin[] = {
145151
/*
146152
* UART objects
147153
*/
148-
// Replace PYx_Rx and PYx_Tx by UART_RX and UART_TX pin names
149-
HardwareSerial Serial(PYx_Rx, PYx_Tx); // Connected to ST-Link
154+
HardwareSerial Serial(PD9, PD8); // Connected to ST-Link
150155

151156
void serialEvent() __attribute__((weak));
152157
void serialEvent() { }
153158

154-
// Define as many Serial instance as desired
155-
// Replace 'SerialX' by the desired name
156-
//#ifdef ENABLE_SERIALX
157-
//HardwareSerial SerialX(PYx_Rx, PYx_Tx);
158-
//
159-
//void serialEventx() __attribute__((weak));
160-
//void serialEventx() { }
161-
//#endif
159+
#ifdef ENABLE_SERIAL1
160+
HardwareSerial Serial1(PG9, PG14);
161+
162+
void serialEvent1() __attribute__((weak));
163+
void serialEvent1() { }
164+
#endif
165+
#ifdef ENABLE_SERIAL2
166+
HardwareSerial Serial2(PD6, PD5);
167+
168+
void serialEvent2() __attribute__((weak));
169+
void serialEvent2() { }
170+
#endif
162171

163172
void serialEventRun(void)
164173
{
165174
if (Serial.available()) serialEvent();
166-
//#ifdef ENABLE_SERIALX
167-
// if (SerialX.available()) serialEventX();
168-
//#endif
175+
#ifdef ENABLE_SERIAL1
176+
if (Serial1.available()) serialEvent1();
177+
#endif
178+
#ifdef ENABLE_SERIAL2
179+
if (Serial2.available()) serialEvent2();
180+
#endif
169181
}
170-
171182
// ----------------------------------------------------------------------------
172183

173184
#ifdef __cplusplus

variants/NUCLEO_F207ZG/variant.h

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ extern "C"{
4949
extern const PinName digitalPin[];
5050

5151
// Enum defining Arduino style alias for digital pin number --> Dx
52-
// !!!
53-
// !!! It must be aligned with the number of PinName
54-
// !!! defined in digitalPin[] array in variant.cpp
55-
// !!!
5652
enum {
5753
D0, D1, D2, D3, D4, D5, D6, D7, D8, D9,
5854
D10, D11, D12, D13, D14, D15, D16, D17, D18, D19,
@@ -67,10 +63,6 @@ enum {
6763
DEND
6864
};
6965
// Enum defining Arduino style alias for analog pin number --> Ax
70-
// !!!
71-
// !!! It must be aligned with the number of analog PinName
72-
// !!! defined in digitalPin[] array in variant.cpp
73-
// !!!
7466
enum {
7567
A_START_AFTER = D77, // pin number preceding A0
7668
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
@@ -88,54 +80,56 @@ enum {
8880
#define PWM_MAX_DUTY_CYCLE 255
8981

9082
//On-board LED pin number
91-
#define LED_BUILTIN Dx
83+
#define LED_BUILTIN 33
9284
#define LED_GREEN LED_BUILTIN
85+
#define LED_BLUE 73
86+
#define LED_RED 74
9387

9488
//On-board user button
95-
#define USER_BTN Dx
89+
#define USER_BTN 75
9690

9791

9892
//SPI definitions
9993
//define 16 channels. As many channel as digital IOs
10094
#define SPI_CHANNELS_NUM 16
10195

10296
//default chip salect pin
103-
#define BOARD_SPI_DEFAULT_SS 10 // Default for Arduino connector compatibility
97+
#define BOARD_SPI_DEFAULT_SS 10
10498

10599
//In case SPI CS channel is not used we define a default one
106100
#define BOARD_SPI_OWN_SS SPI_CHANNELS_NUM
107101

108102
#define SS BOARD_SPI_DEFAULT_SS
109-
#define MOSI 11 // Default for Arduino connector compatibility
110-
#define MISO 12 // Default for Arduino connector compatibility
111-
#define SCLK 13 // Default for Arduino connector compatibility
103+
#define MOSI 11
104+
#define MISO 12
105+
#define SCLK 13
112106
#define SCK SCLK
113107

114108
//I2C Definitions
115-
#define SDA 14 // Default for Arduino connector compatibility
116-
#define SCL 15 // Default for Arduino connector compatibility
109+
#define SDA 14
110+
#define SCL 15
117111

118112
//Timer Definitions
119113
//Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
120-
#define TIMER_TONE TIMx
121-
#define TIMER_UART_EMULATED TIMx
114+
#define TIMER_TONE TIM6
115+
#define TIMER_UART_EMULATED TIM7
122116

123117
//Do not use basic timer: OC is required
124-
#define TIMER_SERVO TIMx //TODO: advanced-control timers don't work
118+
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
125119

126-
#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3
120+
#define DEBUG_UART ((USART_TypeDef *) USART3)
127121

128122
// UART Emulation (uncomment if needed, required TIM1)
129123
//#define UART_EMUL_RX PYxx // PinName used for RX
130124
//#define UART_EMUL_TX PYxx // PinName used for TX
131125

132126
// Serial Pin Firmata
133-
#define PIN_SERIAL_RX Dx
134-
#define PIN_SERIAL_TX Dx
135-
// Define as many PIN_SERIALX than desired
136-
//#define PIN_SERIAL1_RX Dx
137-
//#define PIN_SERIAL1_TX Dx
138-
//...
127+
#define PIN_SERIAL_RX 76
128+
#define PIN_SERIAL_TX 77
129+
#define PIN_SERIAL1_RX 0
130+
#define PIN_SERIAL1_TX 1
131+
#define PIN_SERIAL2_RX 52
132+
#define PIN_SERIAL2_TX 53
139133

140134
#ifdef __cplusplus
141135
} // extern "C"
@@ -147,8 +141,8 @@ enum {
147141
#ifdef __cplusplus
148142
// declare here as many UART objects than defined in variant.cpp
149143
extern HardwareSerial Serial;
150-
//extern HardwareSerial SerialX;
151-
//...
144+
extern HardwareSerial Serial1;
145+
extern HardwareSerial Serial2;
152146

153147
// These serial port names are intended to allow libraries and architecture-neutral
154148
// sketches to automatically default to the correct port name for a particular type

0 commit comments

Comments
 (0)