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

WIP: Native GPIO #1737

Closed
wants to merge 18 commits into from
Closed

Conversation

LudwigKnuepfer
Copy link
Member

  • dummy and Linux sysfs GPIO drivers for native
  • minor PIR driver test fix

TODO:

  • add signal mode for sysfs driver
  • implement writing for sysfs driver
  • test sysfs driver on raspberry PI
  • add control method for virtual interface
  • address sysfs GPIO availability issue
  • guard native system calls
  • rename "dummy" to "virtual"?

- [ ] enable pullup/pulldown on sysfs (if possible) not posssible
- [ ] enable mapping of host GPIO numbers to native GPIO numbers

External GPIO/sysfs documentation:
http://pi.gadgetoid.com/pinout
http://wiki.openwrt.org/doc/hardware/port.gpio

Based on #1838

@LudwigKnuepfer LudwigKnuepfer changed the title WIP: Native gpio WIP: Native GPIO Sep 29, 2014
@LudwigKnuepfer LudwigKnuepfer added Platform: native Platform: This PR/issue effects the native platform Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Sep 29, 2014
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
*/

#ifdef MODULE_NATIVE_GPIO_DUMMY
Copy link
Contributor

Choose a reason for hiding this comment

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

#if defined(MODULE_NATIVE_GPIO_DUMMY) || defined(MODULE_NATIVE_GPIO_SYSFS)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking of making this configurable from the outside because the host might not have as many GPIOs.. I wasn't sure how to solve the _EN setting and just ignored it - adding to TODO

Copy link
Contributor

Choose a reason for hiding this comment

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

-DNATIVE_GPIO_NUMOF=42

#ifdef NATIVE_GPIO_NUMOF
#   if NATIVE_GPIO_NUMOF > 16
#       define GPIO_NUMOF 16
#   else
#       define GPIO_NUMOF NATIVE_GPIO_NUMOF
#   endif
#else
#    define GPIO_NUMOF 0
#endif

#if GPIO_NUMOF > 0
#   define GPIO_0_EN 1
#endif
#if GPIO_NUMOF > 1
#   define GPIO_1_EN 1
#endif#if GPIO_NUMOF > 15
#   define GPIO_15_EN 1
#endif

?

Copy link
Member Author

Choose a reason for hiding this comment

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

seems to work, TA!

@Kijewski Kijewski added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Sep 29, 2014
@LudwigKnuepfer LudwigKnuepfer added this to the Release NEXT MAJOR milestone Sep 29, 2014
_NATIVE_GPIO_CONF_OUT,
_NATIVE_GPIO_CONF_BOTH,
_NATIVE_GPIO_CONF_INT,
_NATIVE_GPIO_CONF_INT_OUT,
Copy link
Contributor

Choose a reason for hiding this comment

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

what is INT_OUT? I don't think there is something as an output interrupt for gpios...

Copy link
Member Author

Choose a reason for hiding this comment

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

brainfart

@haukepetersen
Copy link
Contributor

rename "dummy" to "virtual" --> +1

@LudwigKnuepfer
Copy link
Member Author

Found to work on Raspberry PI =)

Native GPIO device 0 is now HIGH
Native GPIO device 1 is now HIGH
Native GPIO device 2 is now HIGH
Native GPIO device 3 is now HIGH
Native GPIO device 0 is now LOW
Native GPIO device 1 is now LOW
Native GPIO device 2 is now LOW
Native GPIO device 3 is now LOW

--------------------------------------------

Setting GPIOs to input w/o pull resister now
/home/ludwig/RIOT/tests/periph_gpio/bin/native/periph_gpio.elf: gpio_init_in(0)
/home/ludwig/RIOT/tests/periph_gpio/bin/native/periph_gpio.elf: gpio_init_in(1)
/home/ludwig/RIOT/tests/periph_gpio/bin/native/periph_gpio.elf: gpio_init_in(2)
/home/ludwig/RIOT/tests/periph_gpio/bin/native/periph_gpio.elf: gpio_init_in(3)
Will now poll all pins and print status on change
GPIO_0:H  GPIO_1:H  GPIO_2:H  GPIO_3:H  

GPIO_0:L  GPIO_1:H  GPIO_2:H  GPIO_3:H  
GPIO_0:H  GPIO_1:H  GPIO_2:H  GPIO_3:H  
GPIO_0:L  GPIO_1:H  GPIO_2:H  GPIO_3:H  
GPIO_0:H  GPIO_1:H  GPIO_2:H  GPIO_3:H  
GPIO_0:L  GPIO_1:H  GPIO_2:H  GPIO_3:H  
GPIO_0:H  GPIO_1:H  GPIO_2:H  GPIO_3:H  
GPIO_0:H  GPIO_1:L  GPIO_2:H  GPIO_3:H  
GPIO_0:H  GPIO_1:H  GPIO_2:H  GPIO_3:H  

@LudwigKnuepfer
Copy link
Member Author

Here's a video of GPIO in action:
Vimeo Link

The LEDs on top are blinking, you have to look closely ;)

@haukepetersen
Copy link
Contributor

I like :-)

@LudwigKnuepfer
Copy link
Member Author

rebased on master

@mehlis
Copy link
Contributor

mehlis commented Oct 4, 2014

@LudwigOrtmann PR needs rebase

@OlegHahm
Copy link
Member

OlegHahm commented Oct 7, 2014

Again...

@LudwigKnuepfer
Copy link
Member Author

rebased on #1838

@LudwigKnuepfer LudwigKnuepfer removed the State: waiting for other PR State: The PR requires another PR to be merged first label Oct 21, 2014
@LudwigKnuepfer
Copy link
Member Author

rebased on master

@LudwigKnuepfer
Copy link
Member Author

rebased

#endif
#if GPIO_NUMOF > 15
# define GPIO_15_EN (1)
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

hm, above you define, that there can be up to 32 GPIOs, but here you stop at 15...

Copy link
Member Author

Choose a reason for hiding this comment

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

Hoppla.

@LudwigKnuepfer
Copy link
Member Author

I've been thinking to have the virtual interface do more or less the same as the sysfs does, namely write to / read from files in some directory structure. Any opinions?

@haukepetersen
Copy link
Contributor

Not really, sounds sensible to me.

@N8Fear
Copy link

N8Fear commented Oct 30, 2014

I too think that this idea has it's merits. Do you have some kind of documentation on how to use it? Ideally for both the rpi and the virtual implementation.

@LudwigKnuepfer LudwigKnuepfer added the State: waiting for other PR State: The PR requires another PR to be merged first label Jan 20, 2015
@OlegHahm OlegHahm force-pushed the master branch 3 times, most recently from 9f184dd to 45554bf Compare March 31, 2015 13:01
@OlegHahm
Copy link
Member

Any progress?

@LudwigKnuepfer
Copy link
Member Author

still waiting for native file descriptor infrastructure pr

@OlegHahm OlegHahm modified the milestone: Release 2015.12 Nov 28, 2015
@OlegHahm
Copy link
Member

Shall we close as memo?

@LudwigKnuepfer LudwigKnuepfer added the State: archived State: The PR has been archived for possible future re-adaptation label Feb 28, 2016
@bergzand bergzand mentioned this pull request Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Platform: native Platform: This PR/issue effects the native platform State: archived State: The PR has been archived for possible future re-adaptation State: waiting for other PR State: The PR requires another PR to be merged first State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants