Page 1 of 1

machine memory module

Posted: Tue Jan 19, 2021 11:10 pm
by miltmobley
Why is the extmod machine_mem only used in the Unix and Windows ports? It would seem to be more dangerous if used there,
and also more useful on the embedded cards, for example to examine adc or dma registers?

Re: machine memory module

Posted: Wed Jan 20, 2021 12:19 am
by dhylands
machine_mem is used in many of the MCU ports as well (stm32, zephyr, samd, nrf, esp8266, eps32, mimxrt)

Here's some sample code that uses it:
https://github.com/dhylands/upy-example ... der.py#L14

(the stm.memXX functions and machine.memXX functions are the same thing from extmod/machine_mem.c)

Re: machine memory module

Posted: Wed Jan 20, 2021 3:54 am
by jimmo
Only the Unix and Windows port need to provide MICROPY_MACHINE_MEM_GET_READ_ADDR and MICROPY_MACHINE_MEM_GET_WRITE_ADDR -- the other ports get the default implementation.

Otherwise just enabling MICROPY_PY_MACHINE and adding mem8,mem16,mem32 to the port's modmachine globals table is sufficient (which as dhylands says, all the ports do).

Re: machine memory module

Posted: Wed Jan 20, 2021 7:55 pm
by miltmobley
Thanks for the example code and explanation