Debug one of exynos4412-ARM embedded Linux-LEDS/GPIO drivers, exynos4412leds
/**
**************************************** ***************************************@ Author's brother * @ version V1.0.0 * @ date 2016-02-19 **************************** **************************************** * ********** <Beijing university of posts and telecommunications> ********************* **************************************** **************************************** **************************************** * *************** platform exynos4412 ********************* **************************************** ********************/
1-led hardware Principle
The Led circuit is relatively simple. Generally, a control circuit is built using a transistor.
Shows the control circuit of two LEDs in the schematic diagram. KP_COL0 and VDD50_EN are used to control the LEDs.
As shown in.
When the KP_COL0 and VDD50_EN networks are high, the BE and CE of the transistor L9014 are turned on, which is equivalent to the VSYS voltage of 5 V to 1 K and the Led light, and the light will BE on.
When the KP_COL0 and VDD50_EN networks are low, the BE of the transistor L9014 will end, and the CE will end,
The VSYS voltage equivalent to 5 V is added to 1 K, a small Led lamp, and an infinitely large resistor. If the current is zero, the light will go off.
Call, assign values, and configure 2Led pins
Functions Involving GPIO calls, assignment, and Configuration
2.1GPIO application and release functions
To use any GPIO, you must apply for it first.
The "include/linux/gpio. h" header file contains the Linux default GPIO application function. This header file belongs to the embedded Linux platform and can be used by any embedded linux kernel.
As shown in, run the "vim include/linux/gpio. h" command in the source code directory to open the file.
As shown in, gpio_request is the function used in this experiment.
As shown in, we will briefly introduce the gpio_request function.
First, this function has an important "check" function, that is, if you have applied for this IO elsewhere, an error will be returned here, prompting that it has been occupied. This is a standard usage.
The gpio_request function has two parameters.
Unsigned gpio, The GPIO applied for, is generally the macro definition corresponding to GPIO
Const char * label, which is the name of GPIO for ease of reading
As shown in, the gpio_request function corresponds to the gpio_free function.
After calling the gpio_request function, it indicates to the system that this IO is occupied. When detaching the driver, you usually need to call the gpio_free function to release it.
The parameter of the gpio_free function is relatively simple. Only one GPIO parameter can be defined using the macro corresponding to the GPIO.
As shown in, there is also a value assignment function gpio_set_value.
After the GPIO is configured as the output mode, you also need to assign a value to the GPIO, which is generally high-voltage and low-level.
The two parameters are
Unsigned gpio, GPIO
Int value, high level 1 and low level 0.
2.2Macro definition of GPIO configuration parameters
GPIO is initialized in Linux. After ing, the GPIO operation function is called to operate the GPIO macro definition.
This GPIO macro definition file is provided by the original manufacturer. It must have been prepared and belongs to the BSP board-level development kit.
As shown in, use commands in the source code directory.
"Vim arch/arm/mach-exynos/include/mach/gpio-exynos4.h" open the file.
As shown in, we can see that all GPIO has been defined.
Find the KP_COL0 and VDD50_EN networks in the schematic diagram and connect them to the section above 4412, as shown in.
2.3GPIO configuration functions and Parameters
In Linux, the configuration functions and parameters of GPIO have been integrated into the Samsung board-level development kit.
Let's take a look at the configuration function, as shown in. Use the command in the source code directory.
"Vim arch/arm/plat-samsung/include/plat/gpio-cfg.h" open the file.
As shown in, the initi_gpio_cfgpin function is required in this experiment.
As shown in, the function extern int initi_gpio_cfgpin (unsigned int pin, unsigned int );
Generally, functions with s3cxxx are functions that can be used by the Samsung platform.
There are two parameters in the configuration function of the pin of the gpio_cfgpin.
Parameter unsigned int pin, pin
The parameter unsigned int to is configured.
Let's take a look at the configuration parameters, as shown in. Use the command in the source code directory.
"Vim arch/arm/plat-samsung/include/plat/gpio-cfg.h" open the file and configure parameters and functions are in the same function.
As shown in, for GPIO, You need to configure it as the output mode, which corresponds to the macro definition of initi_gpio_output.
I have a limited level and it is not easy to grasp the difficulties. So I want to write and help you step by step!
For the compilation of simple applications and testing, see: Debugging exynos4412-ARM embedded Linux-LEDS/GPIO driver II