From 1d97d4867f4daeb15312b396e3cc6d11ef832a3a Mon Sep 17 00:00:00 2001 From: Tanks Transfeld Date: Mon, 20 Mar 2023 14:37:28 +0100 Subject: [PATCH] Update embedded-workshop-book/src/uarte-implementation.md Co-authored-by: Jonathan Pallant --- embedded-workshop-book/src/uarte-implementation.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/embedded-workshop-book/src/uarte-implementation.md b/embedded-workshop-book/src/uarte-implementation.md index 66ece96..5ba4475 100644 --- a/embedded-workshop-book/src/uarte-implementation.md +++ b/embedded-workshop-book/src/uarte-implementation.md @@ -124,7 +124,11 @@ pub fn init() -> Result { ### 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.