Skip to content

Commit efe4680

Browse files
authored
Update README.md
- added missing commas in Registers group. - fixed the number of bits of RANGE to 2. - Removed the text mentioning 'CR' since it has gone. - registers.s is ReadOnly. Changed the example line to use ".read()" rather than ".modify()".
1 parent ac5be9a commit efe4680

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

libraries/tock-register-interface/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ register_structs! {
4747

4848
// The type for a register can be anything. Conveniently, you can use an
4949
// array when there are a bunch of similar registers.
50-
(0x00C => array: [ReadWrite<u32>; 4])
51-
(0x01C => ... )
50+
(0x00C => array: [ReadWrite<u32>; 4]),
51+
(0x01C => ... ),
5252

5353
// Etc.
5454

@@ -178,7 +178,7 @@ register_bitfields! [
178178
// name OFFSET(shift) NUMBITS(num) [ /* optional values */ ]
179179

180180
// This is a two-bit field which includes bits 4 and 5
181-
RANGE OFFSET(4) NUMBITS(3) [
181+
RANGE OFFSET(4) NUMBITS(2) [
182182
// Each of these defines a name for a value that the bitfield can be
183183
// written with or matched against. Note that this set is not exclusive--
184184
// the field can still be written with arbitrary constants.
@@ -439,13 +439,13 @@ with a register of the type `ReadWrite<_, Control>` (or `ReadOnly/WriteOnly`,
439439
etc). For instance, if we have the bitfields and registers as defined above,
440440

441441
```rust
442-
// This line compiles, because CR and registers.cr are both associated with the
443-
// Control group of bitfields.
442+
// This line compiles, because registers.cr is associated with the Control group
443+
// of bitfields.
444444
registers.cr.modify(Control::RANGE.val(1));
445445

446-
// This line will not compile, because CR is associated with the Control group,
447-
// while registers.s is associated with the Status group.
448-
registers.s.modify(Control::RANGE.val(1));
446+
// This line will not compile, because registers.s is associated with the Status
447+
// group, not the Control group.
448+
let range = registers.s.read(Control::RANGE);
449449
```
450450

451451
## Naming conventions

0 commit comments

Comments
 (0)