[nrf52] Module for register definitions like "stm"

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
kak
Posts: 19
Joined: Fri Oct 05, 2018 11:35 am

[nrf52] Module for register definitions like "stm"

Post by kak » Thu Oct 11, 2018 9:09 am

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?

pfalcon
Posts: 1090
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Thu Oct 11, 2018 9:28 am

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
Awesome MicroPython list
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
Oftentimes more up to date docs than mainline - http://pycopy.readthedocs.io/

User avatar
dhylands
Posts: 2908
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

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

Post by dhylands » Thu Oct 11, 2018 7:04 pm

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.

kak
Posts: 19
Joined: Fri Oct 05, 2018 11:35 am

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

Post by kak » Thu Oct 11, 2018 8:25 pm

Would you like to add that officially?

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

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

Post by WhiteHare » Fri Oct 12, 2018 5:13 pm

Regarding the OP, machine.mem32[...] works great and is definitely the way to go: viewtopic.php?f=12&t=5377

:D

Post Reply