Crate teensy4_bsp[][src]

Expand description

A Rust board support package (BSP) for the Teensy 4. Supports the Teensy 4.0 and 4.1 boards.

Peripherals are re-exported from the imxrt-hal hardware abstraction layer. See the HAL’s documentation for more information on creating and using peripherals.

Runtime

The teensy4-bsp use the cortex-m-rt crate to provide a runtime. Enable runtime support using the "rt" feature. To properly link your program, you must link with the t4link.x linker script.

The teensy4-bsp emits a cortex-m-rt-compatible linker script. The layout supports the i.MX RT’s boot requirements and advanced memory features. Specifically, the layout includes the image vector table (IVT) and boot data that’s necessary for i.MX RT processors. Additionally, the layout specifies the FlexSPI configuration block’s (FCB) FLASH location. Finally, the linker script places all instructions in ITCM, and all data in DTCM.

The teensy4-bsp provides its own reset hander. The custom reset handler

  • initalizes TCM regions
  • copies instructions into ITCM
  • copies the vector table into DTCM, and sets VTOR
  • set’s the CCM’s low-power setting
  • prepares memory caches

The reset handler then calls the cortex-m-rt entrypoint to finish memory initialization and invoke your program’s main().

Features

The teensy4-bsp supports these features:

FlagDescriptionDefault?
"systick"Registers a SYSTICK exception handler that’s called every millisecond
"usb-logging"Adds support for logging over USB with the log crate
"rt"Adds runtime support using cortex-m-rt
"rtic"Adds support for using the BSP peripherals with RTIC

Notes:

  • Combining "rtic" with "systick" is not supported. RTIC may try to register a SYSTICK exception handler, which conflicts with the BSP’s definition.

Proper RTIC support requires that you disable the BSP’s default features. You may combine "rtic" with either "rt" and "usb-logging".

[dependencies.teensy4-bsp]
default-features = false
features = ["rtic",  "rt"]
version = # ...

Pins

The BSP helps you convert all the i.MX RT processor pads into your Teensy 4’s pins. From these pins, you may construct peripherals and perform I/O. The Teensy 4.0 and 4.1 boards support many of the same pins; see the common module for those similar pins. To construct Teensy 4.0 or 4.1 pins, see the t40::into_pins and t41::into_pins for more information.

Examples

Turn on a Teensy 4.0’s LED:

use cortex_m::asm::wfi;
use teensy4_bsp as bsp;

use embedded_hal::digital::v2::OutputPin;

let peripherals = bsp::Peripherals::take().unwrap();
let pins = bsp::t40::into_pins(peripherals.iomuxc);
let mut led = bsp::configure_led(pins.p13);

loop {
    led.set_high().unwrap();
    wfi();
}

See more examples in the project’s repository.

Re-exports

pub use imxrt_hal as hal;

Modules

Common pinout

Teensy 4.0 specific APIs

Teensy 4.1 specific APIs

usbusb-logging

Teensy 4 USB, taken from the original Teensy 4 C libraries

Structs

SysTicksystick

A type that represents the system timer, SYSTICK

Enums

Available interrupts for this device

Functions

Configure the board’s LED

Returns the size of the heap, in bytes.

Returns a pointer to the start of the heap

Type Definitions

The LED