nrf52dk-sys
nrf52dk-sys copied to clipboard
WIP: Update to use cortex-m-rt
Hey!
I wanted to test this repo using the cortex-m-rt crate, here is what I came up with to make the blinky example work.
If I clean up all examples and update the readme/instructions, is this something you would like to have contributed?
/Max
(BTW, I'm super new to the Rust world, this is basically the first real changes I have made after reading a lot...)
Hey @maxekman, thanks for the contribution! I think this should be okay, the only concern that I have is that the Nordic Softdevice makes certain assumptions, like which interrupts/interrupt levels are reserved for use by the softdevice, and I am not sure if there is a way to prevent the cortex-m-rt and the nordic softdevice from interfering with eachother.
Here is what I found after a quick search: http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.sds%2Fdita%2Fsoftdevices%2Fs130%2Fprocessor_avail_interrupt_latency%2Fexception_mgmt_sd.html.
I am actually not too familiar with exactly what/how cortex-m-rt works. It would be nice to see these invariants covered either by code, or by documentation.
Thanks for the info, I’ll look into how the interrupts works. It may be possible to do something along these lines: https://github.com/japaric/cortex-m-rt/blob/master/examples/device.rs
Another option could be a custom device.x file: https://github.com/japaric/cortex-m-rt/blob/master/device.x
I’m also new to cortex-m-rt, but the library seems minimal enough to have as a dependency.
When reading more about the interrupts, it seems like only certain priorities are reserved, not the actual interrupt vectors. Does that seem correct?
Cortex-m-rt only seems to deal with the interrupt vectors not the priorities, which would put that level of protection in a HAL for the nrf52. I would guess it would affect implementing the embedded-hal timer traits for example.
Sounds good! I agree that a comment/note in the -sys
crate is good enough, and adding the checked restriction (or being careful when implementing) to the hal
crate should work.
:+1: from me, let me know when you are ready to merge.
I'm continuing development on this here: https://github.com/kamathba/nrf52dk-sys/tree/crate-updates
Have some experience with the nordic parts and using this as an exercise to learn some embedded rust. Might try having configs for softdevice / no-softdevice, and extend the example a bit. I actually still need to test on hardware.
Sounds good! I’ll close this as soon you open a (WIP) PR here.