The experiment in this chapter will realize the real Linux driver, which will realize the direct interaction with the hardware. 4 LED lights need to be controlled .
the implementation principle of 7.1LED drive
In fact, it is not the Linux driver that writes data directly to the memory in the hardware, but interacts with the native I/O memory. I/o Memory is a mapping of hardware in host memory that is connected to the host through various interfaces.
7.2 Writing LED Drivers
1. Create LED -driven device files
(1). Use Cdev_init Initialization of functions Cdev
(2). Specify the device number
(3). Use Cdev_add function to add a character device to a character device array in the kernel.
(4) Use class_create Macro Creation struct class
(5) Use device_create function to create a device file
2. uninstalling the LED -driven device files
3. setting the register and initializing the LED driver
4. control LED
7.4LED -driven porting
Because the LED driver does not invoke too many Linux kernel APIs, these APIs are less likely to be lost, So porting to the kernel only needs to be recompiled. Porting Linux drivers is very important, is to modify the Linux driver source code, should try not to modify the Linux The driver interface.
In a complete Linux Drive, mainly consists of internal processing and hardware interaction two parts. If the inter-Linux porting between different versions , the main porting of the first part, on different hardware platforms, then the main second part.
Software 1308 class 31st Zhang Fan Blog Park address: http://home.cnblogs.com/u/sxauzzz/
Android Deep Explore (Volume 1) HAL with Driver development seventh chapter LED will blink for me: Control led reading notes