NXP
Cortex-A7
Development Board
i.MX6UL Elite
i.MX6UL Universal
i.MX6ULL
Cortex-A9
Development Board
i.MX6Q-Connector
i.MX6Q-Stamp Hole
i.MX8M Mini
SAMSUNG
Cortex-A9
Development Board
4412 Elite
4412 Universal
4418 Connector
4418-Stamp Hole
Kenel Board
4412(SCP)
4412(POP)
iTOP-4418
6818 Stamp Hole
4418 Stamp Hole
Cortex-A53
Development Board
6818 Connector
6818-Stamp Hole
Kenel Board
iTOP-6818
Rockchip
loongson
STMicroelectronics
Intelligent terminal
HMI
Embedded Computer
eTOP-6UL-MANNV10
LCD Module
Date: 2020-12-16
The experimental routine path: I.MX6ul Terminator CD data /06_Linux driver routines /08_key
After adding the hardware information of the keys in the device tree file, create the key.c file and write the driver program. The specific content is as follows:
In line 36, add a keyvalue to the device structure of the key to record the keyvalue.
In lines 47 to 65, the function keyio_init is used to initialize the key, get the GPIO information of the key from the device tree, and then set it as input. The key initialization code is extracted as an independent function to improve the modular design of the program.
In lines 74 to 85, the key_open function initializes the keystroke I/O by calling the keyio_init function, which initializes the keystroke I/O each time the application opens the keystroke driver file.
On lines 95 to 112, the key_read function is executed when the application reads the key value through the read function. Line 110 reads the level of key IO. If 0, the key is pressed. If the key is pressed, line 111 waits for the key release. After the key is released, mark the key value as 0xF0.
Line 130 calls the atomic_set function to initialize the atomic variable to an invalid value by default.