-
Notifications
You must be signed in to change notification settings - Fork 1k
Make Serialx instance generic #122
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
Merged
Merged
Conversation
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
e32c2c4
to
f04a44e
Compare
Usage example: PinNamepin_rx = pinmap_pin(USART1, PinMap_UART_RX); PinNamepin_tx = pinmap_pin(USART1, PinMap_UART_TX); Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
Previously Serialx instance was defined by the variant. It was not enough generic and flexible. With this patch, all available Serialx instance are handled dynamically. Where 'x' is the U(S)ART number. Currently, STM32 MCU could have 9 U(S)ART. Serial is the generic name used in Arduino sketches. Serial is now mapped to the Serialx instance linked to the com port in the variant.h (mainly one linked to ST-Link) Moreover this will simplify USB integration to map the SerialUSB. Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
When Serialx instanciation, check if it is the generic 'Serial' then set Rx/Tx pins if defined else get the pins of the first peripheral occurence in PinMap Anyway, Rx/Tx pins could be changed later using Serialx.setRx/setTx methods before call the Serialx.begin() Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
By default, UART_DEBUG is linked to Serial generic instance. So it is not required to define it. It could be redefined in the variant.h to print on another instance than Serial Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
As HardwareSerial is no more used in variant, use pins_arduino.h instead of Arduino.h Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
Signed-off-by: fpr <fabien.perroquin@wi6labs.com> Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
ghost
approved these changes
Oct 6, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on some boards and that seems to be OK.
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.
Previously Serialx instance was defined by the variant.
It was not enough generic and flexible.
With this patch, all available Serialx instance are handled dynamically.
Where 'x' is the U(S)ART number.
Currently, STM32 MCU could have up to 10 U(S)ART.
Serial is the generic name used in Arduino sketches.
Serial is now mapped to the Serialx instance linked to the com port in the variant.h (mainly one linked to ST-Link).
To define the generic Serial, define this in variant.h:
Moreover this will simplify USB integration to map the SerialUSB as Serial.
Menu has been review, 4 options:
Generic Serial (default): only the Serialx instance linked to the com port is available.
No Serial: Serial is disabled (useful for sketch which not use Serial)
Fisrt third: Instanciate the first third Serial instance (USART1 to 3)
All: Instantiate all available U(S)ART (up to 10)
SerialxEvent() are weak and could be redefined by the user at sketch level.
Depends of #121
Fixed #113