SukkoPera/PsxNewLib

Multitap (devel branch)

sonik-br opened this issue · 6 comments

Hi!

I'm doing some tests with the multitap feature of the devel branch.
Using HardwareSpi.
Code works fine until I disable/enable interrupts for reading controller.
Like this

noInterrupts();
const bool success = psx.read (0, controller);
interrupts();

Code just hangs.

Any idea why?

IIRC the code uses interrupts to detect the falling edge on the ACK line between bytes, so it needs interrupts to be enabled. What would be the reason for disabling them BTW? 😅

I think there's also a "backend" that doesn't use the ACK line as in previous versions, but can't remember exactly.

Just trying to get it to run as fast as possible.
But the ACK pin is not even connected XD

Mmmmh...

So, the PsxDriverHwSpiWithAck driver uses a pin-change interrupt to detect the falling edge on the ACK pin.

If you are not using that, but rather the PsxDriverHwSpi driver, it doesn't seem to require interrupts, but maybe the Arduino SPI library does?

If you want to go faster, you can raise the SPI clock, anyway.

The old lib works fine in HwSpi mode with disabled interrupts.
But that's ok. I will test with the guncon and see if the added latency will impact it.
Fell free to close this. I still need to add guncon support for doing the test and it can take a while.

OK, I think the code hangs because of this (the value returned by millis() will not increment while interrupts are disabled).

Adding a setAttentionInterval(0) call might fix the issue but make sure not to poll the controller too often.

Just calling setAttentionInterval(0) did not fix.
Had to comment out the line. :)

I will add support for the guncon and test to see if it's required to disable the interrupts.