Skip to content

Commit 402a26c

Browse files
committed
[Nucleo F429ZI] Disable Serial1/Serial2 by default
To save RAM space, Serial1 and Serial2 are disabled by default. To enable them add -DENABLE_SERIAL1 and/or -DENABLE_SERIAL2 Signed-off-by: Frederic.Pillon <[email protected]>
1 parent e6fcc14 commit 402a26c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Diff for: boards.txt

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Nucleo_144.menu.Nucleo_144_board.NUCLEO_F429ZI.build.variant=NUCLEO_F429ZI
3333
Nucleo_144.menu.Nucleo_144_board.NUCLEO_F429ZI.build.cmsis_lib_gcc=arm_cortexM4l_math
3434
#To enable USB add '-DUSBCON'
3535
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
36+
#To enable Serial1 (USART1 on PG9, PG14) add -DENABLE_SERIAL1
37+
#To enable Serial2 (USART2 on PD6, PD5) add -DENABLE_SERIAL2
3638
Nucleo_144.menu.Nucleo_144_board.NUCLEO_F429ZI.build.extra_flags=-DSTM32F429xx {build.usb_flags}
3739

3840

Diff for: variants/NUCLEO_F429ZI/variant.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,34 @@ const PinName digitalPin[] = {
133133
* UART objects
134134
*/
135135
HardwareSerial Serial(PD9, PD8); // Connected to ST-Link
136+
#ifdef ENABLE_SERIAL1
136137
HardwareSerial Serial1(PG9, PG14);
138+
#endif
139+
#ifdef ENABLE_SERIAL2
137140
HardwareSerial Serial2(PD6, PD5);
141+
#endif
138142

139143
void serialEvent() __attribute__((weak));
140144
void serialEvent() { }
141145

146+
#ifdef ENABLE_SERIAL1
142147
void serialEvent1() __attribute__((weak));
143148
void serialEvent1() { }
144-
149+
#endif
150+
#ifdef ENABLE_SERIAL2
145151
void serialEvent2() __attribute__((weak));
146152
void serialEvent2() { }
153+
#endif
147154

148155
void serialEventRun(void)
149156
{
150157
if (Serial.available()) serialEvent();
158+
#ifdef ENABLE_SERIAL1
151159
if (Serial1.available()) serialEvent1();
160+
#endif
161+
#ifdef ENABLE_SERIAL2
152162
if (Serial2.available()) serialEvent2();
163+
#endif
153164
}
154165

155166
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)