Embedded linux of --LED drive (character device)

1, define inlet and outlet and function declarations protocol driver:
Here Insert Picture Description
2, the registration process of the specific function definitions and the inlet and outlet of a character device driver:
Here Insert Picture Description
Description: There are two functions and register_chrdev_region alloc_chrdev_region, and look at its prototype the following effects:

If we already know the device number to be assigned to use this function is:
Here Insert Picture Description
if we do not know the device number, the system automatically assigns want, then call this function:
Here Insert Picture Description
3, but there is a structure file_operations (see my explanation structure another article: embedded linux of --LED drive (miscellaneous equipment)):
Here Insert Picture Description
4, ioctl direct control chip pin lighting, and no technical content, computing chip pin attention to:
Here Insert Picture Description
led_open and led_release the time being it did not dry, keep adding it later;

5, loading skin LED driver: insmod led_test.ko

6, view the newly loaded device number: CAT / proc / Devices
Here Insert Picture Description
. 7, establish a device file: mknod / dev / led_test c 255 0, then you can see it in the drive led_test dev directory:
Here Insert Picture Description
8 point lights:
Here Insert Picture Description
the OK , we're done, wash sleep

Guess you like

Origin blog.csdn.net/weixin_45264317/article/details/94591382