Skip to content
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

cpu/msp430: rework MSP430 x1xx periph drivers #19835

Merged
merged 2 commits into from
Jan 22, 2024
Merged

Conversation

maribu
Copy link
Member

@maribu maribu commented Jul 18, 2023

Contribution description

  • Move common code for USART (shared SPI / UART peripheral) to its own file and allow sharing the USART peripheral to provide both UART and SPI in round-robin fashion.
  • Configure both UART and SPI bus via a struct in the board's periph_conf.h
    • this allows allocating the two UARTs as needed by the use case
    • since both USARTs signals have a fixed connection to a single GPIO, most configuration is moved to the CPU
    • the board now only needs to decide which bus is provided by which USART

Note: Sharing an USART used as UART requires cooperation from the app:

  • If the UART is used in TX-only mode (no RX callback), the driver will release the USART while not sending
  • If the UART is used to also receive, the application needs to power the UART down while not expecting something to send. An spi_acquire() will be blocked while the UART is powered up.

Testing procedure

UART and SPI should still work

  • UART works still fine for stdio on my Olimex boards
  • SPI works fine according to the logic analyzer and the loopback test in tests/periph/spi

Issues/PRs references

Depends on and includes:

@github-actions github-actions bot added Platform: MSP Platform: This PR/issue effects MSP-based platforms Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports labels Jul 18, 2023
@maribu maribu added Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jul 18, 2023
@riot-ci
Copy link

riot-ci commented Jul 18, 2023

Murdock results

✔️ PASSED

407deab boards/olimex-msp430-h1611: uart_stdio @ 9600 Bd

Success Failures Total Runtime
8623 0 8623 11m:13s

Artifacts

@maribu maribu added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Jul 18, 2023
@github-actions github-actions bot added the Area: Kconfig Area: Kconfig integration label Dec 5, 2023
@maribu maribu changed the title cpu/msp430/x1xx: Add uart_config_t cpu/msp430: major cleanup Dec 6, 2023
@maribu maribu removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 6, 2023
@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Dec 6, 2023
@maribu maribu changed the title cpu/msp430: major cleanup cpu/msp430: rework MSP430 x1xx periph drivers Dec 6, 2023
@maribu maribu added State: waiting for other PR State: The PR requires another PR to be merged first CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet labels Dec 6, 2023
@github-actions github-actions bot removed Area: tests Area: tests and testing framework Area: Kconfig Area: Kconfig integration labels Dec 10, 2023
@maribu maribu removed the State: waiting for other PR State: The PR requires another PR to be merged first label Dec 10, 2023
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Looks good, static-tests has some nits though

@benpicco benpicco enabled auto-merge January 22, 2024 13:39
@benpicco benpicco added this pull request to the merge queue Jan 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 22, 2024
- Move common code for USART (shared SPI / UART peripheral) to its
  own file and allow sharing the USART peripheral to provide both
  UART and SPI in round-robin fashion.
- Configure both UART and SPI bus via a `struct` in the board's
  `periph_conf.h`
    - this allows allocating the two UARTs as needed by the use case
    - since both USARTs signals have a fixed connection to a single
      GPIO, most configuration is moved to the CPU
    - the board now only needs to decide which bus is provided by
      which USART

Note: Sharing an USART used as UART requires cooperation from the app:
- If the UART is used in TX-only mode (no RX callback), the driver
  will release the USART while not sending
- If the UART is used to also receive, the application needs to power
  the UART down while not expecting something to send. An
  `spi_acquire()` will be blocked while the UART is powered up.
@maribu maribu requested a review from miri64 as a code owner January 22, 2024 15:59
@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Jan 22, 2024
@maribu maribu enabled auto-merge January 22, 2024 15:59
@maribu maribu added this pull request to the merge queue Jan 22, 2024
Merged via the queue into RIOT-OS:master with commit 63ec7fc Jan 22, 2024
25 checks passed
@maribu maribu deleted the msp430 branch January 23, 2024 05:09
@maribu
Copy link
Member Author

maribu commented Jan 23, 2024

Thx :)

@MrKevinWeiss MrKevinWeiss added this to the Release 2024.01 milestone Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: MSP Platform: This PR/issue effects MSP-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants