-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhoriz_tp.rs
76 lines (68 loc) · 2.32 KB
/
horiz_tp.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! 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.
#![no_std]
#![no_main]
#[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
#[cortex_m_rt::entry]
fn main() -> ! {
// Give the driver its hardware resources...
m4vga::take_hardware()
// ...select a display timing...
.configure_timing(&m4vga::timing::SVGA_800_600)
// ... and provide a raster callback.
.with_raster(
// 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.
vga.video_on();
// Spin forever!
loop {}
},
)
}
/// Wires up the PendSV handler expected by the driver.
#[cortex_m_rt::exception]
#[link_section = ".ramcode"]
fn PendSV() {
m4vga::pendsv_raster_isr()
}
/// Wires up the TIM3 handler expected by the driver.
#[interrupt]
#[link_section = ".ramcode"]
fn TIM3() {
m4vga::tim3_shock_isr()
}
/// Wires up the TIM4 handler expected by the driver.
#[interrupt]
#[link_section = ".ramcode"]
fn TIM4() {
m4vga::tim4_horiz_isr()
}