Skip to content

Add SoftwareSerial #627

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

Closed
wants to merge 18 commits into from
Closed

Add SoftwareSerial #627

wants to merge 18 commits into from

Conversation

armint
Copy link

@armint armint commented Sep 2, 2019

Summary

Add SoftwareSerial for STM32 boards.

This PR adds SoftwareSerial support for STM32 boards. The code was based on the SoftwareSerial implementation from the lpc176x arduino port and adapted for STM32. It uses the recently added HardwareTimer code for timing. The timer to be used can be defined in variant.h by defining TIMER_SERIAL. When no TIMER_SERIAL is defined it will use the simplest timer available.
Tested and working on STM32F446ZE and STM32F401RE. Works with existing SoftwareSerial example code. Tested at 9600 and 115200 baud by communicating with hardware serial interfaces and by logic analyser.

Fixes #267

Library can provide a precompiled library.
See precompiled option here:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format

The .a(archive)/.so(shared object) file must be located at: `src/{build.mcu}`

So the `build.mcu` could not contain `fpu` and `float-abi` options
and should only contain `cortex-mx` value.

Else Arduino IDE, instead of searching `cortex-mx`, searches
`cortex-mx -mfpu=fpv4-sp-d16 -mfloat-abi=hard` if floating-point
options are set.

`build.flags.fp` has been added to contain floating-point options if any.

Fixes stm32duino#606

Signed-off-by: Frederic Pillon <[email protected]>
@ABOSTM
Copy link
Contributor

ABOSTM commented Sep 4, 2019

Hi @armint,
Thank you for this pull request.
It looks really interresting, and I will make a deep review into your code.

Copy link
Contributor

@ABOSTM ABOSTM left a comment

Choose a reason for hiding this comment

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

In order to do like arduino with its SoftwareSerial,
could you move the files
from
cores\arduino
to
libraries\SoftwareSerial\

@armint
Copy link
Author

armint commented Sep 4, 2019

@ABOSTM Thank you for the review! I have modified the code to address the issues

@fpistm fpistm added this to the 1.7.0 milestone Sep 5, 2019
active_out = nullptr;
// When in half-duplex mode, we wait for HALFDUPLEX_SWITCH_DELAY bit-periods after the byte has
// been transmitted before allowing the switch to RX mode
} else if (tx_bit_cnt > 10 + HALFDUPLEX_SWITCH_DELAY) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that if 5 bits are required you need (

  • HALFDUPLEX_SWITCH_DELAY * OVERSAMPLE (old style when send() check if (--tx_tick_cnt <= 0))
  • (HALFDUPLEX_SWITCH_DELAY * OVERSAMPLE) - 1 (new style with if (--tx_tick_cnt < 0) )

@stas2z
Copy link
Contributor

stas2z commented Sep 6, 2019

Tested it with Nucleo F103
57600 cause errors

15:58:03.187 -> _S recv: 1111111111111111111111111 : 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 0D 0A 
15:58:03.319 -> MS recv: 111111111111111111111111"�� : 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 22 1A 14 
15:58:03.319 -> S2 recv: 1111111111111111111111111 : 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 0D 0A 

(where S is what was recieved from user console, MS - Software serial recieved from hardware serial, S2 - hardware serial received from software serial, serials are hardwired on the board (rx->tx))
at 115200 board doesn't boot at all

@ABOSTM
Copy link
Contributor

ABOSTM commented Sep 9, 2019

Hi @armint,
Thanks a lot for the job you have done. We really appreciate your contribution.
As it looks like you don't want to spend much more time on this, I takeover the SoftwareSerial.
So I created a new PR #645, based on your PR.
I keep you as the author as you made all the job, and you are welcome to comment on my PR if you want.

@fpistm
Copy link
Member

fpistm commented Sep 11, 2019

Closed by #645

@fpistm fpistm closed this Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abandoned No more work on this arduino compatibility enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SoftwareSerial needed
5 participants