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