久久久国产精品视频袁燕,99re久久精品国产,亚洲欧美日韩国产综合v,天天躁夜夜躁狠狠久久,激情五月婷婷激情五月婷婷

快速體驗 Rust 嵌入式

學(xué)習(xí)新的語言,第一門課程當(dāng)然是輸出hello world。在這節(jié)你將能非常輕松得讓單片機運行一段打印hello wolrd 的程序。

準備

在閱讀本文之前,如果您還沒有配置基礎(chǔ)的Rust 開發(fā)環(huán)境,您可以閱讀 環(huán)境搭建

本文將基于主板 Py32_Rust_Dev 1.2 演示,在此前你需要準備基本的硬件設(shè)備如下

  • Py32_Rust_dev 1.2
  • Jlink V9(或 Stlink V2)+ SWD 下載線 需要準備的軟件環(huán)境如下:
  • Rust (night)
  • thumbv6m-none-eabi
  • probe-rs

獲取代碼

你需要獲取開發(fā)版 Py32_Rust_dev 的 Rust 驅(qū)動包,里面有芯片的 Rust 外設(shè)驅(qū)動以及提供了豐富的學(xué)習(xí)例程。

使用以下命令獲取源碼

git clone https://github.com/hysonglet/py32f030-hal.git

測試代碼

#![no_std]
#![no_main]

use py32f030_hal as _;

use {defmt_rtt as _, panic_probe as _};

#[cortex_m_rt::entry]
fn main_fun() -> ! {
    defmt::info!("hello world");
    loop {
        cortex_m::asm::wfe();
    }
}

燒錄和運行

使用以下命令即可快速編譯代碼,并且燒錄固件到芯片,然后可以在終端中看到 py32f030 的輸出打印內(nèi)容

cargo run --example hello_world
?  py32f030-hal git:(main) ? cargo r --example hello_world
warning: unused manifest key: dependencies.embedded-io-async.option
    Finished `dev` profile [optimized + debuginfo] target(s) in 0.16s
     Running `probe-rs run --chip PY32F030x8 target/thumbv6m-none-eabi/debug/examples/hello_world`
      Erasing ? [00:00:00] [###############################################################] 12.00 KiB/12.00 KiB @ 92.09 KiB/s (eta 0s )
  Programming ? [00:00:02] [##################################################################] 9.50 KiB/9.50 KiB @ 4.18 KiB/s (eta 0s )    Finished in 2.444s
INFO  hello world
└─ hello_world::__cortex_m_rt_main_fun @ examples/hello_world.rs:10

聲明:本內(nèi)容為作者獨立觀點,不代表電子星球立場。未經(jīng)允許不得轉(zhuǎn)載。授權(quán)事宜與稿件投訴,請聯(lián)系:editor@netbroad.com
覺得內(nèi)容不錯的朋友,別忘了一鍵三連哦!
贊 3
收藏 3
關(guān)注 14
成為作者 賺取收益
全部留言
0/200
成為第一個和作者交流的人吧