The seventh chapter led will blink for me: control luminous Two-tube reading notes

Source: Internet
Author: User

First, the realization principle of LED drive

Linux driver and hardware interaction principle: Linux Drive and I/O memory through the IOREAD30 and IOWRITE32 functions, I/O memory and hardware, memory management module is responsible for synchronizing I/O memory and hardware in Germany data.

Second, write led driver

Where 1 means open, 0 indicates off. When the string length is less than 4, it is equivalent to 0 of the following

1. Create LED-driven device files

(1) Initialize the Cdev with the Cdev_init function

(2) Specify the device number

The device number of the Linux device file is the primary device number and the secondary device number, the first 12-bit main device number, and the last 20 bits represent the secondary device number.

Device number Designation Method: Specify (hard code) directly in the code, dynamically assign

Multiple Linux device files can have the same main device number. However, the main device number and the secondary device number of the two devices will not be the same.

(3) using the Cdev_add function to add a character device to the kernel in the German character device array

(4) Create a struct class using the Class_create macro

(5) Create a device file using the Device_create function

2. Uninstalling the LED-driven device files

Call three methods in turn:

Void Device_destroy (struct class *class,dev_t devt)

Void Class_destroy (struct class *cls)

Void unregister_chrdev_region (dev_t from,unsigned count)

3. Setting the register and initializing the LED driver

4. Control LED

(1) control led via string

(2) control led via I/o command

Module parameters for 5.LED drives

If you have more than one module parameter in your Linux driver, you need to enclose these parameters in single or double quotation marks.

Third, Test led driver

1. General procedures for writing test I/O control commands

2. Test led driver with NDK

3. Test LED driver using Java

Four, LED-driven transplant

The seventh chapter led will blink for me: control luminous Two-tube reading notes

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.