I want to set interrupt priorities for processor internal exceptions. The cortex_m
crate provides easy access to NVIC control registers. Specifically, there is a method that let me set priority for each interrupt.
let mut p = cortex_m::Peripherals::take().unwrap();
p.NVIC.set_priority(...);
set_priority
asks me to pass an argument specifying for which interrupt I intend to modify the priority. Say I want to change the priority for PendSV
. However, passing in cortex_m::peripheral::scb::Exception::PendSV
will not work because it does not implement a required trait bound.
I am developing on STM32F407VGT6 board, so I also looked in the stm32f4
crate, but I did not find any enum definition that can help either.
Should I write my own enum that implements the required trait so that it can specify interrupt numbers, or is there already some existing crate that can make it work?
According to the documentation of InterruptNumber
, implementing this Trait is responsibility of the PAC (peripheral access crate) provider. Looking at the stm32f4
crate, its latest release (0.12.1
as of time of writing) is still dependant on cortex-m >=0.5.8, <0.7
, meaning the developers likely haven't upgraded to the new API yet.
The old API makes use of the bare_metal::Nr
trait, which a few PACs stil rely on.
I found an example in the cortex-m-quickstart guide that makes use of the old NVIC API.
I recommend you go by the dependency requirements of your PAC and downgrade to cortex-m >=0.5.8, <0.7
and keep an eye out for updates to stm32f4
.