Created
January 12, 2021 03:58
-
-
Save 9names/5af3df955d341cf750b4ac16b27ec87a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![no_std] | |
#![no_main] | |
use panic_halt as _; | |
use bl602_hal as hal; | |
use hal::{ | |
clock::{self, SysclkFreq, UART_PLL_FREQ}, | |
serial::{Serial, Config}, | |
pac, | |
prelude::*, | |
}; | |
#[riscv_rt::entry] | |
fn main() -> ! { | |
let dp = pac::Peripherals::take().unwrap(); | |
let mut parts = dp.GLB.split(); | |
// enable clock | |
let clocks = clock::Strict::new() | |
.use_pll(40_000_000u32.Hz()) | |
.sys_clk(SysclkFreq::Pll160Mhz) | |
.uart_clk(UART_PLL_FREQ.Hz()) | |
.freeze(&mut parts.clk_cfg); | |
let pin16 = parts.pin16.into_uart_sig0(); | |
let pin7 = parts.pin7.into_uart_sig7(); | |
let mux0 = parts.uart_mux0.into_uart0_tx(); | |
let mux7 = parts.uart_mux7.into_uart0_rx(); | |
let mut serial = Serial::uart0( | |
dp.UART, | |
Config::default().baudrate(115274.Bd()), | |
((pin16, mux0), (pin7, mux7)), | |
clocks | |
); | |
loop { | |
serial.try_write(b'R').ok(); | |
while !serial.try_flush().is_ok(){}; | |
serial.try_write(b'U').ok(); | |
while !serial.try_flush().is_ok(){}; | |
serial.try_write(b'S').ok(); | |
while !serial.try_flush().is_ok(){}; | |
serial.try_write(b'T').ok(); | |
while !serial.try_flush().is_ok(){}; | |
serial.try_write(b'\r').ok(); | |
while !serial.try_flush().is_ok(){}; | |
serial.try_write(b'\n').ok(); | |
while !serial.try_flush().is_ok(){}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment