mirror of
https://github.com/nkbai/book.git
synced 2026-08-24 12:13:30 +08:00
Fix typos in chapter in chapter 4
This commit is contained in:
@@ -249,6 +249,6 @@ This is defintely a convenient way to store the state of the pin, but why do it
|
||||
|
||||
## Compile Time Functional Safety
|
||||
|
||||
Because we are enforcing our design constrains entirely at compile time, this incurs no runtime cost. It is impossible to set an output mode when you have a pin in an input mode. Instead, you must walk through the states by converting it to an output pin, and then setting the output mode. Because of this, there is no runtime penalty due to checking the current state before executing a function.
|
||||
Because we are enforcing our design constraints entirely at compile time, this incurs no runtime cost. It is impossible to set an output mode when you have a pin in an input mode. Instead, you must walk through the states by converting it to an output pin, and then setting the output mode. Because of this, there is no runtime penalty due to checking the current state before executing a function.
|
||||
|
||||
Also, because these states are enforced by the type system, there is no longer room for errors by consumers of this interface. If they try to perform an illegal state transition, the code will not compile!
|
||||
|
||||
@@ -91,7 +91,7 @@ impl Gpio {
|
||||
}
|
||||
```
|
||||
|
||||
However, this could allow us to modify certain registers that do not make sense. For example, what happens if we set the `output_mode` field when our GPIO is configured as an input? For some hardware, ths may not matter, but on some hardware, it could cause unexpected or undefined behavior.
|
||||
However, this could allow us to modify certain registers that do not make sense. For example, what happens if we set the `output_mode` field when our GPIO is configured as an input? For some hardware, this may not matter, but on some hardware, it could cause unexpected or undefined behavior.
|
||||
|
||||
This would allow us to reach states not defined by our state machine above: An output that is pulled low, or an input that was set high!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user