2个版本
使用旧的Rust 2015
0.1.1 | 2019年3月23日 |
---|---|
0.1.0 | 2019年3月23日 |
#662 in 嵌入式开发
9MB
310K SLoC
CC2650设备支持crate
TI CC2650微控制器的嵌入式Rust访问API。
此crate提供了一个与CC2650及其外围设备交互的自自动生成的API。API是通过svd2rust和dslite2svd生成的。
用法
要使用,在Cargo.toml中
[dependencies]
cc2650 = "0.1"
rt
特性是可选的,并提供了对cortex-m-rt的支持
[dependencies]
cc2650 = { version = "0.1", features = ["rt"] }
示例
注意:以下示例假设您使用的是Rust 2018,即Rust >= 1.31。
use cc2650;
fn init() {
let device_peripherals = cc2650::Peripherals::take().unwrap();
// Configure GPIO pins for output, maximum strength
device_peripherals.IOC
.iocfg10
.modify(|_r, w| w.port_id().gpio().ie().clear_bit().iostr().max());
device_peripherals.IOC
.iocfg15
.modify(|_r, w| w.port_id().gpio().ie().clear_bit().iostr().max());
// Enable the PERIPH power domain and wait for it to be powered up
device_peripherals.PRCM.pdctl0.modify(|_r, w| w.periph_on().set_bit());
loop {
if device_peripherals.PRCM.pdstat0.read().periph_on().bit_is_set() {
break;
}
}
// Enable the GPIO clock
device_peripherals.PRCM.gpioclkgr.write(|w| w.clk_en().set_bit());
// Load settings into CLKCTRL and wait for LOAD_DONE
device_peripherals.PRCM.clkloadctl.modify(|_r, w| w.load().set_bit());
loop {
if device_peripherals.PRCM.clkloadctl.read().load_done().bit_is_set() {
break;
}
}
// Enable outputs
device_peripherals.GPIO
.doe31_0
.modify(|_r, w| w.dio10().set_bit().dio15().set_bit());
}
支持的设备
注意:CC26x0系列中还有其他设备可能也适用,但这些尚未经过测试。
生成
此crate是从由dslite2svd生成的SVD文件生成的。
许可
此项目在以下许可证下双许可
- Apache许可证版本2.0 (LICENSE-APACHE OR https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证 (LICENSE-MIT OR http://opensource.org/licenses/MIT)
依赖
~0.8–1.1MB
~17K SLoC