mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2025-01-10 00:05:45 +00:00
Update embedded-workshop-book/src/uarte-implementation.md
Co-authored-by: Jonathan Pallant <jonathan.pallant@ferrous-systems.com>
This commit is contained in:
parent
f0bf2ec6c3
commit
5fc64c53a2
1 changed files with 5 additions and 1 deletions
|
@ -124,7 +124,11 @@ pub fn init() -> Result<Board, ()> {
|
|||
|
||||
### Step 6: Implementing the `fmt::Write` trait
|
||||
|
||||
We can't just write to the `Uarte` instance. A simple write would write from flash memory. This does not work because of EasyDMA. We have to write a function that implements the `fmt::Write` trait. This trait guarantees that the buffer is fully and successfully written on a stack allocated buffer, before it returns.
|
||||
We want to implement the `fmt::Write` trait so that users can call `write!` on our Uarte object
|
||||
|
||||
When implementing this, we can't just write to the `Uarte` instance because a simple write of a string literal would try and read the string literal from flash memory. This does not work because the EasyDMA peripheral in the nRF52 series can only access RAM, not flash.
|
||||
|
||||
Instead our implementation must ensure all the strings are copied to a stack allocated buffer and that buffer is passed to the Uarte's `write` method.
|
||||
|
||||
✅ Add `use::core::fmt;` to your imports.
|
||||
|
||||
|
|
Loading…
Reference in a new issue