#teensy-4 #arm #cortex-m #board

no-std teensy4-pins

Helpers for configuring and using a Teensy 4's pins. Part of the teensy4-rs project

5 unstable releases

new 0.3.2 May 27, 2024
0.3.1 Feb 9, 2023
0.3.0 Jan 6, 2023
0.2.0 Dec 29, 2021
0.1.0 Oct 16, 2020

#1625 in Embedded development

Download history 26/week @ 2024-02-07 58/week @ 2024-02-14 94/week @ 2024-02-21 107/week @ 2024-02-28 76/week @ 2024-03-06 78/week @ 2024-03-13 76/week @ 2024-03-20 68/week @ 2024-03-27 82/week @ 2024-04-03 110/week @ 2024-04-10 98/week @ 2024-04-17 81/week @ 2024-04-24 53/week @ 2024-05-01 53/week @ 2024-05-08 60/week @ 2024-05-15 168/week @ 2024-05-22

341 downloads per month
Used in 6 crates (via teensy4-bsp)

MIT/Apache

47KB
573 lines

teensy4-pins

Hardware pins for the Teensy 4.0 and 4.1 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 exposes type aliases that simplify pin identification in the type system.

Note that this pin API is optional. You are free to configure the pins using the pad identifiers, instead of the physical pin identifiers. Pads are available directly from the imxrt-iomuxc crate.

See the API documentation for more information.

License: MIT OR Apache-2.0


lib.rs:

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, 4.1 and MicroMod. It also exposes type aliases that simplify pin identification in the type system.

Note that this pin API is optional. You are free to configure the pins using the pad identifiers, instead of the physical pin identifiers. Pads are available directly from the imxrt-iomuxc crate.

Teensy 4.0

To acquire Teensy 4.0 pins, call t40::from_pads and provide all of the processor pads:

use teensy4_pins::t40;

let pads = // Handle to all processor pads
    # unsafe { Pads::new() };
let pins = t40::from_pads(pads);

Teensy 4.1

The approach is the same as the Teensy 4.0, replacing t40 with t41:

use teensy4_pins::t41;

let pads = // Handle to all processor pads
    # unsafe { Pads::new() };
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;

let pads = // Handle to all processor pads
    # unsafe { Pads::new() };
let pins = tmm::from_pads(pads);

Pin configuration

Once you have your pad resources, you can configure pull ups, pull downs, and other pad characteristics. See the Config documentation for all supported features. Use configure to apply the settings.

For example, here's a pull down on pin 7 and an pull up, open drain on pin 9:

use teensy4_pins::{t40, Config, configure, PullKeeper, OpenDrain};

const P7_CONFIG: Config = Config::zero()
    .set_pull_keeper(Some(PullKeeper::Pulldown100k));

const P9_CONFIG: Config = Config::zero()
    .set_pull_keeper(Some(PullKeeper::Pullup22k))
    .set_open_drain(OpenDrain::Enabled);

let pads = // Handle to all processor pads
    # unsafe { Pads::new() };
let mut pins = t40::from_pads(pads);

configure(&mut pins.p7, P7_CONFIG);
configure(&mut pins.p9, P9_CONFIG);

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, t41::Pins::new, or tmm::Pins::new constructor methods to create an instance that may be aliasing another handle to the pads or pins.

Dependencies

~415KB