wokwi / rp2040js

A Raspberry Pi Pico Emulator in JavaScript
MIT License
384 stars 40 forks source link

feat(DMA): implement DMA sniffing (partially) #91

Open tomods opened 2 years ago

tomods commented 2 years ago

Implements (parts of) the RP2040 datasheet, chapter 2.5.5.2.

Currently, the code disobeys some settings in SNIFF_CTRL. It just assumes OUT_INV = OUT_REV = SNIFF_BSWAP = 0; CALC = 0xf. I.e., it can only do simple summation, no further checksumming.

Is the style OK? Would you be willing to merge this without the features mentioned above? I'm not really in the mood to add the other checksumming options...

Tested with a transfer size of 16 bits using the code you already know from https://github.com/wokwi/rp2040js/pull/90 ;) Just with the commented-out parts of RP2040ADC.py enabled. So you can easily test this in https://wokwi.com/arduino/projects/320232834674459219

urish commented 2 years ago

Thanks!

Would it be hard to support OUT_INV, OUT_REV, and SNIFF_BSWAP as well?

For the bit reversal part, we already have an implementation. You could move it to src/utils/bits.ts, sharing it between the PIO and DMA.

tomods commented 2 years ago

Nah, not hard at all. Will look into it when I have some more time

urish commented 2 years ago

Guess you are busy nowadays?