sys/arduino: add Serial over stdio support#17447
Merged
aabadie merged 5 commits intoRIOT-OS:masterfrom Jan 7, 2022
Merged
Conversation
24f890f to
c5940ad
Compare
c5940ad to
33c7423
Compare
Contributor
|
I tried this PR on arduino-mkrfox1200 and it works like a charm. Very nice! diff --git a/boards/sodaq-autonomo/include/arduino_board.h b/boards/sodaq-autonomo/include/arduino_board.h
index dbf200ed43..2f95638c75 100644
--- a/boards/sodaq-autonomo/include/arduino_board.h
+++ b/boards/sodaq-autonomo/include/arduino_board.h
@@ -33,9 +33,11 @@ extern "C" {
#define ARDUINO_LED (13)
/**
- * @brief On-board serial port mapping
+ * @brief On-board serial port mapping, stdio is used for Serial
*/
-#define ARDUINO_UART_DEV UART_DEV(0)
+#ifndef ARDUINO_UART_DEV
+#define ARDUINO_UART_DEV UART_UNDEF
+#endif
/**
* @brief Look-up table for the Arduino's digital pinsSo I'm +1 for adapting them as well (some arduino stuff could be shared there but that's another story). In a word, I'd ACK if you adapt them as well. |
If module `arduino_serial_stdio` is used and `ARDUINO_UART_DEV` is `UART_UNDEF`, the STDIO is used for `Serial`. It requires that the used `stdio` backend implements `stdio_available`.
33c7423 to
a7dc480
Compare
Contributor
Author
|
OK, I have rebased to have the changes of PR #17446. |
Contributor
|
Thanks !
Let's keep this for a follow-up. |
Contributor
Author
|
Thanks for reviewing and merging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
This PR provides the support for using the
Serialoverstdio_*On Arduino boards, the
Serialobject usesHardwareSerial)_Serial).However, the
Serialobject in RIOT always uses the UART interface defined byARDUINO_UART_DEV, usuallyUART_DEV(0). ThereforeSerialdoes not work for boards likefeather-m0andarduino-mkrwhich use the USB CDC interface directly. Since the STDIO already uses the USB CDC interface for such boards with the help of the modulestdio_cdc_acm, it is possible to realize theSerialobject for such boards on top of the STDIO.For this purpose the module
arduino_serial_stdiois introduced. If this module is enabled AND theARDUINO_UART_DEVis defined asUART_UNDEF, the STDIO is used forSerial. This allows either the use of the STDIO or the use of a UART interface if defined byARDUINO_UART_DEV.The module
arduino_serial_stdiois automatically enabled for boards usingstdio_cdc_acm. However, to actually useSerialvia STDIO,ARDUINO_UART_DEVhave to be defined additionallyUART_UNDEF. This is done by this PR forfeather-m0arduino-mkr.For
sodaqboards the situation is unclear, sinceARDUINO_UART_DEVis explicitly defined for these boards and it is not clear whether this is intentional.The use of
Serialover STDIO requires that the usedstdiobackend implements thestdio_availablefunction that was introduced by PR #17446.Testing procedure
feather-m0or anarduino-mkrboard and use the following example to test:std_uart, for exampleesp32-wroomand do the same:Issues/PRs references
Depends on PR #17446.