Code: Select all
ba=bytearray[100]
base_address = uctypes.addressof(ba)
Why do I want this? Well, on the nRF52 series, the radio uses DMA to read and write directly from the same memory used by the microcontroller. I need to allocate a block of memory for the radio to use to store the payload of a received packet, and I do that by telling the radio the address of the first byte (the base address) of the block of memory. Once I tell the radio that address, I can't have that block of memory moved somewhere else by the GC, or else the radio will be writing bytes into the wrong parts of memory.
Is a byte array naturally locked down (can't be moved in memory), or do I have to do something explicit to lock a byte array down so that it doesn't move?