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

periph/gpio: merged dir and pushpull parameters #4862

Merged
merged 31 commits into from
Mar 18, 2016

Conversation

haukepetersen
Copy link
Contributor

This PR solves #4472

Please have a look at the interface change first (commit 57ba62e) -> this is what came out of the discussion in #4472 (or what I interpreted of it :-) ).

I adjusted all CPUs except the kinetis_common. For the latter I am waiting on #4830 to prevent duplicate work...

If you all agree, I guess some extensive testing is in order...

@haukepetersen haukepetersen added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Platform: MSP Platform: This PR/issue effects MSP-based platforms Platform: ARM Platform: This PR/issue effects ARM-based platforms Impact: major The PR changes a significant part of the code base. It should be reviewed carefully Platform: AVR Platform: This PR/issue effects AVR-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. labels Feb 20, 2016
@haukepetersen haukepetersen added this to the Release 2016.03 milestone Feb 20, 2016
int res;

if (dir == GPIO_DIR_OUT) {
if (mode == GPIO_OUT) {
Copy link
Member

Choose a reason for hiding this comment

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

Using switch(mode){ case xyz:} instead of if() would improve the readability because of the similarities with other periph drivers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true. But it is true, that the compiler ends up with the same binary in this case, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, at least for a modern compiler such as gcc or clang I expect the generated machine code to be identical.

int gpio_init_int(gpio_t pin, gpio_pp_t pullup, gpio_flank_t flank,
gpio_cb_t cb, void *arg)
int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
gpio_cb_t cb, void *arg)
Copy link
Member

Choose a reason for hiding this comment

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

remove the added whitespaces, alignment is messed up

@haukepetersen
Copy link
Contributor Author

rebased and squashed

@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 CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable labels Mar 17, 2016
@haukepetersen
Copy link
Contributor Author

fixed limifrog

@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 CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 17, 2016
@A-Paul
Copy link
Member

A-Paul commented Mar 17, 2016

@haukepetersen

and who has a 'weio' board flying around? @PeterKietzmann, do you have one?

FYI, I asked Peter. We don't have one here.

typedef enum {
GPIO_IN = GPIO_MODE(0, 1), /**< input w/o pull R */
GPIO_IN_PD = GPIO_MODE(0, 2), /**< input with pull-down */
GPIO_IN_PU = GPIO_MODE(0, 2), /**< input with pull-up */
Copy link
Member

Choose a reason for hiding this comment

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

It seems improbable that IN_PU and IN_PD should have the same value :) As in GPIO_IN_PD and GPIO_IN_PU would always have the same value now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, this is correct -> this only enables the pull resistor in general, see stm32f1/periph/gpio.c line 89/90, the output register value determines if PU or PD are used.

@DipSwitch
Copy link
Member

Pffeewwww long read 40 minutes or so haha, but seems ok apart from the F1 gpio_mode_t definition. :)

@DipSwitch
Copy link
Member

If the F1 is fixed ACK from my side :)

@haukepetersen
Copy link
Contributor Author

The F1 is actually correct, Travis is happy -> go go go

haukepetersen added a commit that referenced this pull request Mar 18, 2016
periph/gpio: merged dir and pushpull parameters
@haukepetersen haukepetersen merged commit d79a662 into RIOT-OS:master Mar 18, 2016
@haukepetersen haukepetersen deleted the opt_periph_gpio_mode branch March 18, 2016 09:13
@DipSwitch
Copy link
Member

No because now the pull-up will always be enabled ;)
On 18 Mar 2016 10:13 a.m., "Hauke Petersen" notifications@github.com
wrote:

Merged #4862 #4862.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#4862 (comment)

@haukepetersen
Copy link
Contributor Author

No, when you use GPIO_IN, the pull resistors are disabled.

port->CR[pin_num >> 3] |= (mode << ((pin_num & 0x7) * 4));
/* set initial state of output register */
port->BRR = (1 << pin_num);
if (mode == GPIO_IN_PU) {
Copy link
Member

Choose a reason for hiding this comment

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

because

 +    GPIO_IN_PD = GPIO_MODE(0, 2),   /**< input with pull-down */
 +    GPIO_IN_PU = GPIO_MODE(0, 2),   /**< input with pull-up */

is the same value, this if statement is also true for PD :)

@DipSwitch
Copy link
Member

Yeah that's true, sorry for the mis-communication. I meant the the pull-up is always enabled, even for pull-down :)

@haukepetersen
Copy link
Contributor Author

Oh, seems I wearing my pink glasses today, you are perfectly right! Will provide a fix ASAP

@DipSwitch
Copy link
Member

haha np, happens on Friday ;)

@haukepetersen
Copy link
Contributor Author

-> #5104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: major The PR changes a significant part of the code base. It should be reviewed carefully Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: AVR Platform: This PR/issue effects AVR-based platforms Platform: MSP Platform: This PR/issue effects MSP-based platforms Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation 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.

7 participants