… sorry, I’m having my first coffee of the morning, so I’m probably missing something: what would putting a RefCell inside a mutex buy you? You’re already ensuring unique access with the Mutex, how would you ever get multiple accesses to the RefCell?
I'm not sure! The critical section-ed Mutex prevents the multiple accesses; Note that you generally have an Option inside the RefCell, so you can initialize it as a static, then assign to it later. Maybe that's related
For copy types, you can use `Cell` instead. And of course, atomics for primitive types.
Ah! So this is an unfamiliarity issue on my part: I didn’t realize cortex_m::interrupt::Mutex has a different API than std::sync::Mutex or the various spinlock mutices. It deliberately only provides immutability because they want you to be able to choose how to do the interior mutability yourself. Now this all seems reasonable. Tricky!
(With hubris the interrupt stuff is abstracted away so you don’t need to access stuff this way, hence at least some of that unfamiliarity.)
I appreciate the insight! Forgot to mention it was that Mutex. Of note, the syntax is kind of messy (Especially the access syntax, which I omitted), but it's not so bad with macros.