Skip to content

Add SoftwareSerial library #32

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 15 commits into
base: main
Choose a base branch
from
Open

Add SoftwareSerial library #32

wants to merge 15 commits into from

Conversation

shadow578
Copy link
Owner

@shadow578 shadow578 commented Feb 9, 2025

Add the SoftwareSerial library.
Based on the library found in STM32duino, tho fully re-written and (imo) improved.

To-Do:

  • Full-Duplex mode (echo-back example)
  • Half-Duplex mode (e.g. Marlin TMC2208 communication)
  • dynamic baud-rate change
  • @ 8 MHz PCLK1: baud rates up to 9600 baud
  • @ 50 MHz PCLK1: baud rates up to 115200 baud
  • check compatibility (works with Marlin / TMCStepper)

Note:
this PR is a cleaned-up version of #30 (diff)

@shadow578 shadow578 force-pushed the add/softserial-clean branch from 3740abd to 55320b8 Compare February 9, 2025 10:04
@shadow578 shadow578 changed the title Add/softserial clean Add SoftwareSerial library Feb 9, 2025
@shadow578 shadow578 requested a review from Copilot May 5, 2025 08:56
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new SoftwareSerial library for the HC32F460, updates Timer0 functionality with a new frequency query method, and refines various build scripts, SPI driver warnings, and interrupt handling.

  • Added a new SoftwareSerial library with full- and half-duplex modes, examples, and README documentation.
  • Introduced get_actual_frequency() in Timer0 along with related clock divider conversion functions.
  • Updated build configuration, SPI warning placement, and an assertion in the interrupts module to improve overall reliability.

Reviewed Changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/platformio/platformio-build-arduino.py Updated core requirement list to include "timer0".
libraries/Timer0/src/Timer0.h Added get_actual_frequency() method with documentation.
libraries/Timer0/src/Timer0.cpp Implemented get_actual_frequency(), including prescaler and compare value extraction.
libraries/SoftwareSerial/src/SoftwareSerial.h New implementation for SoftwareSerial library.
libraries/SoftwareSerial/examples/SoftwareSerialExample/src/main.cpp Added an example showcasing basic SoftwareSerial usage.
libraries/SoftwareSerial/README.md New README with configuration options and usage details for SoftwareSerial.
libraries/SPI/src/SPI.h & SPI.cpp Adjusted warning message placement regarding untested SPI functionality.
cores/arduino/drivers/interrupts/interrupts.cpp Modified assertion logic in auto-assigned IRQ resigning.
Files not reviewed (2)
  • libraries/SoftwareSerial/examples/SoftwareSerialExample/.gitignore: Language not supported
  • libraries/SoftwareSerial/examples/SoftwareSerialExample/platformio.ini: Language not supported
Comments suppressed due to low confidence (2)

libraries/SPI/src/SPI.h:14

  • [nitpick] The warning regarding untested SPI functionality was removed from the header and added in the source file; ensure that this change in warning placement is deliberate for consistent user notification.
#warning "SPI on the HC32F460 has not been tested yet. See https://github.com/shadow578/framework-arduino-hc32f46x/pull/29"

cores/arduino/drivers/interrupts/interrupts.cpp:272

  • The assertion logic was inverted compared to the previous version. Please verify that checking for equality to no_handler is now correct and intended to ensure the IRQ was resigned.
CORE_ASSERT(ram_vector_table.irqs[irqn] == no_handler, "IRQ was not resigned before auto-assign resignment", return Error);

shadow578 and others added 2 commits May 5, 2025 10:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@shadow578 shadow578 force-pushed the add/softserial-clean branch from 5867c9b to d637cd4 Compare May 5, 2025 10:04
@shadow578 shadow578 requested a review from Copilot May 5, 2025 10:06
Copilot

This comment was marked as outdated.

@shadow578 shadow578 requested a review from Copilot May 5, 2025 11:12
Copilot

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@shadow578 shadow578 requested a review from Copilot May 5, 2025 11:14
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new SoftwareSerial library implementation with extended features and improvements over the STM32duino version while also including some ancillary code updates. Key changes include:

  • Addition of the SoftwareSerial library with full and half-duplex modes and dynamic baud-rate switching.
  • New API to retrieve the actual Timer0 frequency.
  • Updates in configuration files and minor fixes in SPI, interrupts, and example workflows.

Reviewed Changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/platformio/platformio-build-arduino.py Updated core requirements list order
libraries/Timer0/src/Timer0.h & Timer0.cpp Added new function for reporting Timer0 frequency
libraries/SoftwareSerial/src/*.h, examples, README.md Introduced the new SoftwareSerial library and associated docs
libraries/SPI/src/SPI.h & SPI.cpp Moved SPI testing warning from header to source
cores/arduino/drivers/interrupts/interrupts.cpp Corrected assert condition for IRQ auto-assignment
.github/workflows/build_examples.yaml Expanded build matrix search paths
Files not reviewed (2)
  • libraries/SoftwareSerial/examples/SoftwareSerialExample/.gitignore: Language not supported
  • libraries/SoftwareSerial/examples/SoftwareSerialExample/platformio.ini: Language not supported
Comments suppressed due to low confidence (2)

cores/arduino/drivers/interrupts/interrupts.cpp:272

  • The assert condition has been corrected to check that the IRQ has been properly resigned before auto-assignment. Verify that using '==' for 'no_handler' correctly reflects the intended state.
CORE_ASSERT(ram_vector_table.irqs[irqn] == no_handler, "IRQ was not resigned before auto-assign resignment", return Error);

libraries/SPI/src/SPI.h:14

  • [nitpick] The warning in SPI.h has been removed, while a similar warning is emitted in SPI.cpp. Ensure that shifting the warning solely to the source file is an intentional move to maintain consistency in documentation.
#warning "SPI on the HC32F460 has not been tested yet. See https://github.com/shadow578/framework-arduino-hc32f46x/pull/29"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant