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

Create README.md #3

Merged
merged 1 commit into from
Feb 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# linux-gpio-nct5104d
NCT5104D GPIO Linux Driver

<b>Preconditions (Compile):</b><br>
you should have the following packages installed:
* linux-headers-$(uname -r)
* build-essential
* make
* git (you can also download the repo as zip)

`apt-get install -y linux-headers-$(uname -r) build-essential make git`

`git clone <this repo url>`

<b>Compile:</b><br>
run `make` in the driver folder on the target machine<br>
(otherwise your driver gets compiled for a different kernal version)

<b>Load the driver:</b><br>
`insmod gpio-nct5104d.ko`

<b>Unload the driver:</b><br>
unexport all the used GPIO Pins first, then run<br>
`rmmod gpio-nct5104d.ko`

<b>Export a GPIO Pin:</b><br>
`echo 0 > /sys/class/gpio/export` will export/reserve/setup the gpio pin 0

<b>Unexport a GPIO Pin:</b><br>
`echo 0 > /sys/class/gpio/unexport` will unexport/free the gpio pin 0

<b>Set GPIO Pin as output:</b><br>
`echo out > /sys/class/gpio/gpio0/direction`

<b>Set GPIO Pin output value:</b><br>
`echo 1 > /sys/class/gpio/gpio0/value`

<b>Read GPIO Pin value:</b><br>
`cat /sys/class/gpio/gpio0/value`

<b>Invert GPIO Pin logic:</b><br>
`echo 1 > /sys/class/gpio/gpio0/active_low`

<b>Using the Kernel interrupt system for GPIO Pins:</b><br>
`echo <TRIGGER_TYPE> >/sys/class/gpio/gpio0/edge`<br>
`TRIGGER_TYPE` can be one of the following values:
* none
* falling
* rising
* both

<b>Show GPIO states using kernal debug information:</b><br>
`cat /sys/kernel/debug/gpio`<br>
this has to be enabled in your kernal

<b>Additional informatio:</b><br>
see those pages for some c-code examples:<br>
http://wiki.gnublin.org/index.php/GPIO<br>
http://falsinsoft.blogspot.de/2012/11/access-gpio-from-linux-user-space.html<br>

see the Kernel documentation for more details:<br>
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt<br>
https://www.kernel.org/doc/Documentation/gpio/gpio-legacy.txt<br>
and so on...