Nineth chapter, Hardware abstraction Layer: HAL reading notes

Source: Internet
Author: User

steps to write a Linux driver

First step: Build Linux driver skeleton (load and unload Linux drivers)

Step two: Register and unregister the device files

Step three: Specify driver-related information

Fourth step: Specify the back-off function

Fifth Step : writing business logic

Sixth step: Writing the makefile file

Seventh step: Writing Linux drivers

Eighth Step: Install and uninstall Linux drivers

The Printf function runs in user space, andtheprintk function runs in kernel space.

Testing Linux driver steps

First step: Import the test_count.c file

Step two: Set the include path

Step three: Set up target

Fourth step:build Project

Fifth step: Run the test program

For aLinuxdriver, you can start atUbuntulinuxto do pre-development and testing. The parts that access the hardware can beUbuntulinuxsimulation with the software. When the basic development is finished, it is necessary to test the actual hardware on the Development Board or the engineering prototype. We can test it in a variety of waysLinuxdrive, mainly withUbuntulinuxtesting, inAndroidthe simulator passes the native (native)CProgram TestingLinuxDrive, useANDROIDNDKTestLinuxDrive, useJavasource code directly manipulate device files to testLinuxDrive, uses3c6410Dev Board TestLinuxDriver , you can also compile the driver into theLinuxKernel for testing.

A complete Linux driver consists mainly of internal processing and interaction with hardware. The internal processing mainly refers to the linux driver loading, unloading, device file-related action processing, and business logic. Interaction with hardware mainly refers to the interaction of data with registers in hardware through functions such as ioweite,ioread32 and so on. The porting of Linux drivers on different platforms is also handled in these two parts. If the porting between different Linux kernel versions is primarily porting part 1 , if the porting on different hardware platforms, the primary is porting the second part.

The steps to write LED light drivers are as follows:

1, create the LED Drive equipment files:

(1) Initialize the cdevwith the cdev-init function ;

(2) specify the device number;

(3) use the cdev_add function to add the character device to the character device array in the kernel;

(4) Create struct classwith class_creat macro;

(5) Create a device file using the device_create function;

2.uninstalling the Led driver's device files

3. Set register and initialize led driver

4, control led lights:

(1) control LED via string

(2) control via I/o command

5 . Module parameters of LED driver

6. Test LED driver

(1) A general program for writing test I/O control commands;

(2) using NDK to test LED driver;

(3) using Java test LED driver;

7,Led Drive transplant

Nineth chapter, Hardware abstraction Layer: HAL reading notes

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.