Implement `free()` method
Sh3Rm4n opened this issue · comments
In the case I understood the API correctly, it is currently not possible to retrieve the peripheral consumed with Can::new
associated with the Instance
trait
Line 49 in f4d5d96
To retrieve the peripheral, maybe a free()
method should be implemented like that:
diff --git a/src/lib.rs b/src/lib.rs
index 2584107..f589e00 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -470,6 +470,10 @@ where
pub fn split(self) -> (Tx<I>, Rx<I>) {
unsafe { (Tx::conjure(), Rx::conjure()) }
}
+
+ pub fn free(self) -> I {
+ self.instance
+ }
}
impl<I: FilterOwner> Can<I> {
This is probably not enough, I guess. I have only glanced over the implementation, but I imagine, that the peripheral has to be deconfigured to safely free it.
Sounds reasonable to have this, yeah. I'm not entirely sure what free
should do exactly, since some stuff is up to the HAL (like turning off the clock).
Because free
in the HAL is usually about freeing the consumed pins, it has to wrap this free function anyways, so leave it up entirely to the HAL?
Yeah, that could work