lpc1114-test: try 8 leds, it's weird
This commit is contained in:
parent
78667968a8
commit
5e76bae67a
|
@ -2,5 +2,4 @@ source [find interface/ftdi/tigard.cfg]
|
||||||
source [find interface/ftdi/swd-resistor-hack.cfg]
|
source [find interface/ftdi/swd-resistor-hack.cfg]
|
||||||
source [find target/lpc11xx.cfg]
|
source [find target/lpc11xx.cfg]
|
||||||
|
|
||||||
adapter speed 2000
|
adapter speed 4000
|
||||||
adapter_khz 13500
|
|
||||||
|
|
|
@ -5,21 +5,28 @@ use panic_semihosting as _;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
|
|
||||||
|
const PINS: [u8; 8] = [1, 2, 4, 5, 6, 7, 8, 9];
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
let cp = cortex_m::Peripherals::take().unwrap();
|
let cp = cortex_m::Peripherals::take().unwrap();
|
||||||
|
|
||||||
// SAFETY: yes... ha ha ha... YES
|
// SAFETY: yes... ha ha ha... YES
|
||||||
let gpio0 = unsafe { &(*lpc111x_pac::Gpio0::ptr()) };
|
let p = unsafe { lpc111x_pac::Peripherals::steal() };
|
||||||
|
|
||||||
gpio0.dir().write(|w| w.io7().bit(true));
|
let gpio1: &lpc111x_pac::gpio1::RegisterBlock = &p.gpio1;
|
||||||
|
|
||||||
|
// SAFETY: it's fine i promise i read the datasheet and all the errata
|
||||||
|
gpio1.dir().write(|w| unsafe { w.bits(0b11_1111_0110) });
|
||||||
|
|
||||||
let mut delay = cortex_m::delay::Delay::new(cp.SYST, 12_000_000);
|
let mut delay = cortex_m::delay::Delay::new(cp.SYST, 12_000_000);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
gpio0.data().write(|w| w.data7().bit(true));
|
for pin in PINS {
|
||||||
delay.delay_ms(500);
|
gpio1
|
||||||
gpio0.data().write(|w| w.data7().bit(false));
|
.data()
|
||||||
delay.delay_ms(500);
|
.modify(|r, w| unsafe { w.bits(r.bits() ^ (1 << pin)) });
|
||||||
|
delay.delay_ms(500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue