Skip to content

drivers/gpio: improved doc for gpio_init()#7173

Merged
smlng merged 1 commit intoRIOT-OS:masterfrom
haukepetersen:opt_gpiodoc
Jul 14, 2017
Merged

drivers/gpio: improved doc for gpio_init()#7173
smlng merged 1 commit intoRIOT-OS:masterfrom
haukepetersen:opt_gpiodoc

Conversation

@haukepetersen
Copy link
Copy Markdown
Contributor

No description provided.

@haukepetersen haukepetersen added Area: doc Area: Documentation Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Jun 12, 2017
@haukepetersen haukepetersen added this to the Release 2017.07 milestone Jun 12, 2017
@haukepetersen haukepetersen requested review from kaspar030 and smlng June 12, 2017 11:45
@kaspar030
Copy link
Copy Markdown
Contributor

ACK for the change. Do we have to go through our gpio implementations that they actually adhere to this? Otherwise the extra doc does more harm than help.

@smlng
Copy link
Copy Markdown
Member

smlng commented Jun 12, 2017

well as pointed out cc2538 does explicitly clear the gpio on init! Other do not, others do that too ...

@haukepetersen
Copy link
Copy Markdown
Contributor Author

Yapp, to be clean, we IMHO need to adapt all effected GPIO drivers, but I think this effort is not too bad and easily doable. I will create a tracking issue and provide adaptions for a number of them this afternoon...

@haukepetersen
Copy link
Copy Markdown
Contributor Author

See #7176

@aabadie aabadie added the State: waiting for other PR State: The PR requires another PR to be merged first label Jun 23, 2017
/**
* @brief Initialize the given pin as general purpose input or output
*
* When configured as output, the pin state is not touched. So if a specific
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could (or should) be more strict stating

When configured as output, the pin state MUST NOT be changed by the MCU specific GPIO driver implementation!

@haukepetersen
Copy link
Copy Markdown
Contributor Author

@smlng: unfortunately, we can more strict on the pin state - in contrary, I even relaxed the documentation a bit more. The reason here is, that some CPUs do not keep the output state when re-configuring a pin from output to input and vice-versa, so the CPUs architecture is forcing us to touch the pin's state. I can't recall the specific CPUs right now, but some use the output data register to configure the pull resistor state in case the pin is in input mode...

@kaspar030
Copy link
Copy Markdown
Contributor

some CPUs do not keep the output state when re-configuring a pin from output to input and vice-versa

Let's make a list of them.

@haukepetersen
Copy link
Copy Markdown
Contributor Author

Go ahead :-) And where to you want to put the list?

@haukepetersen haukepetersen added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed State: waiting for other PR State: The PR requires another PR to be merged first labels Jul 13, 2017
@haukepetersen
Copy link
Copy Markdown
Contributor Author

@smlng do you get my argument for being vague in the doc?

@kaspar030: I think there are many aspects in the CPU abstraction/periph drivers, where the interfaces leave some space for implementation being a little vague on certain aspects (though vague here meaning that they state explicitly that certain behavior is preferred but not guaranteed). In my understanding it is common practice to look at the concrete implementation to find out the exact behavior of a platform (where the specific implementation hopefully contains some documentation on this). So creating list(s) for all these things seems way too much overhead to me...

@smlng
Copy link
Copy Markdown
Member

smlng commented Jul 13, 2017

do you get my argument for being vague in the doc

I think so ...

@haukepetersen
Copy link
Copy Markdown
Contributor Author

doesn't sound too convinced :-)

@smlng
Copy link
Copy Markdown
Member

smlng commented Jul 14, 2017

doesn't sound too convinced

well, I personally would expect that when I configure a GPIO as output, that its initial state would be unset that is LOW. However, from empirical data (so to speak) I also know that some boards have an inverted logic for some of their GPIOs, so unset a GPIO actually means HIGH for them - so you got a point in saying that from the GPIO API perspective we cannot assume anything on the actual state of the GPIO without knowing the platform and the low level driver, etc ...

So I'm fine with updated docu here and with your reasoning that this is low-level, hence simple as it gets API. However, for high-layer APIs such as SAUL it could be reasonable to have an explicit pin state set after init, which I proposed with #7148

@haukepetersen
Copy link
Copy Markdown
Contributor Author

Perfect, so all we need is an official ACK for this PR :-)

Copy link
Copy Markdown
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

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

ACK

@smlng smlng merged commit 95b3166 into RIOT-OS:master Jul 14, 2017
@haukepetersen
Copy link
Copy Markdown
Contributor Author

nice, thanks!

@haukepetersen haukepetersen deleted the opt_gpiodoc branch July 14, 2017 12:26
smlng added a commit that referenced this pull request Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: doc Area: Documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants