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
77
78
79
80
81
82
83
84
#![no_main]
#![no_std]
extern crate panic_semihosting;
use cortex_m::iprintln;
use cortex_m_rt::entry;
use cortex_m_semihosting::hprintln;
use hal::prelude::*;
use lpc55_hal as hal;
#[entry]
fn main() -> ! {
let hal = hal::new();
let mut anactrl = hal.anactrl;
let mut pmc = hal.pmc;
let mut syscon = hal.syscon;
let mut gpio = hal.gpio.enabled(&mut syscon);
let mut iocon = hal.iocon.enabled(&mut syscon);
let mut cp = unsafe { hal::raw::CorePeripherals::steal() };
let dp = unsafe { hal::raw::Peripherals::steal() };
hprintln!("traceclksel = {:x?}", dp.SYSCON.traceclksel.read().bits());
hprintln!("traceclkdiv = {:x?}", dp.SYSCON.traceclkdiv.read().bits());
hprintln!(
"traceclkdiv.div = {:x?}",
dp.SYSCON.traceclkdiv.read().div().bits()
);
hprintln!(
"traceclkdiv.halt = {:x?}",
dp.SYSCON.traceclkdiv.read().halt().bits()
);
// unsafe { dp.SYSCON.traceclksel.write(|w| w.sel().bits(0)); }
// unsafe { dp.SYSCON.traceclkdiv.write(|w| w.div().bits(1)); }
// iocon.set_pio_0_8_swo_func();
iocon.set_pio_0_10_swo_func();
// hprintln!("pio_0_8 = {:?}", iocon.get_pio_0_8_func());
// hprintln!("pio_0_10 = {:?}", iocon.get_pio_0_10_func());
// hprintln!("traceclkdiv = {:?}", dp.SYSCON.traceclkdiv.read().bits());
// let mut cp = unsafe { hal::raw::CorePeripherals::steal() };
let stim = &mut cp.ITM.stim[0];
// dbg!(unsafe { &(*hal::raw::TPIU::ptr()) }.sppr.read() );
// unsafe { &(*hal::raw::TPIU::ptr()) .sppr.write(2) };
// dbg!(unsafe { &(*hal::raw::TPIU::ptr()) }.sppr.read() );
// UM kind of says it's not enabled, but it actually is
// let iocon = iocon.enabled(&mut syscon);
// R = pio1_6
// G = pio1_7
// B = pio1_4
//
// on = low, off = high
let pins = hal::Pins::take().unwrap();
let mut red = pins
.pio1_6
.into_gpio_pin(&mut iocon, &mut gpio)
.into_output(hal::drivers::pins::Level::High); // start turned off
hal::ClockRequirements::default()
// .support_usbfs()
.system_frequency(12.MHz())
.configure(&mut anactrl, &mut pmc, &mut syscon)
.unwrap();
loop {
for _ in 0..10_000 {
red.set_low().unwrap();
}
iprintln!(stim, "led on");
// hprintln!("printed led on");
for _ in 0..10_000 {
red.set_high().unwrap();
}
iprintln!(stim, "led off");
}
}