Android Deep Exploration (Vol. 1) HAL and Driver Development chapter seventh

Source: Internet
Author: User

NotLinuxThe driver writes data directly to the memory in the hardware, but with the nativei/0Memory (I/O Memory, which is in kernel space for interaction. So-called1/0memory is through various interfaces (PCI,USB, Bluetooth, Ethernet port, etc.) connected to the host (PC, the hardware of the mobile phone (network card, sound card, camera, etc.) in the host memory mapping. For example, inUbuntu LinuxRunning on the drive only requires access to runUbuntu Linuxthe host in the/ omemory, and thenLinuxThe kernel will usei/0in-memory data hardware interaction. Linuxthe kernel's memory management module is responsible for synchronizingi/0the data in the memory and hardware.

The LED driver does not use misc_register to build the device files, but instead uses a more flexible way to create the device files. the LED Driver also provides two ways of interacting: command and read-write device files.

LedThe driver creates adev/s3c64 l O _ledsdevice files, theLinuxDrive can control4aLED(Next to the silver Tun of the Development Board, close to the batteryLEDnumber isL, the farthest away from the electric groundLEDnumber is4)。 through to/DEV/S3C64 L OLEDsSend length to1to the4the string can control the4aLEDthe switch. Lindicates open,0indicates off. If the string is not long enough4equivalent to the back of the0.

To create an LED -driven device file :

Step 1 : Initialize the Cdev with the cdev_init function .

Step 2 : Specify the device number.

Step 3 : Use the cdev_add function to add a character device to the character device array in the kernel.

Step 4 : Use the class_create macro to create a struct class .

Step 5 : Use device::.. The create function creates a device file.

Android Deep Exploration (Vol. 1) 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.