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

doc: hardware: emulator: add gpio_emul documentation #67410

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Jan 9, 2024

Previously, the only documentation that existed for gpio_emul was in the form of source code.

Create some additional documentation in the form of .rst to help clarify usage. Any additional instruction for how to use the GPIO Emulator driver can be added here.

@cfriedt cfriedt force-pushed the add-documentation-for-gpio-emulator branch 4 times, most recently from 34de820 to cefd244 Compare January 10, 2024 14:52
Previously, the only documentation that existed for gpio_emul
was in the form of source code.

Create some additional documentation in the form of .rst to
help clarify usage. Any additional instruction for how to
use the GPIO Emulator driver can be added here.

Signed-off-by: Christopher Friedt <[email protected]>
@cfriedt cfriedt force-pushed the add-documentation-for-gpio-emulator branch from cefd244 to 7acc2e6 Compare January 10, 2024 14:57
@cfriedt cfriedt marked this pull request as ready for review January 10, 2024 14:57
@cfriedt
Copy link
Member Author

cfriedt commented Jan 10, 2024

Ready-ish I think - happy to make modifications, as needed.

driver does not follow the same behaviour required by Zephyr's GPIO Driver Model, and the new
driver requires improvement.

2. The ``gpio_emul`` device allows us to perform fast functional testing to verify the expected
Copy link
Member

Choose a reason for hiding this comment

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

I am personally a fan of documentation with a conversational tone :), but I defer to other reviewers.

Copy link
Collaborator

@kartben kartben Jan 10, 2024

Choose a reason for hiding this comment

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

Are you, or are you not? Just asking for clarification in case you forgot a word -- I have to admit that the tone certainly had me do a double take yesterday, even before you made this comment, and I would lean on the "not a fan" side myself as the page currently "reads" very differently than 99.9% of the rest of the documentation. That being said, I will also defer to others :) And in any case I will try to provide actionable feedback. Thanks for the work on this doc page, Chris!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the work on this doc page, Chris!

+1 to that, thank you, Chris!

Are you, or are you not?

Personally, I like reading conversational documentation. That being said, you brought up a good point that the rest of the Zephyr documentation does not follow a conversational theme. So you're probably right that it'd be better to rephrase more exactly.

Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason, I misread "conversational" as "controversial" initially 😅 I guess both could be true.

I will make some objective corrections first, and then will look at subjective corrections.

It might take a bit of time

@aescolar aescolar requested a review from kartben January 10, 2024 17:03

Use the emulated GPIO driver exactly the same as one would use any other GPIO driver.

Insert an instance into Devicetree, ensuring that the named compatible is ``zephyr,gpio-emul``
Copy link
Member

Choose a reason for hiding this comment

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

You reminded me I need to go make a gh issue about needing support for tristate gpios.

@aaronemassey aaronemassey self-requested a review January 10, 2024 17:05
Copy link
Member

@aescolar aescolar left a comment

Choose a reason for hiding this comment

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

Thanks for documenting it,
But it does not seem ready yet.
Rendered version can be found here:
https://builds.zephyrproject.io/zephyr/pr/67410/docs/hardware/emulator/gpio_emulator.html


Zephyr's GPIO (General Purpose Input-Output) emulator has several functions.

1. It serves as a model for the basic GPIO Driver API; if a new GPIO driver is added for a new
Copy link
Member

Choose a reason for hiding this comment

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

This does not render well.

#. Lightweight Vector Graphics Library (LVGL) sample with a "soft" button

.. zephyr-app-commands::
:app: tests/drivers/eeprom/api
Copy link
Member

Choose a reason for hiding this comment

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

This is not the lvgl sample.

driver requires improvement.

2. The ``gpio_emul`` device allows us to perform fast functional testing to verify the expected
behaviour of various libraries and applications. Why? In Zephyr, a GPIO is a GPIO is a GPIO
Copy link
Member

Choose a reason for hiding this comment

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

I would avoid funny phrases with meanings that are only known by speakers in some areas and times.. In 20 years nobody may know what this was supposed to mean, and already today people who are not of the same background as you will be left baffled by this sentence.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1, this 100% looked like a typo to me, tbh

Copy link
Member Author

Choose a reason for hiding this comment

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

Lol, sure. I guess it's more of a native English thing / colloquialism


1. It serves as a model for the basic GPIO Driver API; if a new GPIO driver is added for a new
controller, and some aspect of the new driver fails Zephyr's GPIO Driver API Testsuite, while
the emulated GPIO driver (and others) pass, it may be an indicator that something in the new
Copy link
Member

Choose a reason for hiding this comment

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

This would be applicable to any Zephyr provided GPIO driver. But I guess nobody has agreed this particular driver is the reference implementation for the API(?). So this paragraph implies something I would not imply. Meaning, I would remove this paragraph all together.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was used that way when it was added and that's how I was instructed to design it by the previous gpio maintainer.

We also do not yet have a replacement GPIO maintainer.

In any case, I will remove it.


2. The ``gpio_emul`` device allows us to perform fast functional testing to verify the expected
behaviour of various libraries and applications. Why? In Zephyr, a GPIO is a GPIO is a GPIO
(from a functional perspective) because there is a common GPIO Driver API and model. How can
Copy link
Member

Choose a reason for hiding this comment

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

I'd say this format does not help with readability. In any case, this whole paragraph could have been 2 sentences.
Most readers prefer brief documentation.

The ``zephyr,gpio-emul`` Devicetree bindings inherit from ``gpio-controller`` and ``base``
Devicetree bindings.

It may be necessary to add the :kconfig:option:`CONFIG_GPIO_EMUL=y` option to your project
Copy link
Member

Choose a reason for hiding this comment

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

:kconfig:option:CONFIG_GPIO_EMUL is a link to the option, you cannot have the =y in the link itself

@aaronemassey aaronemassey self-requested a review January 10, 2024 17:25
};

.. note::
The ``zephyr,gpio-emul`` Devicetree bindings inherit from ``gpio-controller`` and ``base``
Copy link
Member

Choose a reason for hiding this comment

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

Please replace zephyr,gpio-emul with a link to the binding doc page
(:dtcompatible:zephyr,gpio-emul)

Usage
=====

Use the emulated GPIO driver exactly the same as one would use any other GPIO driver.
Copy link
Contributor

Choose a reason for hiding this comment

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

Related to the above discussion of formality in documentation, "Use the emulated GPIO driver" is fairly informal, while "one would use" is fairly formal. Without expressing a strong opinion on which one I think you should choose, this sentence and the document should be internally consistent: "Use the emulated GPIO driver ... as you would use ..." or "One uses the emulated GPIO driver ... as one would use ..."

The same idea also applies to other constructions below like "may be specified" ("you may specify") and "it may be necessary" ("you may need").

struct gpio_callback *cb,
gpio_port_pins_t pins)
{
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a snippet here that gets the interesting information out of port and pins and calls some made-up function with those objects as arguments?

Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Mar 11, 2024
@github-actions github-actions bot closed this Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants