Android Drive Development (vii)----LED will blink for me: control Light Emitting diodes

Source: Internet
Author: User

In this section, the author describes the driver development of Android by using an instance control led. Unlike the previous section, the previous chapter uses function misc_register when registering and uninstalling device files, while in LEDs, functions such as cdev_init are used. The difference is: the former can only establish the main device number of 10 device files, use is not flexible enough, the latter class to establish other device number of equipment files, and can build multiple device files (in the parameters of the Device_create function can be associated with the corresponding settings).

In addition, in this section, mainly for the control of the LED, to control the LED, it is necessary to understand which hardware should be controlled to achieve the final effect. That is, three registers, Gpmcon, Gpmdat, gpmpud three registers. To write different content to three registers, the LED will appear differently. Of course, to use three registers, it is necessary to initialize the three registers, whose initialization should be initialized in the LEDS_INIT_GPM function, the corresponding code is:

TMP = IOREAD32 (S3c6402_gpmcon);
TMP &= (~0XFFFF);
TMP |= 0x1111;
IOWRITE32 (TMP, S3c6402_gpmcon);

TMP = IOREAD32 (S3C6402_GPMPUD);
TMP &= (~0XFF);
TMP |= 0xAA;
IOWRITE32 (TMP, S3C6402_GPMPUD);

TMP = IOREAD32 (S3c6402_gpmcon);
TMP &= (~0XF);
TMP |= Leds_default;
IOWRITE32 (TMP, S3c6402_gpmcon);

In addition, there are two ways to implement control LEDs, one is to control LEDs through strings, and one to control LEDs through I/O commands. In the previous section, the former was used, and the function used was file_operations.write. The latter is used in this section, and the function used is file_operations.ioctl. This function can receive commands and parameters sent to a character device.

Android Drive Development (vii)----LED will blink for me: control Light Emitting diodes

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.