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 a function to get a pin number from mraa_gpio_context #76

Closed
wants to merge 1 commit into from
Closed

Add a function to get a pin number from mraa_gpio_context #76

wants to merge 1 commit into from

Conversation

yoneken
Copy link
Contributor

@yoneken yoneken commented Dec 21, 2014

I add a function named mraa_gpio_get_pin .
This function is useful to restore a physical pin number in callback function.

For example,

void interrupt_in(void *arg)
{
  mraa_gpio_context dev = (mraa_gpio_context)arg;
  printf("Pushed %d", mraa_gpio_get_pin(dev));
}

int main(int argc, char *argv[])
{
  mraa_gpio_context in0 = mraa_gpio_init(14);
  mraa_gpio_dir(in0, MRAA_GPIO_IN);
  mraa_gpio_mode(in0, MRAA_GPIO_PULLUP);
  mraa_gpio_isr(in, MRAA_GPIO_EDGE_FALLING, interrupt_in, (void *)in0);

  mraa_gpio_context in1 = mraa_gpio_init(15);
  mraa_gpio_dir(in1, MRAA_GPIO_IN);
  mraa_gpio_mode(in1, MRAA_GPIO_PULLUP);
  mraa_gpio_isr(in, MRAA_GPIO_EDGE_FALLING, interrupt_in, (void *)in1);

  sleep(30);

  return 0;
}

Signed-off-by: Kenta Yonekura yoneken@ieee.org

@arfoll
Copy link
Contributor

arfoll commented Dec 21, 2014

Thanks a lot or this just one change before I can merge, the return type should be int not mraa_result_t. Thanks

@tingleby
Copy link
Member

Also having a sign-off in the the commit would be nice.

@arfoll
Copy link
Contributor

arfoll commented Dec 21, 2014

@tingleby oh didn't realise the sign off came with the PR msg! Yes, please run git commit --amend --signoff

Signed-off-by: Kenta Yonekura <yoneken@ieee.org>
@yoneken
Copy link
Contributor Author

yoneken commented Dec 21, 2014

@arfoll @tingleby Thanks a lot for your gentle suggestion. I changed the return type and made a sign-off.

@arfoll
Copy link
Contributor

arfoll commented Dec 21, 2014

Thank you very much for contributing! Merged with 74d172c.

@arfoll arfoll closed this Dec 21, 2014
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.

None yet

3 participants