Skip to content

Commit

Permalink
Try #128:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Feb 8, 2023
2 parents 8637e20 + bbd476d commit 38b76b8
Show file tree
Hide file tree
Showing 7 changed files with 334 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

Add support for the Teensy MicroMod. See the updated `board` APIs and
documentation for more information.

## [0.4.0] - 2023-01-05

**BREAKING** Update to imxrt-hal 0.5. This changes the driver APIs exposed by
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# teensy4-rs

A collection of crates for Rust development on the Teensy 4. Supports
both the Teensy 4.0 and 4.1 boards.
the following boards:

- Teensy 4.0
- Teensy 4.1
- Teensy MicroMod

[![Code Checks][]][1] [![crates.io][]][2] [![docs.rs]][3]

Expand Down
19 changes: 16 additions & 3 deletions src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//!
//! - Teensy 4.0 boards should use [`t40`].
//! - Teensy 4.1 boards should use [`t41`].
//! - Teensy MicroMod boards should use [`tmm`].
//!
//! The produced resources are nearly the same, except for the pins.
//!
Expand Down Expand Up @@ -133,8 +134,8 @@ pub use ral::Instances;

/// Acquire peripheral instances.
///
/// These are the resources supplied to [`t40`] or [`t41`]. They can
/// also be used to initialize your own drivers.
/// These are the resources supplied to [a resource constructor](crate::board#getting-started).
/// They can also be used to initialize your own drivers.
///
/// ```
/// use teensy4_bsp as bsp;
Expand Down Expand Up @@ -179,11 +180,15 @@ pub type T40Resources = Resources<pins::t40::Pins>;
///
/// Use [`t41`] to construct this. The pins are specific to the Teensy 4.1.
pub type T41Resources = Resources<pins::t41::Pins>;
/// Resources for a Teensy MicroMod.
///
/// Use [`tmm`] to construct this. The pins are specific to the Teensy MicroMod.
pub type TMMResources = Resources<pins::tmm::Pins>;

/// Resources constructed by the board.
///
/// The concrete `Pins` type depends on how this is constructed.
/// See [`T40Resources`] or [`T41Resources`] for more information.
/// See the various `*Resources` aliases for more information.
#[non_exhaustive]
pub struct Resources<Pins> {
/// Periodic interrupt timer channels.
Expand Down Expand Up @@ -596,3 +601,11 @@ pub fn t40(instances: impl Into<Instances>) -> T40Resources {
pub fn t41(instances: impl Into<Instances>) -> T41Resources {
prepare_resources(instances.into(), pins::t41::from_pads)
}

/// Create resources for the Teensy MicroMod board.
///
/// Note that the peripheral instances acquired by RTIC -- named `device` in the
/// `init::Context` object -- can be used as the argument to this function.
pub fn tmm(instances: impl Into<Instances>) -> TMMResources {
prepare_resources(instances.into(), pins::tmm::from_pads)
}
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//! A Rust board support package (BSP) for the Teensy 4. Supports the Teensy 4.0 and
//! 4.1 boards.
//! A Rust board support package (BSP) for the Teensy 4.
//!
//! `teensy4-bsp` supports the following boards:
//!
//! - Teensy 4.0
//! - Teensy 4.1
//! - Teensy MicroMod
//!
//! If you're just getting started with embedded Rust development on the Teensy 4, take
//! a look at [the `board` module](crate::board). This module provides pre-configured drivers
Expand Down
2 changes: 2 additions & 0 deletions teensy4-pins/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

Add Teensy MicroMod pins in the `tmm` module.

## [0.3.0] - 2023-01-05

**BREAKING** Update to imxrt-iomuxc 0.2. Pin aliases remain the same, but pad
Expand Down
24 changes: 19 additions & 5 deletions teensy4-pins/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Hardware pins for the Teensy 4.0 and 4.1 boards
//! Hardware pins for the Teensy 4.0, 4.1 and MicroMod boards
//!
//! `teensy4-pins` is designed to the [`imxrt-iomuxc`] crate. The pins API constrains
//! the processor pads to the ones that are available on the Teensy 4.0 and 4.1. It also
//! the processor pads to the ones that are available on the Teensy 4.0, 4.1 and MicroMod. It also
//! exposes type aliases that simplify pin identification in the type system.
//!
//! [`imxrt-iomuxc`]: https://docs.rs/imxrt-iomuxc/0.1/imxrt_iomuxc/
Expand Down Expand Up @@ -37,18 +37,32 @@
//! let pins = t41::from_pads(pads);
//! ```
//!
//! # Teensy MicroMod
//!
//! The approach is the same as the Teensy 4.0, replacing `t40` with `tmm`:
//!
//! ```
//! use teensy4_pins::tmm;
//! # use imxrt_iomuxc::imxrt1060::Pads;
//!
//! let pads = // Handle to all processor pads
//! # unsafe { Pads::new() };
//! let pins = tmm::from_pads(pads);
//! ```
//!
//! # Safety
//!
//! The safe APIs expect to work on the only instance of the processor pads. If you don't have that
//! available, or you need more flexibility, use the unsafe [`t40::Pin::new`](t40::Pins::new())
//! or [`t41::Pins::new`](t41::Pins::new()) constructor methods to create an instance
//! that may be aliasing another handle to the pads or pins.
//! available, or you need more flexibility, use the unsafe [`t40::Pin::new`](t40::Pins::new()),
//! [`t41::Pins::new`](t41::Pins::new()), or [`tmm::Pins::new`](tmm::Pins::new()) constructor methods
//! to create an instance that may be aliasing another handle to the pads or pins.
#![no_std]

pub mod common;
pub mod t40;
pub mod t41;
pub mod tmm;

mod iomuxc {
pub use imxrt_iomuxc::imxrt1060::*;
Expand Down
Loading

0 comments on commit 38b76b8

Please sign in to comment.