Sponsored Content
Full Discussion: GPIO and sysfs
Top Forums UNIX for Advanced & Expert Users GPIO and sysfs Post 303030779 by Circuits on Friday 15th of February 2019 11:08:29 AM
Old 02-15-2019
@Corona688 Thanks I will be sure to change my code! So I did managed to figure out the gpio lib. Apparently there is a formula that the Linux kernel uses for identifying pins based on their GPIO number:

linux gpio number = (gpio_bank - 1) * 32 + gpio_bit

So if you're pin is: GPIO2_18, then in the Linux kernel that would be: (2-1)32+18 = 50

That is the number you would have to reference in order to toggle the pin from within the user space using gpiolib.
These 2 Users Gave Thanks to Circuits For This Post:
 

2 More Discussions You Might Find Interesting

1. Programming

Unable to reference sysfs on Linux.

I am porting C code to a linux system but I am unable to link a call to the sysfs function. An excerpt from my code is: if (fstat(fileno(TrCtl.Fp), &fsstat) != -1) { (void) sysfs(1, fsname); if (strcmp(fsname, "nfs")) { (void) lockf(fileno(TrCtl.Fp), F_LOCK, 0L); ... (5 Replies)
Discussion started by: mbb
5 Replies

2. Linux

Query about creating sysfs directory under device driver

Hi all, Currently i am involved in developing a device driver for a custom hardware. My linux stack already has the sysfs directory structure /sys/class/hwmon/ My need is that, while loading my device driver i need to create a "xyz" sysfs directory inside hwmon sysfs directory as... (0 Replies)
Discussion started by: cbalu
0 Replies
GPIOLOCK(4)						   BSD Kernel Interfaces Manual 					       GPIOLOCK(4)

NAME
gpiolock -- support for multi-position keylocks attached to GPIO pins SYNOPSIS
gpiolock* at gpio? offset ? mask ? gpiolock* at gpio? DESCRIPTION
The gpiolock driver allows connecting of multi-position keylocks over GPIO pins. The keylock driver registers with an in-kernel keylock sup- porting system and provides kauth(9) support through an experimental security model. The keylock state can be queried using the hw.keylock sysctl variables. Only locks with 2-4 positions are currently supported. The pin number is specified in the kernel configuration with the offset locator. The mask locator denotes the pins used for the lock (minimum 2, maximum 4 pins are used). The offset and mask can also be specified when gpiolock is attached at runtime using the GPIOATTACH ioctl(2) on the gpio(4) device. SEE ALSO
gpio(4), intro(4) HISTORY
The gpiolock driver first appeared in NetBSD 6.0. AUTHORS
The gpiolock driver was written by Marc Balmer <marc@msys.ch>. BSD
August 21, 2009 BSD
All times are GMT -4. The time now is 07:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy