Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multitap (devel branch) #18

Open
sonik-br opened this issue Jun 9, 2022 · 6 comments
Open

Multitap (devel branch) #18

sonik-br opened this issue Jun 9, 2022 · 6 comments

Comments

@sonik-br
Copy link

sonik-br commented Jun 9, 2022

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?

@SukkoPera
Copy link
Owner

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.

@sonik-br
Copy link
Author

sonik-br commented Jun 9, 2022

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

@SukkoPera
Copy link
Owner

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.

@sonik-br
Copy link
Author

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.

@SukkoPera
Copy link
Owner

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.

@sonik-br
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants