Skip to content

Commit

Permalink
demo: uart tx for v003
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed May 5, 2024
1 parent 9405001 commit 1d0c45e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions examples/ch32v003/src/bin/uart_tx.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]

use hal::delay::Delay;
use hal::gpio::{Level, Output};
use hal::println;
use hal::usart::UartTx;
use qingke::riscv;
use {ch32_hal as hal, panic_halt as _};

#[qingke_rt::entry]
fn main() -> ! {
hal::debug::SDIPrint::enable();
let mut config = hal::Config::default();
config.rcc = hal::rcc::Config::SYSCLK_FREQ_48MHZ_HSE;
let p = hal::init(config);

let mut uart = UartTx::new_blocking(p.USART1, p.PC0, Default::default()).unwrap();

println!("dev init ok");

uart.blocking_write(b"Hello, world!\r\n").unwrap();

let mut delay = Delay;

let mut led = Output::new(p.PD6, Level::Low, Default::default());
loop {
led.toggle();

uart.blocking_write(b"Hello, world!\r\n").unwrap();

delay.delay_ms(1000);
}
}

0 comments on commit 1d0c45e

Please sign in to comment.