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

Add support for getting/setting GPIOs #2

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

runger1101001
Copy link

The CY7C652xx also support GPIOs.

The chip is quite flexible, allowing any of the pins not used for other functions to be used as GPIOs. You have to decide at configuration time whether the pin should be input or output, and for output pins you can set what the initial output state is after reset.

Having GPIO control is useful in one of this chips primary use-cases: in system programming. Having GPIO control allows you to trigger reset pins, set mode pins, check "done" pins and similar things that you need when flashing FPGAs and other devices.

This PR adds support for setting the GPIOs programmatically in the python API.

Please let me know if this meets your expectations? I'm not primarily a python programmer, so please be forgiving! 😃

It is the first PR but I hope to send you one or two more:

  • I'd like to add GPIO setting to the CLI tool also
  • I'm using the CY7C65215 - which is the dual channel model. I'd like to add support for it.

@multiplemonomials
Copy link

Hi! Sorry, for some reason GitHub did not notify me about this PR, just saw it. Thanks so much for giving this repo a shot, really excited to have someone using it!

@runger1101001
Copy link
Author

I'll fix these and add my other improvements to the PR asap...

@multiplemonomials
Copy link

multiplemonomials commented Nov 27, 2024

Apologies, could we keep this PR for the GPIO changes only, and make the CY7C65215 changes their own PR? I think adding support for that model will be a pretty big job...

@@ -45,6 +46,7 @@ repository = 'https://github.com/mbed-ce/cy_serial_bridge/'

[tool.poetry.scripts]
cy_serial_cli = 'cy_serial_bridge.cli:main'
cy_flash = 'cy_serial_bridge.flash:main'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is pointing to a script that doesn't exist (in this PR at least?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh sorry - it's a utility for flashing NOR flash chips and similar devices that I'm working on. You need something a bit more complicated than the SPI write of the general CLI, and there are many options, so I thought a separate cy_flash cli program is the way to go.
Its a work in progress, the branch for it is here: https://github.com/runger1101001/cy_serial_bridge/tree/cy_flash_utility

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I'll make a separate PR when its ready so for now I will back out this change from this PR.

@@ -59,7 +59,7 @@ class CyType(IntEnum):
6 # Used to indicate a device which is in CDC UART mode (which will automatically work using an OS driver)
)
UART_PHDC = 7 # Used to indicate a device which is in PHDC (Personal Healthcare Device Class) UART mode

CDC_DATA = 8 # Used to indicate the CDC data interface (which is a separate interface from the CDC UART interface)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random question, do you have a source for what this interface actually does? I don't actually know, and I think I wasn't able to find out easily back when I was looking into this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I was curious myself... There is a CDC defintion for SPI devices also, maybe its related to that?

@runger1101001
Copy link
Author

Apologies, could we keep this PR for the GPIO changes only, and make the CY7C65215 changes their own PR? I think adding support for that model will be a pretty big job...

I'm happy to split it... its just that I can't test it without the CY7C65215 changes as that's the only device I have to test with.
So I can make new PRs for:

  • gpio setting
  • CY7C65215 support
  • flash memory utility (upcoming)

I hope its ok that it takes me a few days each time to progress... I have a lot going on right now and have to do this on the side...

by the way ultimate goals:

  1. I want to be able to easily program flash memories and FPGAs from the command line. The GPIO functionality is part of that as you may need to control the BOOT and RESET pins of the devices.
  2. I want to be able to write simple to use python scripts to work with devices that have an embedded CY7C652xx - so you can have a python script that recognises your custom CY7C652xx device based on its VID/PID/Serial and then offers functions specific to the way the CY7C652xx is used in that device allowing the user to control or update it.

@multiplemonomials
Copy link

Splitting it into three PRs like that sounds perfect!

@multiplemonomials
Copy link

As long as you tested the GPIO stuff in this form, it's okay if you can't test it by itself

@runger1101001 runger1101001 marked this pull request as draft December 1, 2024 23:21
@runger1101001
Copy link
Author

ok, made this PR a draft for now, so it doesn't accidentally get merged :-)

  • I've made a PR (Get/Set GPIOs #4) for the GPIO stuff only, this is ready for merge.
  • I've made a PR (Support CY6C65215 and CY6C65215A #5) for the CY7C65215 changes, as a WIP and for discussion.
  • I'll make one for the flash utility after I've tested it successfully on the CY7C65215 EVM board.

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

Successfully merging this pull request may close these issues.

2 participants