Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
77 lines (68 sloc) 2.32 KB
//! Horizontal test pattern generator.
//! This produces alternating vertical stripes of white-black pixels at full
//! horizontal resolution. It's useful for checking signal integrity: the
//! pattern is easy to observe on a scope, and it generates all the
//! high-frequency transients we can expect in practice.
//! It's also about the simplest thing you can do with the library, so it serves
//! as a concise example.
#[cfg(feature = "panic-halt")]
extern crate panic_halt;
#[cfg(feature = "panic-itm")]
extern crate panic_itm;
use stm32f4;
use stm32f4::stm32f407::interrupt;
/// Demo entry point. Responsible for starting up the display driver and
/// providing callbacks.
#[allow(unused_parens)] // TODO bug in cortex_m_rt
fn main() -> ! {
// Give the driver its hardware resources...
// a display timing...
// ... and provide a raster callback.
// The raster callback is invoked on every horizontal retrace to
// provide new pixels. Here, we just scribble a test pattern into
// the target buffer.
|_, tgt, ctx, _| {
let mut pixel = 0xFF;
for t in &mut tgt[0..800] {
*t = pixel;
pixel ^= 0xFF;
ctx.target_range = 0..800; // 800 pixels now valid
ctx.repeat_lines = 599; // don't ask again this frame
// This closure contains the main loop of the program.
|vga| {
// Enable outputs. The driver doesn't do this for you in case
// you want to set up some graphics before doing so.
// Spin forever!
loop {}
/// Wires up the PendSV handler expected by the driver.
#[link_section = ".ramcode"]
fn PendSV() {
/// Wires up the TIM3 handler expected by the driver.
#[link_section = ".ramcode"]
fn TIM3() {
/// Wires up the TIM4 handler expected by the driver.
#[link_section = ".ramcode"]
fn TIM4() {
You can’t perform that action at this time.