feat(uart): UART (SCI) driver implementation and host unit tests #80

Merged
hoogv merged 1 commit from feat/79-uart-driver into dev 2026-07-23 11:34:58 +00:00
hoogv commented 2026-07-23 11:30:58 +00:00 (Migrated from codeberg.org)

Description

Adds hal/mss/uart/hal_uart.c/.h — the UART (SCI) driver: baud/parity/stop-bit init (TRM-derived SCIBAUD divisor formula against the 200MHz VCLK), blocking transmit/receive with bounded ready-poll timeouts, IRQ source enable/disable/priority, and the four instance/priority-line raw handlers decoding SCIFLR to a weak, application-overridable hal_uart_irq_handler() hook. Self-contained — no cross-module dependency, unlike ESM's VIM calls.

Why

Continues the driver-implementation phase started by GPIO (#75/#76) and ESM (#77/#78).

Closes #79

Type of Change

  • New feature

Impact Assessment

  • Functional impact: None — self-contained addition alongside the already-landed GPIO/ESM drivers.
  • Regulatory impact: None.
  • QMS impact: None.
  • Risk impact: No — existing risk coverage sufficient.

Testing

  • CI pipeline passes (compile, unit tests, integration tests, static analysis)
  • Manually tested: built and ran testing/mss/unit/hal_functionality/test_uart_functional locally (24 test cases, 104 assertions, all passing) alongside the full existing ctest suite (189/189 passing, no regressions); ran a full MISRA C:2025 pass (0 unsuppressed findings, -DENABLE_UART_MODULE added); reformatted and re-verified against the exact clang-format 18.1.3 the CI runner uses (pulled from the ccstudio image directly) before pushing, to avoid the version-mismatch fixup GPIO's PR needed; sanity-checked by changing the baud-divisor adjustment from -1 to -2, confirming the test suite fails (3 assertions), then reverting.
  • No regressions observed in related areas

PR Size

  • XL (> 300 lines) — justification required below

Size justification / exemption (if L or XL):

965 raw lines across 6 files, all hand-reviewed (no mechanically-generated content). Not split further — the driver (hal_uart.c/.h, 505 lines) and its comprehensive Catch2 spec (test_uart.c, 453 lines, covering both instances, every parity/stop-bit combination, and all four IRQ handlers) don't decompose into independently-reviewable sub-PRs, same rationale as ESM's PR (#78).

Checklist

  • Commit messages follow type(scope): description convention with Relates to #<issue> footer
  • PR template filled in completely
  • No unverified external binaries introduced (see QMS-GITFLOW-001 Binary Security section)
  • All commits leave the codebase in a compilable, passing-tests state (Commit Integrity Rule)

Summary

  • hal/mss/uart/hal_uart.c/.h: UART driver (init/baud derivation, blocking TX/RX, IRQ enable/disable/priority, IRQ handlers)
  • Cross-checked the baud-divisor formula against TI's own ti/drivers/uart/src/uartsci.c (uses a slightly different but numerically comparable expression) and this project's TRM citation (Section 27.7.11) — algebraically consistent, no correction needed
  • testing/mss/unit/hal_functionality/test_uart.c (+ CMakeLists.txt): Catch2 functional test suite
  • tools/misra/run_misra.sh: -DENABLE_UART_MODULE added
## Description Adds `hal/mss/uart/hal_uart.c`/`.h` — the UART (SCI) driver: baud/parity/stop-bit init (TRM-derived `SCIBAUD` divisor formula against the 200MHz VCLK), blocking transmit/receive with bounded ready-poll timeouts, IRQ source enable/disable/priority, and the four instance/priority-line raw handlers decoding `SCIFLR` to a weak, application-overridable `hal_uart_irq_handler()` hook. Self-contained — no cross-module dependency, unlike ESM's VIM calls. ## Why Continues the driver-implementation phase started by GPIO (#75/#76) and ESM (#77/#78). ## Related Issue Closes #79 ## Type of Change - [x] New feature ## Impact Assessment - **Functional impact:** None — self-contained addition alongside the already-landed GPIO/ESM drivers. - **Regulatory impact:** None. - **QMS impact:** None. - **Risk impact:** No — existing risk coverage sufficient. ## Testing - [x] CI pipeline passes (compile, unit tests, integration tests, static analysis) - [x] Manually tested: built and ran `testing/mss/unit/hal_functionality/test_uart_functional` locally (24 test cases, 104 assertions, all passing) alongside the full existing `ctest` suite (189/189 passing, no regressions); ran a full MISRA C:2025 pass (0 unsuppressed findings, `-DENABLE_UART_MODULE` added); reformatted and re-verified against the exact clang-format 18.1.3 the CI runner uses (pulled from the `ccstudio` image directly) before pushing, to avoid the version-mismatch fixup GPIO's PR needed; sanity-checked by changing the baud-divisor adjustment from `-1` to `-2`, confirming the test suite fails (3 assertions), then reverting. - [x] No regressions observed in related areas ## PR Size - [x] XL (> 300 lines) — justification required below **Size justification / exemption (if L or XL):** 965 raw lines across 6 files, all hand-reviewed (no mechanically-generated content). Not split further — the driver (`hal_uart.c`/`.h`, 505 lines) and its comprehensive Catch2 spec (`test_uart.c`, 453 lines, covering both instances, every parity/stop-bit combination, and all four IRQ handlers) don't decompose into independently-reviewable sub-PRs, same rationale as ESM's PR (#78). ## Checklist - [x] Commit messages follow `type(scope): description` convention with `Relates to #<issue>` footer - [x] PR template filled in completely - [x] No unverified external binaries introduced (see QMS-GITFLOW-001 Binary Security section) - [x] All commits leave the codebase in a compilable, passing-tests state (Commit Integrity Rule) ## Summary - `hal/mss/uart/hal_uart.c`/`.h`: UART driver (init/baud derivation, blocking TX/RX, IRQ enable/disable/priority, IRQ handlers) - Cross-checked the baud-divisor formula against TI's own `ti/drivers/uart/src/uartsci.c` (uses a slightly different but numerically comparable expression) and this project's TRM citation (Section 27.7.11) — algebraically consistent, no correction needed - `testing/mss/unit/hal_functionality/test_uart.c` (+ `CMakeLists.txt`): Catch2 functional test suite - `tools/misra/run_misra.sh`: `-DENABLE_UART_MODULE` added
hoogv added this to the Development project 2026-07-23 13:35:36 +00:00
hoogv self-assigned this 2026-07-23 13:36:10 +00:00
Sign in to join this conversation.
No reviewers
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
opendutchsolutions.public/hal_awr6843!80
No description provided.