46 lines
995 B
Rust
46 lines
995 B
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
use panic_halt as _;
|
|
|
|
use cortex_m::peripheral::syst;
|
|
use cortex_m_rt::entry;
|
|
|
|
use ch57x_pac;
|
|
|
|
#[entry]
|
|
fn main() -> ! {
|
|
let core_peripherals = cortex_m::Peripherals::take().unwrap();
|
|
let peripherals = ch57x_pac::Peripherals::take().unwrap();
|
|
|
|
let mut systick = core_peripherals.SYST;
|
|
|
|
systick.set_clock_source(syst::SystClkSource::Core);
|
|
systick.set_reload(8_000_000);
|
|
systick.clear_current();
|
|
|
|
systick.enable_counter();
|
|
|
|
let ch57x_sys = peripherals.SYS;
|
|
|
|
/* PB0: LED, data set to 1 */
|
|
ch57x_sys.r32_pb_out__r8_slv_rd_data.modify(|r, w| unsafe {
|
|
w.bits(r.bits() | 0x01)
|
|
});
|
|
|
|
/* PB0: LED, direction set to output */
|
|
ch57x_sys.r32_pb_dir.modify(|r, w| unsafe {
|
|
w.bits(r.bits() | 0x01)
|
|
});
|
|
|
|
loop {
|
|
while !systick.has_wrapped() {
|
|
}
|
|
|
|
/* Toggle LED */
|
|
ch57x_sys.r32_pb_out__r8_slv_rd_data.modify(|r, w| unsafe {
|
|
w.bits(r.bits() ^ 0x01)
|
|
});
|
|
}
|
|
}
|