FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Make Serialx instance generic by fpistm · Pull Request #122 · stm32duino/Arduino_Core_STM32 · GitHub

Make Serialx instance generic - #122

Merged
fpistm merged 9 commits into
stm32duino:masterfrom
fpistm:genericSerial
Oct 6, 2017
Merged

Make Serialx instance generic#122
fpistm merged 9 commits into
stm32duino:masterfrom
fpistm:genericSerial

Conversation

fpistm commented Oct 4, 2017
edited
Loading

Copy link
Copy Markdown
Member

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:

// Define here Serial instance number to map on Serial generic name
#define SERIAL_UART_INSTANCE    x //ex: 2 for Serial2 (USART2)

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

fpistm added the enhancement New feature or request label Oct 4, 2017
fpistm self-assigned this Oct 4, 2017
fpistm requested review from a user and VVESTM October 4, 2017 07:55
fpistm added this to the Next release milestone Oct 4, 2017
fpistm force-pushed the genericSerial branch 2 times, most recently from e32c2c4 to f04a44e Compare October 4, 2017 12:33
fpistm added 8 commits October 6, 2017 10:29
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 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I tested on some boards and that seems to be OK.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL