bors[bot] 5b0e8a1292 Merge #90
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>
2018-11-19 10:26:58 +00:00
2018-08-10 01:26:34 -05:00
2018-11-04 23:49:05 +01:00
2018-11-19 10:26:58 +00:00
2018-08-10 00:00:41 -05:00
2018-09-13 20:51:02 +02:00
2018-11-07 00:23:03 -08:00

[Work in Progress] - The Embedded Rust Book

Documentation on how to use the Rust Programming Language to develop firmware for bare metal (microcontroller) devices

This project is developed and maintained by the Resources team.

See the issue tracker for more details. This is a very early work in progress.

Online Copies of this Book

This book is located at https://docs.rust-embedded.org/book/

License

The Embedded Rust Book (this project) is distributed under the following licenses:

  • The code samples and free-standing Cargo projects contained within this book are licensed under the terms of both the MIT License and the Apache License v2.0.
  • The written prose contained within this book is licensed under the terms of the Creative Commons CC-BY-SA v4.0 license.

Copies of the licenses used by this project may also be found here:

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

Code of Conduct

Contribution to this crate is organized under the terms of the Rust Code of Conduct, the maintainer of this crate, the Resources team, promises to intervene to uphold that code of conduct.

Description
rust 嵌入式编程书籍的翻译,原书地址 https://rust-embedded.github.io/book/
Readme 2.5 MiB
Languages
JavaScript 55.3%
HTML 43.7%
CSS 1%