87: Have mdBook not wrap code snippets in "fn main() {}" r=therealprof a=adamgreen
This is the same change as in commit c5caa3b but for the instances I noticed in the rest of the chapters.
Before this change, clicking on the icon to copy a code snippet to the clipboard would result in something like:
```rust
fn main() {
// Exception handler for the SysTick (System Timer) exception
fn SysTick() {
// ..
}
}
```
After this change, the following would be copied to the clipboard instead:
```rust
// Exception handler for the SysTick (System Timer) exception
fn SysTick() {
// ..
}
```
Co-authored-by: Adam Green <adamgreen@users.noreply.github.com>
I switched to using 'transmitter' as an example in my a1c7244 commit
last night when the rest of the examples were plural. This commit adds
the 's' to make it consistent with the other examples.
90: Move "last_state = state" assignment r=adamgreig a=adamgreen
I believe that I have found a bug in the samples found in the concurrency chapter where the value of the `last_state` variable should be updated on each loop iteration but it is only updated on the detection of the first leading edge. For example:
```rust
loop {
let state = read_signal_level();
if state && !last_state {
last_state = state;
// DANGER - Not actually safe! Could cause data races.
unsafe { COUNTER += 1 };
}
}
```
I think that loop should actually be written as:
```rust
loop {
let state = read_signal_level();
if state && !last_state {
// DANGER - Not actually safe! Could cause data races.
unsafe { COUNTER += 1 };
}
last_state = state;
}
```
As the code exists today, I think it would detect the first leading edge, set last_state to true and then never be updated again which would also mean that it never detects another leading edge.
Co-authored-by: Adam Green <adamgreen@users.noreply.github.com>
I fixed a few more typos I noticed as I finished my first read through
of the Embedded Rust Book.
My editor also deleted some trailing white space from a few lines when
I saved out my typo fixes.
I believe that I have found a bug in the samples found in the
concurrency chapter where the value of the `last_state` variable
should be updated on each loop iteration but it is only updated
on the detection of the first leading edge. For example:
loop {
let state = read_signal_level();
if state && !last_state {
last_state = state;
// DANGER - Not actually safe! Could cause data races.
unsafe { COUNTER += 1 };
}
}
I think that loop should actually be written as:
loop {
let state = read_signal_level();
if state && !last_state {
// DANGER - Not actually safe! Could cause data races.
unsafe { COUNTER += 1 };
}
last_state = state;
}
As the code exists today, I think it would detect the first leading
edge, set last_state to true and then never be updated again which
would also mean that it never detects another leading edge.
83: Mention complexity benefits by using embedded-hal r=jamesmunns a=therealprof
Co-authored-by: Daniel Egger <daniel@eggers-club.de>
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
84: Added layer diagram for embedded-hal use r=jamesmunns a=therealprof
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
Co-authored-by: Daniel Egger <daniel@eggers-club.de>
Section 3 discusses how the MMU on desktop machines is used to protect
one **thread** from accessing the memory of another thread. On most
desktop operating systems, the MMU is used to protect one **process**
from accessing another process' memory. Threads within a process can
typically access the memory used by other threads in the same process.
This is the same change as in commit c5caa3b but for the instances I
noticed in the rest of the chapters.
Before this change, clicking on the icon to copy the code snippet to
the clipboard would result in:
```rust
fn main() {
// Exception handler for the SysTick (System Timer) exception
fn SysTick() {
// ..
}
}
```
After this change, the following is copied to the clipboard instead:
```rust
// Exception handler for the SysTick (System Timer) exception
fn SysTick() {
// ..
}
```
86: Chapter 2 updates r=therealprof a=adamgreen
This PR includes a few chapter 2 updates:
* Have mdBook not wrap code snippets in "fn main() {}" by setting language to "rust,ignore".
For example before the following would be copied to the clipboard:
```rust
fn main() {
// Exception handler for the SysTick (System Timer) exception
fn SysTick() {
// ..
}
}
```
After this change, the following is copied to the clipboard:
```rust
// Exception handler for the SysTick (System Timer) exception
fn SysTick() {
// ..
}
```
* I also fixed some code samples so that they compile without errors/warnings. The biggest change was to a SysTick sample in the "Memory Mapped Registers" section to properly setup the SysTick peripheral to countdown 1000 ticks.
* Some minor text updates.
Co-authored-by: Adam Green <adamgreen@users.noreply.github.com>
These fixes get code samples to compile without warnings. Other changes
include:
* Fix the SysTick code snippet on the "Memory Mapped Registers" page so
that it:
* Compiles without errors/warnings.
* Sets up the SysTick peripheral correctly for counting down 1000
ticks.
* Added a reminder in the "Semihosting" section about how to enable
semihosting in openOCD.
I noticed that when I tried to copy a code snippet into the clipboard
that it had some extra code text that I didn't see on the webpage. It
had wrapped the code snippet in a "fn main()" declaration. The code
window on the page also contained arrows in the upper-right corner for
expanding the code so that this hidden declaration could be seen. These
snippets aren't meant to be working samples so treating them as code to
be contained in main() often doesn't make sense. Changing the language
from "rust" to "rust,ignore" on these snippets causes mdBook to not
perform this wrapping.
For example before the following would be copied to clipboard:
```rust
fn main() {
// Exception handler for the SysTick (System Timer) exception
fn SysTick() {
// ..
}
}
```
After this change, we get the following copied to the clipboard:
```rust
// Exception handler for the SysTick (System Timer) exception
fn SysTick() {
// ..
}
```