Coder Social home page Coder Social logo

Support for more boards about psxnewlib HOT 16 OPEN

sukkopera avatar sukkopera commented on May 31, 2024
Support for more boards

from psxnewlib.

Comments (16)

SukkoPera avatar SukkoPera commented on May 31, 2024 1

It's pretty much black magic to me, too :). But DigitalIO has an example that, when run on a board, will produce the output that should be added to the library in order to enable support for it. Try it!

(Be sure to use my fork and send a PR if you manage to come up with anything. Upstream doesn't seem to care anymore.)

from psxnewlib.

tbillion avatar tbillion commented on May 31, 2024

hey throw me in the hat for looking to get this done as well ... my project is a little more real world application and i think i just outgrew the uno328 so any luck with this?

as far as the PSXnewlib goes what does digital io do for the library ? why do none of the other psx libs have it ?

from psxnewlib.

SukkoPera avatar SukkoPera commented on May 31, 2024

DigitalIO is just a way of driving the GPIOs as fast as possible and with as little code as possible (i.e. 1/2 ASM instructions on AVRs). It's not strictly necessary and you could easily write new versions of PsxControllerHwSpi.h and PsxControllerBitBang.h that do not require it.

from psxnewlib.

sonik-br avatar sonik-br commented on May 31, 2024

I tried to port the DigitalIO library but those processors works quite differently.

But looks like at least on the RP2040 digitalWrite() and digitalRead() are fast enough!

I was testing with a modified (simplified) version of DigitalIO that does passthrough and call directly the digital/Write/Read methods of the arduino ide. Doing this way I don't need to modify the PsxNewLib.

The code builds but I have not tested yet as I still need to wire an psx input port to the Pi Pico.
The STM32 should be fast enough too.

from psxnewlib.

tbillion avatar tbillion commented on May 31, 2024

from psxnewlib.

tbillion avatar tbillion commented on May 31, 2024

from psxnewlib.

SukkoPera avatar SukkoPera commented on May 31, 2024

@tbillion Your idea is fine to me, but I am not going to do that. It's very simple however, you can do it yourself: just make a copy of PsxControllerBitBang.h, name it PsxControllerBitBangSlow.h and replace all DigitalIO calls with straight Arduino calls (pinMode(), digitalRead() and digitalWrite ()). Finally submit a PR :).

from psxnewlib.

tbillion avatar tbillion commented on May 31, 2024

10-4 i have done that part this part though is outside my scope of understanding what to do with, what needs to be done here in the beginning of the code to transfer the pin numbers to the now "dumbed down" version of the code.

template <uint8_t PIN_ATT, uint8_t PIN_CMD, uint8_t PIN_DAT, uint8_t PIN_CLK>
class PsxControllerBitBang: public PsxController {
private:
	#define <PIN_ATT> att
	#define <PIN_CLK> clk;
	#define <PIN_CMD> cmd;
	#define <PIN_DAT> dat;

because what i have does not work 🥇 surprise

below compiles but i am not sure it is correct. I am away from my desk so i cannot test to ensure that will work.

template <uint8_t PIN_ATT, uint8_t PIN_CMD, uint8_t PIN_DAT, uint8_t PIN_CLK>
class PsxControllerBitBang: public PsxController {
private:
	uint8_t att = PIN_ATT;
	uint8_t clk = PIN_CLK;
	uint8_t cmd = PIN_CMD;
	uint8_t dat = PIN_DAT;

	//#define <PIN_ATT> att
	//#define <PIN_CLK> clk
	//#define <PIN_CMD> cmd
	//#define <PIN_DAT> dat

from psxnewlib.

sonik-br avatar sonik-br commented on May 31, 2024

Comment out this block
https://github.com/SukkoPera/PsxNewLib/blob/master/src/PsxControllerBitBang.h#L24-L28

Change the calls low() and high() to digitalWrite(PIN_NUMBER, LOW) and digitalWrite(PIN_NUMBER, HIGH)
IE: att.high() would be digitalWrite(PIN_ATT, HIGH)

Here it's used to read..
https://github.com/SukkoPera/PsxNewLib/blob/master/src/PsxControllerBitBang.h#L70

Change dat to digitalRead(PIN_CMD)

And here it needs to call pinMode(). For the ones that are OUTPUT you will also need to call digitalWrite()
https://github.com/SukkoPera/PsxNewLib/blob/master/src/PsxControllerBitBang.h#L82-L85

IE:

//Change from
att.config (OUTPUT, HIGH);

//Change to
pinMode(PIN_ATT, OUTPUT);
digitalWrite(PIN_ATT, HIGH);
//Do this for the 3 input pins

//Then do this for the output pin
//Change from
dat.config (INPUT, HIGH);     // Enable pull-up

//Change to
pinMode(PIN_DAT, INPUT_PULLUP);

from psxnewlib.

tbillion avatar tbillion commented on May 31, 2024

@sonik-br I got all of that I have to test it later, based on context do you think it would be more expediant to change the uppercase variables to the lower case variables to avoid changing too much from the original. I submitted a pull request as suggested with the extra file it could use some deletions because I just commented out and replaced also a clear explanation of why you'd use this one vs the original is probably needed to clarify the use case .

If redeclaring them as private variables is unnecessary then changing PIN_CMD to cmd may be the most fluid solution?

from psxnewlib.

sonik-br avatar sonik-br commented on May 31, 2024

Got it working?

If redeclaring them as private variables is unnecessary then changing PIN_CMD to cmd may be the most fluid solution?

I don't see why redeclare them. Just use what's defined in the template. (ie: PIN_CMD).
But I'm not good at C and I have no idea what's the "best practices" for the language.

from psxnewlib.

tbillion avatar tbillion commented on May 31, 2024

ok so the bit bang example works on rp2040 however it was not a library issue.

well actually it was a library issue, and a hardware issue. firstly i think that the actual installation of the digitalio library from git hub instead of the arduino repo for library manager is a MUST DO, like bold italic the whole nine.

then as far as hardware is concerned, the pico either doesn't have pull ups, or they don't work, so you need to follow the suggestions here :

https://store.curiousinventor.com/guides/PS2/
and here :

http://sophiateam.undrgnd.free.fr/psx/index.html

and place a 10k pull up on the i/o pin that is associated with DAT pin.

on an RPI PICO in overclock this thing is smooth as butter, way better than arduino i will come back and edit in a while when i attempt to retry the library extension i made with out digital IO and see if i can get that one and the HWSPI to work.

//EDIT : apparently what i was trying out originally when it worked was my fastproc.h which true to its name on the pi is actually faster than the Digital IO extension. I just finished trying that out and both bitbangs work.

//EDIT : HWSPI doesn't work. not sure why as i have a functional bitbang on the correct pins for HWSPI so i know its connected correctly, not sure how to proceed on this.

from psxnewlib.

sonik-br avatar sonik-br commented on May 31, 2024

The PI PICO does have pullup. I tested it in some random pins and it worked.
Using pinMode(PIN_NUMBER, INPUT_PULLUP); ?

from psxnewlib.

SukkoPera avatar SukkoPera commented on May 31, 2024

Please note that internal pull-ups are never as strong as they should be. The PsOne has 1k pull-ups, internal pull-ups are often several tens of kiloohms. This means signals will rise more slowly and compatibility with all controllers is not assured.

from psxnewlib.

Crazy-Child avatar Crazy-Child commented on May 31, 2024

Got it working?

If redeclaring them as private variables is unnecessary then changing PIN_CMD to cmd may be the most fluid solution?

I don't see why redeclare them. Just use what's defined in the template. (ie: PIN_CMD). But I'm not good at C and I have no idea what's the "best practices" for the language.

Hello
You managed to connect a controller from PS2 to RP2040?

from psxnewlib.

tbillion avatar tbillion commented on May 31, 2024

from psxnewlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.