Severson-Group / AMDC-Firmware

Embedded system code (C and Verilog) which runs the AMDC Hardware
http://docs.amdc.dev/firmware
BSD 3-Clause "New" or "Revised" License
31 stars 5 forks source link

Expand GPIO Mux and Create GPIO Direct IP #296

Closed codecubepi closed 1 year ago

codecubepi commented 1 year ago

This PR is a request to merge in the additions to the GPIO ports for both the REV D and REV E AMDC.

Changes to existing AMDC REV X block designs:

REV E

REV D

GPIO_DIRECT IP Block

IP Block

The GPIO_DIRECT IP is a new block with two registers: one read, one write.

The three least-signirficant bits of the read register are determined by the digital voltage on the in pins of the connected GPIO port (after differential -> single conversion). The C code driver can be used to read these three digital values.

The three least-signirficant bits of the write register are responsible for determining the digital voltage on the out pins of the connected GPIO port (before single -> differential conversion). The C code driver can be used to set these three digital values.

Driver C Code

The driver C code (located in sdk/app_cpu1/common/drv/gpio_direct.c) gives a layer of abstraction by providing functions that the user can call to read, write, or toggle a given Port/Pin:

gpio_direct_level_t gpio_direct_read(gpio_direct_port_t port, gpio_direct_pin_t pin);
void gpio_direct_write(gpio_direct_port_t port, gpio_direct_pin_t pin, gpio_direct_level_t level);
void gpio_direct_toggle(gpio_direct_port_t port, gpio_direct_pin_t pin);

Command Interface

In addition to the driver C code, a serial command interface has been provided in sdk/app_cpu1/common/sys/cmd/cmd_hw.c, as this IP block adds hardware functionality. See here.

    // Handle 'gpio' sub-command
    // hw gpio read <port> <pin>
    // hw gpio write <port> <pin> <HIGH|LOW>
    // hw gpio toggle <port> <pin>

Additionally, another subcommand option has been added to the hw mux command:

hw mux gpio list

This command will list which IP device is which when selecting which device to drive a GPIO port.

image

To-Do:

npetersen2 commented 1 year ago

@codecubepi is this PR ready for review?

Can you confirm this works on both REV D and REV E hardware?

codecubepi commented 1 year ago

@npetersen2 @elsevers

@codecubepi is this PR ready for review?

Can you confirm this works on both REV D and REV E hardware?

This is now confirmed working on both REV D and REV E hardware... yay!

npetersen2 commented 1 year ago

@codecubepi please run the clang auto formatter: see https://github.com/Severson-Group/AMDC-Firmware/blob/v1.0.x/CONTRIBUTING.md#code-formatting

There is a nice extension to VS Code for this

codecubepi commented 1 year ago

@npetersen2

I believe I have addressed all of your feedback, please review my changes and comments.

Can you remember to show me which VS Code extension you use for the clang formatter in our next meeting?

codecubepi commented 1 year ago

@npetersen2

Ready for re-review. I think everything is much cleaner now.

npetersen2 commented 1 year ago

@codecubepi actually, this issue is what you built for the GPIO direct IP block: https://github.com/Severson-Group/AMDC-Firmware/issues/244

codecubepi commented 1 year ago

@npetersen2 @elsevers

Final functionality verification is good on both REV D and REV E. I think I'm ready for this to be merged with approval.

Relevant repository issues have been linked for automatic closure and tracking