The seventh chapter is mainly about the control of light emitting diode driver, used to control the Development Board of the 4 LED lights

Source: Internet
Author: User

First of all, the implementation of the LED driver principle, the Linux driver is not directly to the memory of the hardware to write data, but with the native I/O memory interaction, each of the hardware connected to Linux in I/O memory will have a map of the first address.

To write the driver, first create the LED-driven device file:

1. Initialize the Cdev with the Cdev_init function

Describing the device file requires a CDEV structure, cdev Most of the member variables do not require us to initialize, as long as the Cdev_init function can be called to initialize the majority of the Cdev member variables

2. Specify the device number

The file number of the Linux device is the main device number and this device number, the device number is specified in two ways: directly in the code, and dynamically assigned.

3. Use the Cdev_add function to add a character device to the character device array in the kernel, and call the Cdev_add function to specify the device file pointer, device number, and number of device files.

4. Create a struct class using the Class_create macro

5. Create a device file using the Device_create function

Uninstalling the LED driver's file requires calling the Device_destroy, Class_destroy, and Unregister_chrdev_region methods in turn.

You must know how to set the register before controlling the LED light on or off.

LED drivers can use two ways to control LED lights:

1. Control the LEDs via a string;

2. Control the LEDs with the I/O command.

Test LED Driver:

1. Test led driver with NDK

2. Test LED driver using Java

The drive to control LED lights is the first and hardware-bound driver of this book, although the program is not complex, but includes all the necessary parts of Linux drivers.

The seventh chapter is mainly about the control of light emitting diode driver, used to control the Development Board of the 4 LED lights

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.