Page 1 of 1

[nrf52] Module for register definitions like "stm"

Posted: Thu Oct 11, 2018 9:09 am
by kak
For the STM32 based boards, there's a module "stm", that allows direct access to processor registers.
Is there something like this also for the nrf port?
If not, where should I start to write one?

Re: [nrf52] Module for register definitions like "stm"

Posted: Thu Oct 11, 2018 9:28 am
by pfalcon
You can easily develop such support for any processor using uctypes module (http://docs.micropython.org/en/latest/l ... types.html). Here's updated docs with some examples: https://pycopy.readthedocs.io/en/latest ... types.html

Re: [nrf52] Module for register definitions like "stm"

Posted: Thu Oct 11, 2018 7:04 pm
by dhylands
You can also add support for machine_mem.

You'd need to add these 3 lines:
https://github.com/micropython/micropyt ... #L485-L487
to this file:
https://github.com/micropython/micropyt ... ine.c#L190

and then you'd have the mem8, mem16, and mem32 accessors available. You'll still need to define constants for all of the registers you want to access, but that would be needed whether you use this approach or the uctypes approach that @pfalcon mentioned.

Re: [nrf52] Module for register definitions like "stm"

Posted: Thu Oct 11, 2018 8:25 pm
by kak
Would you like to add that officially?

Re: [nrf52] Module for register definitions like "stm"

Posted: Fri Oct 12, 2018 5:13 pm
by WhiteHare
Regarding the OP, machine.mem32[...] works great and is definitely the way to go: viewtopic.php?f=12&t=5377

:D