lpc1114-test: try 8 leds, it's weird

This commit is contained in:
Artemis Tosini 2024-03-26 22:43:47 +00:00
parent 78667968a8
commit 5e76bae67a
Signed by: artemist
GPG key ID: EE5227935FE3FF18
2 changed files with 14 additions and 8 deletions

View file

@ -2,5 +2,4 @@ source [find interface/ftdi/tigard.cfg]
source [find interface/ftdi/swd-resistor-hack.cfg]
source [find target/lpc11xx.cfg]
adapter speed 2000
adapter_khz 13500
adapter speed 4000

View file

@ -5,21 +5,28 @@ use panic_semihosting as _;
use cortex_m_rt::entry;
const PINS: [u8; 8] = [1, 2, 4, 5, 6, 7, 8, 9];
#[entry]
fn main() -> ! {
let cp = cortex_m::Peripherals::take().unwrap();
// 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);
loop {
gpio0.data().write(|w| w.data7().bit(true));
delay.delay_ms(500);
gpio0.data().write(|w| w.data7().bit(false));
delay.delay_ms(500);
for pin in PINS {
gpio1
.data()
.modify(|r, w| unsafe { w.bits(r.bits() ^ (1 << pin)) });
delay.delay_ms(500);
}
}
}