Skip to content

Improved implementation in terms of creating all Serial objects available, for a given MCU. (#91) #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cores/arduino/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void HardwareSerial::setHandler(void *handler)
#endif

#if defined(HAVE_HWSERIAL6)
HardwareSerial Serial6(USART6);
HardwareSerial Serial6(UART6);
#endif

#if defined(HAVE_HWSERIAL7)
Expand Down
48 changes: 16 additions & 32 deletions cores/arduino/WSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,45 +67,29 @@
#endif /* !HWSERIAL_NONE && SERIAL_UART_INSTANCE */


#if defined(ENABLE_HWSERIAL1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to remove the definition of ENABLE_HWSERIALx here for it to take effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, maybe this is a “too fast” workaround,... it would be best to edit all the “variant_CH32xxx.h” files and change the definitions in them '#define SERIAL_UART_INSTANCE 1' to '#define SERIAL_UART_INSTANCE “n”' where “n” is the number of available U(S)ART for a given MCU.

#if defined(USART1_BASE)
#define HAVE_HWSERIAL1
#endif
#if defined(USART1_BASE)
#define HAVE_HWSERIAL1
#endif
#if defined(ENABLE_HWSERIAL2)
#if defined(USART2_BASE)
#define HAVE_HWSERIAL2
#endif
#if defined(USART2_BASE)
#define HAVE_HWSERIAL2
#endif
#if defined(ENABLE_HWSERIAL3)
#if defined(USART3_BASE)
#define HAVE_HWSERIAL3
#endif
#if defined(USART3_BASE)
#define HAVE_HWSERIAL3
#endif
#if defined(ENABLE_HWSERIAL4)
#if defined(USART4_BASE) || defined(UART4_BASE)
#define HAVE_HWSERIAL4
#endif
#if defined(USART4_BASE) || defined(UART4_BASE)
#define HAVE_HWSERIAL4
#endif
#if defined(ENABLE_HWSERIAL5)
#if defined(UART5_BASE)
#define HAVE_HWSERIAL5
#endif
#if defined(UART5_BASE)
#define HAVE_HWSERIAL5
#endif
#if defined(ENABLE_HWSERIAL6)
#if defined(UART6_BASE)
#define HAVE_HWSERIAL6
#endif
#if defined(UART6_BASE)
#define HAVE_HWSERIAL6
#endif
#if defined(ENABLE_HWSERIAL7)
#if defined(UART7_BASE)
#define HAVE_HWSERIAL7
#endif
#if defined(UART7_BASE)
#define HAVE_HWSERIAL7
#endif
#if defined(ENABLE_HWSERIAL8)
#if defined(UART8_BASE)
#define HAVE_HWSERIAL8
#endif
#if defined(UART8_BASE)
#define HAVE_HWSERIAL8
#endif

#endif
Expand Down