teensy4_pins/
lib.rs

1//! Hardware pins for the Teensy 4.0, 4.1 and MicroMod boards
2//!
3//! `teensy4-pins` is designed to the [`imxrt-iomuxc`] crate. The pins API constrains
4//! the processor pads to the ones that are available on the Teensy 4.0, 4.1 and MicroMod. It also
5//! exposes type aliases that simplify pin identification in the type system.
6//!
7//! [`imxrt-iomuxc`]: https://docs.rs/imxrt-iomuxc/0.1/imxrt_iomuxc/
8//!
9//! Note that this pin API is optional. You are free to configure the pins using the
10//! pad identifiers, instead of the physical pin identifiers. Pads are available directly
11//! from the `imxrt-iomuxc` crate.
12//!
13//! # Teensy 4.0
14//!
15//! To acquire Teensy 4.0 pins, call `t40::from_pads` and provide all
16//! of the processor pads:
17//!
18//! ```
19//! use teensy4_pins::t40;
20//! # use imxrt_iomuxc::imxrt1060::Pads;
21//!
22//! let pads = // Handle to all processor pads
23//!     # unsafe { Pads::new() };
24//! let pins = t40::from_pads(pads);
25//! ```
26//!
27//! # Teensy 4.1
28//!
29//! The approach is the same as the Teensy 4.0, replacing `t40` with `t41`:
30//!
31//! ```
32//! use teensy4_pins::t41;
33//! # use imxrt_iomuxc::imxrt1060::Pads;
34//!
35//! let pads = // Handle to all processor pads
36//!     # unsafe { Pads::new() };
37//! let pins = t41::from_pads(pads);
38//! ```
39//!
40//! # Teensy MicroMod
41//!
42//! The approach is the same as the Teensy 4.0, replacing `t40` with `tmm`:
43//!
44//! ```
45//! use teensy4_pins::tmm;
46//! # use imxrt_iomuxc::imxrt1060::Pads;
47//!
48//! let pads = // Handle to all processor pads
49//!     # unsafe { Pads::new() };
50//! let pins = tmm::from_pads(pads);
51//! ```
52//!
53//! # Pin configuration
54//!
55//! Once you have your pad resources, you can configure pull ups, pull downs, and other pad
56//! characteristics. See the [`Config`] documentation for all supported features. Use
57//! [`configure`] to apply the settings.
58//!
59//! For example, here's a pull down on pin 7 and an pull up, open drain on pin 9:
60//!
61//! ```no_run
62//! use teensy4_pins::{t40, Config, configure, PullKeeper, OpenDrain};
63//! # use imxrt_iomuxc::imxrt1060::Pads;
64//!
65//! const P7_CONFIG: Config = Config::zero()
66//!     .set_pull_keeper(Some(PullKeeper::Pulldown100k));
67//!
68//! const P9_CONFIG: Config = Config::zero()
69//!     .set_pull_keeper(Some(PullKeeper::Pullup22k))
70//!     .set_open_drain(OpenDrain::Enabled);
71//!
72//! let pads = // Handle to all processor pads
73//!     # unsafe { Pads::new() };
74//! let mut pins = t40::from_pads(pads);
75//!
76//! configure(&mut pins.p7, P7_CONFIG);
77//! configure(&mut pins.p9, P9_CONFIG);
78//! ```
79//!
80//! # Safety
81//!
82//! The safe APIs expect to work on the only instance of the processor pads. If you don't have that
83//! available, or you need more flexibility, use the unsafe [`t40::Pin::new`](t40::Pins::new()),
84//! [`t41::Pins::new`](t41::Pins::new()), or [`tmm::Pins::new`](tmm::Pins::new()) constructor methods
85//! to create an instance that may be aliasing another handle to the pads or pins.
86
87#![no_std]
88
89pub mod common;
90pub mod t40;
91pub mod t41;
92pub mod tmm;
93
94mod iomuxc {
95    pub use imxrt_iomuxc::imxrt1060::*;
96    pub use imxrt_iomuxc::ErasedPad;
97}
98
99pub use imxrt_iomuxc;
100
101pub use imxrt_iomuxc::{
102    configure, Config, DriveStrength, Hysteresis, OpenDrain, PullKeeper, SlewRate, Speed,
103};