Android Deep Explore seventh chapter

Source: Internet
Author: User

The Linux driver interacts directly with the hardware, but not the Linux driver writes the data directly to the memory in the hardware, but interacts with the native I/O memory. Every hardware that connects to Linux has a map header address in I/O memory. This hardware is detected by any modern operating system host when it is plugged into the hardware, but the hardware is detected only to indicate I/O memory is established in the kernel space, the program that wants user space can access the hardware, and the driver that can interact with I/O memory must also be installed.

Readers can create a device file based on the following steps:

(1) Initialize the Cdev with the Cdev_init function;

(2) Specify the device number, can be specified directly in the code can also be dynamically assigned;

(3) Use the Cdev_add function to add the character device to the character device array in the kernel;

(4) Create struct class with Class_create macro;

(5) Create a device file using the Device_create function;

Uninstalling a Linux-powered device file is a bit simpler, and you need to call the Device_destroy,class_destroy and Unregister_chrdev_region methods in turn.

You must know how to set the register before controlling the led to light off. The ARM processor has multiple registers, and by setting the register value, you can set the status of the LED PIN, open or disable the pull-up circuit, and control the LED's light off. Wherein the LED has two pins, the control led needs three registers to complete, each register can use 4 bytes, using the low 16 bits of the Gpmcon register to set the LED two port properties to output. The low 4-bit control using the Gpmdat register controls 4 LEDs, and the low 8 bits of the GPMPUD register open the pull-up circuit for 4 LEDs respectively.

Android Deep Explore seventh chapter

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.