Android Deep Explore (Volume one) HAL and Driver Development chapter seventh

Source: Internet
Author: User

By learning Android Deep Exploration (Volume one) HAL and driver development in the seventh chapter let me know how to control the light emitting diode through the driver, realize the driver directly interacts with the hardware.

A complete Linux driver mainly consists of internal processing and hardware interaction, in which the internal processing mainly refers to the Linux driver loading, unloading, device file-related action processing and business logic, etc., and the hardware interaction mainly refers to the function and the hardware register to interact with the data.

LED driver Implementation principle: Although the Linux driver deals directly with the hardware, it is not the Linux driver that writes data directly to the memory in the hardware, but interacts with the native I/O memory. Every hardware that connects to Linux has a mapped first address in I/O memory.

Also understand and note: LEDs have two pins: GPB0 and GPB1, control LEDs need to be completed by 3 registers, 3 registers are gpmcon,gpmdat and gpmpud, each register can use 4 bytes ; Use the low 16 bits of the Gpmcon register to set the two port properties of the led to output, the low 4 bits of the Gpmdat register to control the light off of 4 LEDs, and the low 8 bits of the GPMPUD register to turn on the pull-up circuit of the 4 LEDs respectively.

To create an LED-driven device file: The first step is to initialize the Cdev with the Cdev_init function; The second step is to specify the device number, and the device number is specified in the code and assigned dynamically in two ways, and the third step is to use the CDEV_ The Add function adds a character device to the character device array in the kernel; Fourth, create a struct class using the Class_create macro, and fifth step, create the device file using the Device_create function.

Android Deep Explore (Volume one) HAL and Driver Development chapter seventh

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.