Seventh chapter LED will blink for me: Control the Light emitting diode

Source: Internet
Author: User

The main steps of the simple led program are as follows:
First: Create LED-driven device files
1. Initialize the Cdev with the Cdev_init function
2. Specify the device number
3. Use the Cdev_add function to add a character device to a character device array in the kernel
4. Create Struct_class using Class_create macros
5. Create a device file using the Device_create function
II: Uninstall the LED drive device files
Three: Set register and initialize led driver
Four: Control LED (and so-called code writing--LINUXC language)
An example of an implementation method is as follows:
In a hybrid device driver, you need to populate the file_operations structure, and then set the Miscdevices value for each field and register it with the kernel. The detailed process is as follows:
1. Writing the IOCTL interface function
2. Fill in the file_operations structure, mainly by registering the IOCTL function
3. Fill the miscdevice structure, mainly the secondary device number, FoPs, and device name.
4. Write the initialization code that you want to provide to the Module_init macro, set the LED port to output, and register it with the kernel.
5. Write the logoff code to be provided to the Module_exit macro, primarily to unregister the Miscdevice device registered with the kernel in the initialization
The LED driver includes the necessary parts of the Linux drive. A complete Linux drive consists mainly of internal processing and interaction with hardware. The internal processing mainly refers to the Linux driver loading, unloading, device file-related action processing, and business logic.

Address: http://www.cnblogs.com/zpm123123

Seventh chapter LED will blink for me: Control the Light emitting diode

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.