Skip to content

Various improvements in all parts#78

Merged
thomasw04 merged 3 commits into
mainfrom
features/various
May 12, 2026
Merged

Various improvements in all parts#78
thomasw04 merged 3 commits into
mainfrom
features/various

Conversation

@thomasw04
Copy link
Copy Markdown
Member

  • I2C and SPI error handling.
  • Scheduler fixes
  • and more

Copilot AI review requested due to automatic review settings May 12, 2026 14:25
Copy link
Copy Markdown
Contributor

@xarantolus xarantolus left a comment

Choose a reason for hiding this comment

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

Mostly looked at CAN, seems fine

Copy link
Copy Markdown
Contributor

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 refines several kernel and HAL subsystems, primarily standardizing device-driver error handling around POSIX errno values and adjusting scheduler real-time semantics (deadlines/budget handling).

Changes:

  • Standardize SPI/I2C/CAN HAL interfaces to return -PosixError_* and update Rust wrappers to convert C return codes via ok_or_err.
  • Add I2C transfer timeouts and bus recovery support end-to-end (C interface → Rust HAL → kernel driver API).
  • Update RT scheduling to use relative deadlines and new replenishment behavior; add a default thread finalizer when none is supplied.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/uapi/spi.rs Removes unused import in SPI uAPI wrapper.
src/uapi/i2c.rs Removes unused import in I2C uAPI wrapper.
src/uapi/sched.rs Tightens RT attribute validation (deadline vs budget/period).
src/types/queue.rs Switches queue APIs to kernel Result/kerr! errno-style errors and updates tests.
src/types.rs Exposes the queue module from types.
src/syscalls/sched.rs Validates RT attributes in the syscall boundary before creating threads.
src/sched/thread.rs Adds relative deadlines and changes RT server budget/deadline accounting.
src/sched/task.rs Adds a default thread finalizer when no finalizer is provided.
src/sched/rt.rs Changes EDF enqueue/put/pick behavior to align with new RT server fields.
src/sched.rs Adds thread_finalizer used as the default thread finalizer.
src/lib.rs Re-exports HAL API error module items at crate root.
src/error.rs Updates WARN macros to use kprintln! and keeps errno/error helpers.
src/drivers/spi.rs Makes SPI bus list push fallible via expect, and minor logging tweak.
src/drivers/i2c.rs Adds timeouts + bus recovery API to I2C driver; changes bus list push to expect.
src/drivers/can.rs Switches CAN driver error type to PosixError and adjusts exports.
machine/cortex-m/st/stm32l4/interface/spi.c Adds errno-mapped SPI error handling, busy-wait timeout, and better validation/timeout calc.
machine/cortex-m/st/stm32l4/interface/i2c.c Adds errno-mapped I2C errors, per-transfer timeout, and bus recovery helpers.
machine/cortex-m/st/stm32l4/interface/gpio.h Declares new open-drain output GPIO init helper.
machine/cortex-m/st/stm32l4/interface/gpio.c Implements gpio_init_output_od.
machine/cortex-m/st/stm32l4/interface/export.h Extends I2C transfer struct with timeout + new recovery function declarations.
machine/cortex-m/st/stm32l4/interface/can.c Converts CAN interface to POSIX errno returns with improved validation/mapping.
machine/cortex-m/src/stub/i2c.rs Updates stub signatures for timeouts and adds stub bus recovery APIs.
machine/cortex-m/src/stub/can.rs Converts stub CAN errors to PosixError.
machine/cortex-m/src/native/spi.rs Uses ok_or_err to map SPI C return codes into PosixError.
machine/cortex-m/src/native/sched.rs Cleans up unused Range import.
machine/cortex-m/src/native/i2c.rs Adds timeout field plumbing + bus recovery wrappers; uses ok_or_err.
machine/cortex-m/src/native/can.rs Uses ok_or_err and maps CAN C return codes into PosixError.
machine/cortex-m/build.rs Generates a C header (hal_api.h) for PosixError via cbindgen and includes it in HAL builds.
machine/api/src/lib.rs Moves POSIX error definitions into a dedicated error module and re-exports them.
machine/api/src/error.rs New module containing PosixError, Result, and helper conversion functions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sched.rs Outdated
Comment thread src/sched/thread.rs
Comment thread src/sched/thread.rs Outdated
Comment thread machine/cortex-m/st/stm32l4/interface/i2c.c
Comment thread src/drivers/spi.rs
Comment thread src/drivers/i2c.rs
@thomasw04 thomasw04 merged commit 99de9d3 into main May 12, 2026
9 checks passed
@thomasw04 thomasw04 deleted the features/various branch May 12, 2026 14:54
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.

3 participants