-
Notifications
You must be signed in to change notification settings - Fork 156
fix docs+examples, work without reset, fixes #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/lib.rs
Outdated
//! | ||
//! `ResetValue` trait provides `reset_value` which returns the value of the `CR2` | ||
//! register after a reset. This value can be used to modify the | ||
//! writable bitfields of the `CR2` register or reset it in initial state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! writable bitfields of the `CR2` register or reset it in initial state. | |
//! writable bitfields of the `CR2` register or reset it to its initial state. |
src/lib.rs
Outdated
@@ -256,26 +262,30 @@ | |||
//! } | |||
//! ``` | |||
//! | |||
//! ## `reset` | |||
//! | |||
//! `ResetValue` trait provides `reset_value` which returns the value of the `CR2` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! `ResetValue` trait provides `reset_value` which returns the value of the `CR2` | |
//! The `ResetValue` trait provides `reset_value` which returns the value of the `CR2` |
src/generate/generic.rs
Outdated
@@ -165,16 +208,18 @@ impl<FI> R<bool, FI> { | |||
} | |||
|
|||
///Register writer | |||
/// | |||
///It is used as argument of closures in [`write`](Reg::write) and [`modify`](Reg::modify) methods of register |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///It is used as argument of closures in [`write`](Reg::write) and [`modify`](Reg::modify) methods of register | |
///Used as an argument to the closures in the [`write`](Reg::write) and [`modify`](Reg::modify) methods of the register |
src/generate/generic.rs
Outdated
@@ -112,6 +151,9 @@ where | |||
} | |||
|
|||
///Register/field reader | |||
/// | |||
///Result of call [`read`](Reg::read) method of register. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///Result of call [`read`](Reg::read) method of register. | |
///Result of the [`read`](Reg::read) method of a register. |
src/generate/generic.rs
Outdated
@@ -112,6 +151,9 @@ where | |||
} | |||
|
|||
///Register/field reader | |||
/// | |||
///Result of call [`read`](Reg::read) method of register. | |||
///Also it can be used in [`modify`](Reg::read) method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///Also it can be used in [`modify`](Reg::read) method | |
///Also it can be used in the [`modify`](Reg::read) method |
src/generate/generic.rs
Outdated
@@ -100,7 +125,21 @@ where | |||
{ | |||
///Modifies the contents of the register | |||
/// | |||
///See [modifying](https://rust-embedded.github.io/book/start/registers.html#modifying) in book. | |||
///Change only part of register: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///Change only part of register: | |
///E.g. to do a read-modify-write sequence to change parts of a register: |
src/generate/generic.rs
Outdated
///or | ||
///```ignore | ||
///periph.reg.modify(|_, w| w | ||
/// .field1() .bits(newfield1bits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// .field1() .bits(newfield1bits) | |
/// .field1().bits(newfield1bits) |
src/generate/generic.rs
Outdated
///```ignore | ||
///periph.reg.modify(|_, w| w | ||
/// .field1() .bits(newfield1bits) | ||
/// .field2() .set_bit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// .field2() .set_bit() | |
/// .field2().set_bit() |
src/generate/generic.rs
Outdated
///periph.reg.modify(|_, w| w | ||
/// .field1() .bits(newfield1bits) | ||
/// .field2() .set_bit() | ||
/// .field3() .variant(VARIANT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// .field3() .variant(VARIANT) | |
/// .field3().variant(VARIANT) |
src/generate/generic.rs
Outdated
///or write only fields you need: | ||
///```ignore | ||
///periph.reg.write(|w| w | ||
/// .field1() .bits(newfield1bits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// .field1() .bits(newfield1bits) | |
/// .field1().bits(newfield1bits) |
src/generate/generic.rs
Outdated
///```ignore | ||
///periph.reg.write(|w| w | ||
/// .field1() .bits(newfield1bits) | ||
/// .field2() .set_bit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// .field2() .set_bit() | |
/// .field2().set_bit() |
src/generate/generic.rs
Outdated
///periph.reg.write(|w| w | ||
/// .field1() .bits(newfield1bits) | ||
/// .field2() .set_bit() | ||
/// .field3() .variant(VARIANT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// .field3() .variant(VARIANT) | |
/// .field3().variant(VARIANT) |
src/generate/generic.rs
Outdated
@@ -68,7 +79,19 @@ where | |||
{ | |||
///Writes bits to `Writable` register | |||
/// | |||
///See [writing](https://rust-embedded.github.io/book/start/registers.html#writing) in book. | |||
///You can write raw bits into register: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///You can write raw bits into register: | |
///You can write raw bits into a register: |
src/generate/generic.rs
Outdated
///```ignore | ||
///periph.reg.write(|w| unsafe { w.bits(rawbits) }); | ||
///``` | ||
///or write only fields you need: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///or write only fields you need: | |
///or write only the fields you need: |
src/generate/generic.rs
Outdated
@@ -42,7 +42,16 @@ where | |||
{ | |||
///Reads the contents of `Readable` register | |||
/// | |||
///See [reading](https://rust-embedded.github.io/book/start/registers.html#reading) in book. | |||
///You can read contents of register in such way: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///You can read contents of register in such way: | |
///You can read the contents of a register in such way: |
src/generate/generic.rs
Outdated
///```ignore | ||
///let bits = periph.reg.read().bits(); | ||
///``` | ||
///or get contents of particular field of register. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///or get contents of particular field of register. | |
///or get the content of a particular field of a register. |
src/generate/generic.rs
Outdated
@@ -55,6 +64,8 @@ where | |||
U: Copy, | |||
{ | |||
///Writes the reset value to `Writable` register | |||
/// | |||
///After call this method register takes the initial state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///After call this method register takes the initial state | |
///Resets the register to its initial state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also should have a CHANGELOG entry mentioning the do improvements and examples. And I think the unsafe problem has snuck in in V0.15.0 because I was looking at weird "don't need unsafe here" and after removal "you do need unsafe here" warning/errors just yesterday; in that case we also need a CHANGELOG entry for this.
Done. Rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
bors r+ |
365: fix docs+examples, work without reset, fixes r=therealprof a=burrbull r? @therealprof Add more docs as @Disasm proposed. Restore `unsafe` on `W::bits()` I somewhere lost. Don't generate `write` if `reset_value` is not present. #258 Co-authored-by: Andrey Zgarbul <[email protected]>
Build succeeded |
r? @therealprof
Add more docs as @Disasm proposed.
Restore
unsafe
onW::bits()
I somewhere lost.Don't generate
write
ifreset_value
is not present. #258