Missing `pub` in register bitfields
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- rust
- 领域
- embedded-iot
调研方向
首先定位 issue 中引用的 SAU Sfsr 和 Sfar 位域声明,然后检查 SCB、SAU 及相关外设中的其他寄存器位域,确认是否存在相同的可见性模式。验证 crate 外部的调用方可以访问指定的状态位方法,并确认仍可通过现有的 read API 使用寄存器定义。
由索引模型根据 Issue 内容生成。
描述
In general, the definitions for a lot of the registers defined in SCB, SAU, etc., are rather deficient, but my current complaint is the Fault Status registers.
The ones defined in SCB are just defined as RW<u32>, so if you want to check individual bits, you have to define your own bitfield (or do the bit twiddling manually). Disappointing, but usable.
In SAU, the situation seems a little better: there are bitfield macros for Sfsr and Sfar! That sounds great, until you try to use them:
#[exception]
unsafe fn SecureFault() {
let peripherals = cortex_m::Peripherals::steal();
let sfsr = peripherals.SAU.sfsr.read();
if sfsr.invep() {
log::error!("INVEP");
}
}
which gets you
error[E0624]: method `invep` is private
--> <snip>/src/main.rs:122:13
|
122 | if sfsr.invep() {
| ^^^^^ private method
|
::: <snip>/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-0.7.7/src/peripheral/sau.rs:81:1
|
81 | / bitfield! {
82 | | /// Secure Fault Status Register description
83 | | #[repr(C)]
84 | | #[derive(Copy, Clone)]
... |
93 | | lserr, _: 7;
94 | | }
| |_- private method defined here
so you end up having to do the same thing (define your own bitfield or do the bit twiddling manually), only now you have to pull the value out of the existing bitfield with sfsr.0.
The sau crate doesn't do anything with this register, yet this bitfield definition makes it useless outside of the crate.
Fix
The register definitions could use a lot of love 🙁, but the obvious fix here is to make the fields in the bitfield pub, e.g.:
bitfield! {
/// Secure Fault Status Register description
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Sfsr(u32);
pub invep, _: 0;
pub invis, _: 1;
pub inver, _: 2;
pub auviol, _: 3;
pub invtran, _: 4;
pub lsperr, _: 5;
pub sfarvalid, _: 6;
pub lserr, _: 7;
}
// Ditto for all other `bitfield`s
- 主要语言
- Rust
- 星标
- 1k
- 派生
- 202
- 平均合并
- 1 天 4 小时
- 30 天内合并 PR
- 2
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rust-embedded/cortex-m 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
rust-embedded/cortex-m#651 · 5 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
rust-embedded/cortex-m#637 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 76/100
rust-embedded/cortex-m#511 · 2 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 55/100
rust-embedded/cortex-m#700 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 48/100
rust-embedded/cortex-m#695 ·
查看 rust-embedded/cortex-m 的全部 Issue
相似的 Issue
-
question
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
field-report
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
area:core
难度 2/5 1-3 小时 新手友好度 85/100
julian-hemmer/ypass#4 ·
-
难度 1/5 1 小时以内 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 62/100
davidkodar/klipp#3426 ·
维护者通常 1 天内回复