First aid! For details about how to compile the makefile of the gpio driver-Linux general technology-Linux technology and application information, see the following. I need to use the GPIO interface to control the stepper motor. The gpio driver code adds the pin control I need according to the \ drivers \ char \ EmbedSky_gpio.c code under the source code of the k
above interfaces do not have standard device files and their links.(1) Export/unexport file interface:/sys/class/gpio/export, this interface can only write unreadableThe user program writes the GPIO number to the kernel to request that the control of a gpio be exported to the user space without the kernel code request
Through the Sysfs control Gpio, first access to the/sys/class/gpio directory, the export file to write the Gpio number, so that the Gpio operation interface from the kernel space exposed to the user space, Gpio operating interface
by Sysfs control Gpio, first access the/sys/class/gpio directory, write the GPIO number to the export file, so that the Gpio operation interface from the kernel space exposed to the user space, The GPIO's operating interface includes direction and value, and direction contro
I. Overview
Through the SYSFS mode control GPIO, first access to the/sys/class/gpio directory, write GPIO number to the export file, so that the GPIO operating interface from the kernel space exposure to user space, GPIO operating
Gpio Library core function, of course, is the operation of Gpio, Gpio is the "general input/Output" interface, such as lighting a LED, relays, or through the IIC SPI 1-wire and other protocols, read, write data, this is the use of Gpio, can say no
,
. Set_value = Exynos_gpio_set_value,
. get_function = exynos_gpio_get_function,
. xlate = Exynos_gpio_ Xlate,
};
In these methods of operation, the corresponding registers of the GPIO will be directly manipulated.Take Exynos_gpio_set_value as an example:
static int Exynos_gpio_set_value (struct udevice *dev, unsigned offset,
int value)
//With the bank corresponding to the Udevice, And the offset in t
From http://www.cnblogs.com/xiaobo-Linux/p/8969324.html command line control LED lightecho >/sys/class/gpio/export Write outputcd/sys/class/gpio/gpio12/Enter this portThe main 2 files Direction/valueDirection control output echo out > Direction/control input echo in > directionValue control high and low level 1, 0 low echo 1 > Value lit/echo 0 > value offRead hig
interruption port
int Gpio_to_irq (unsigned gpio);
The value returned is the interrupt number that can be passed to REQUEST_IRQ () and FREE_IRQ ()
The kernel converts the Gpio port to interrupts by calling the function, and there are similar methods in user space
6 export Gpio port to user space
int Gpio_export (unsigned gp
Gpio is closely related to the hardware system. Linux provides a model for drivers to process gpio in a unified manner. Each card has its own gpio_chip control module: request, free, input, output, get, set, IRQ...
Then, register the control module to the kernel, and then change the global gpio array: gpio_desc [].
When a user requests
Raspberry Pi advanced GPIO library, wiringpi2 for python Use note (3) GPIO operations, gpiowiringpi2
The core function of the GPIO library is to operate GPIO. GPIO is the "general input/output" interface, such as lighting up an LED or relay, or using iic spi 1-wire and other
:
ActiveHigh: When the GPIO is high, the device is active Low: When the GPIO is low, the device is activated the following figure shows the LEDs and buttons are active high and Active low two ways to access Gpio circuit diagramSecond, the software control of GpioIn Linux, GPIO is expressed as a device file, and the ope
set of Gpio number is not complete, but in order to define the size of each group is 32), that is, the index of the X group of the nth Gpio is x*32+y
The logical index GPIO is cast as a pointer to the SUNXI_GPIO_REG * pointer by sunxi_pio_base, and the mapping to the specific register is as follows:
#define GPIO_BANK (PIN) (PIN) >> 5 #define GPIO_NUM (PIN) (PIN)
visible in the current source file. Even if there are functions with the same name in other source files, compilation will not be affected. Here we select the final function sun4i_gpio_init in this driver for full-text analysis.
Static int _ init sun4i_gpio_init (void) {int err; int I; int sun4i_gpio_used = 0; struct sun4i_gpio_data * gpio_ I;/* include/linux/sysfs. h explain struct attribute {const char * name; struct module * owner; mode_t mode;}; struct device_attribute {struct attribute att
resistor setting for each pin within a single port.
GPIO Port Input data register (Gpiox _IDR)
This is a 16-bit read-only register. Each bit represents the input value on a corresponding pin.Reading a ' 0 ' in bit 8 of this GPIOC _IDR register indicates then the voltage on PC8 is 0V (GND).While reading a ' 1 ' in bit 8 of this GPIOC _IDR register indicates that the voltage on PC8 is 3.3V (VDD)
basic idea is to write so much first.Kernel Layer Configuration GPIOIf you want to configure a GPIO pin while writing the kernel driver, you can add it in DTS: Pwd-gpios = In the driver code, you need to include #include gpio_id = Of_get_named_gpio (Your_driver->dev->of_node, "Pwd-gpios", 0);Obtain the ID number of the gp0_07, and then request a Gpio action obje
Linux Gpio provides services to users through SYSFS, and here is a description of the Linux kernel, which you'll learn about.GPIO Sysfs Interface for userspace==================================platforms which use the "Gpiolib" implementors The framework may choose Toconfigure a SYSFS the user interface to GPIOs. This was different from Thedebugfs interface, since it provides control over GPIO direction andv
to the input status ### start sending the command, set the pin to a high level, and wait for DHT11 to pull down the pin. While (gpio. digitalRead (owpin) = 1): pass # If the PIN is always 1, keep waiting. ### If it is pulled low, it indicates that the transmission starts. The response signal + 40-Bit Data + the ending sign contains 42 BITs ### the following cycle for 45 times, deliberately cyclically view the results several times. For I in range (45
bank's methods and parameters, and call Gpiochip_add to register to the kernel.UseThe Development Board has two power LED lamps that are controlled by GPIO ports, respectively:From the circuit diagram, the output of the GPIO port is low, the light is on, and the lamp is off at high power.In addition, several idle GPIO ports are drawn on the expansion slots, resp
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.