Rename `udebug` feature to `ufmt`
Update the bare-metal crate to 1.0.0
The new crate version generates much cleaner code due to #[inline] annotations.
This is an API break, because the CriticalSection + Mutex mechanism changes
from exterior reference lifetime to interior reference lifetime management.
irq: Optimize interrupt save/restore
Avoid unnecessary mask and branch instructions.
The basic reasoning behind this is that all other flags in the SREG can
be clobbered without ill effects. The restore() function is an
optimization fence and the compiler is not allowed to make assumptions
about memory or SREG state after execution.
This avoids an `and` and a `breq` instruction or similar in every
critical section.
While at it, also introduce a better API for manual IRQ-flag management.
Remove all llvm_asm macros
Add basic documentation for beginners
Return the previous interrupt status upon disabling interrupts
This commit addresses #88 by returning a boolean which reflects the
previous state of the GIE flag upon disabling interrupts. This allows
`critical-section` to implement itself for AVR, while not breaking the
existing `avr-device` API.
Only emit inline-assembly when building for AVR
Make sure that we'll never emit AVR assembly on non-AVR targets.
Instead of failing the build, fail at runtime, to allow a potential
application testsuite to run even if those functions somehow get linked
in.
Signed-off-by: Rahix <rahix@rahix.de>
interrupt: Fix interrupt::free() reading wrong address
The SREG is at IO address 0x3F, not 0x35. Fix interrupt::free() to read
the correct register to make it work as advertised.
Signed-off-by: Rahix <rahix@rahix.de>
interrupt: Make interrupt::enable() unsafe
To bring this crate more in line with cortex-m, mark interrupt::enable()
as unsafe. This also fixes a soundness issue: When the function is
safe, one could call it inside a critical section in entirely safe rust.
This is problematic because lot's of code in critical sections relies on
the fact that interrupts are disabled and it thus can safely perform
non-atomic operations without anything interrupting it.
Signed-off-by: Rahix <rahix@rahix.de>
Use llvm_asm!() instead of asm!()
The asm!() feature was changed to a new syntax which this project did not yet
adopt. The old asm!() is now available as llvm_asm!(). Switch to that to
support nightly build.
See PR #27 for details.
Switch to a new design as outlined in #17
Signed-off-by: Rahix <rahix@rahix.de>