Skip to content

Commit

Permalink
Merge pull request #133 from luojia65/luojia65/syterboot-part-2
Browse files Browse the repository at this point in the history
[rust] small fixes on syterkit::entry macro, documentation fixes and remove default members
  • Loading branch information
luojia65 authored Sep 26, 2024
2 parents 9e87243 + 2f654b5 commit bcd4b52
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 18 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ members = [
"rust/xtask",
"board/100ask-d1-h-rs",
]
default-members = ["rust/xtask"]
2 changes: 1 addition & 1 deletion board/100ask-d1-h-rs/src/bin/hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ use panic_halt as _;
use syterkit::{entry, println, Clocks, Peripherals};

#[entry]
fn main(p: Peripherals, c: Clocks) {
fn main(_p: Peripherals, _c: Clocks) {
println!("Hello World!");
}
2 changes: 1 addition & 1 deletion board/100ask-d1-h-rs/src/bin/init-dram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use panic_halt as _;
use syterkit::{entry, mctl, println, Clocks, Peripherals};

#[entry]
fn main(p: Peripherals, c: Clocks) {
fn main(_p: Peripherals, _c: Clocks) {
println!("DDR Init");
let ram_size = mctl::init();
println!("{}M 🐏", ram_size);
Expand Down
2 changes: 1 addition & 1 deletion board/100ask-d1-h-rs/src/bin/led-lightup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use panic_halt as _;
use syterkit::{entry, Clocks, Peripherals};

#[entry]
fn main(p: Peripherals, c: Clocks) {
fn main(p: Peripherals, _c: Clocks) {
// light up led
let mut pb5 = p.gpio.pb5.into_output();
pb5.set_high().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion board/100ask-d1-h-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use panic_halt as _;
use syterkit::{clock_dump, entry, println, show_banner, Clocks, Peripherals};

#[entry]
fn main(p: Peripherals, c: Clocks) {
fn main(p: Peripherals, _c: Clocks) {
// Display the bootloader banner.
show_banner();

Expand Down
21 changes: 8 additions & 13 deletions rust/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,18 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
quote!(
#[export_name = "main"]
pub fn main() {
let (p, c) = ::syterkit::allwinner_rt::__rom_init_params();
let (__p, __uart0, __tx, __rx) = ::syterkit::Peripherals::configure_uart0(p);
unsafe { __syterkit_macros__main(__p, c, __uart0, __tx, __rx) }
let (allwinner_rt_p, c) = ::syterkit::allwinner_rt::__rom_init_params();
let (p, uart0, tx, rx) = ::syterkit::Peripherals::configure_uart0(allwinner_rt_p);
let mut serial = ::syterkit::allwinner_hal::uart::Serial::new(uart0, (tx, rx), ::syterkit::allwinner_hal::uart::Config::default(), &c, &p.ccu);
unsafe {
*::syterkit::CONSOLE.lock() = Some(::syterkit::SyterKitConsole { inner: serial })
};
unsafe { __syterkit_macros__main(p, c) }
}
#[allow(non_snake_case)]
#[inline]
#(#attrs)*
#unsafety fn __syterkit_macros__main(
#args,
__uart0: ::syterkit::allwinner_rt::soc::d1::UART0,
__tx: ::syterkit::allwinner_hal::gpio::Function<'static, 'B', 8, 6>,
__rx: ::syterkit::allwinner_hal::gpio::Function<'static, 'B', 9, 6>
) #ret {
let mut __serial = ::syterkit::allwinner_hal::uart::Serial::new(__uart0, (__tx, __rx), ::syterkit::allwinner_hal::uart::Config::default(), &c, &p.ccu);
unsafe {
*::syterkit::CONSOLE.lock() = Some(::syterkit::SyterKitConsole { inner: __serial })
};
#unsafety fn __syterkit_macros__main(#args) #ret {
#(#stmts)*
}
)
Expand Down
2 changes: 2 additions & 0 deletions rust/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ pub struct Pads<'a> {
};
}

/// Prints to the standard output.
#[macro_export]
macro_rules! print {
($($arg:tt)*) => {
$crate::_print(core::format_args!($($arg)*));
}
}

/// Prints to the standard output, with a newline.
#[macro_export]
macro_rules! println {
() => ($crate::print!("\r\n"));
Expand Down

0 comments on commit bcd4b52

Please sign in to comment.