Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Learning notebook-character device control

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Enter the character device control of the iTOP4412 development board, the main learning content is to transfer parameters through the main function to achieve "LED light on and off", "buzzer pronunciation", ADC conversion and other functions.

(the quality of these tutorials is not high, and the test code introduces a lot of optional format / numerical judgment statements. Real learners will focus on the application of knowledge points, and only those who have nothing to do will enter some non-compliant characters. Let the program run wrong. Video tutorials spend a lot of time writing these things, and then compile them over and over again, looking drunk.)

Baidu found the relevant definitions as follows:

Ioctl is a function in the device driver that manages the device's I _ max O channel. Of course, you can also use other means to achieve IPUP O control, first of all, use it slowly.

The main function used in character device control is: int ioctl (int fd,int cmd,int req.) Fd is the file marker that opens the driver file (or "handle"). Personally, I don't like this translation, which is too pretentious (a simple and intuitive concept, you have to come up with a professional word to show off). In fact, it is a file marker, in principle, a file pointer. It is defined as output high / low level in cmd=command (command) driver and control object in req=request (request) driver.

Specific operation steps of LED and buzzer peripherals:

1. Write a C program

1) header file reference (same as open reference)

2) passing parameters of main function

3) the open function opens the driver file (here is a judgment to facilitate debug)

4) after successfully opening it, call the ioctl function to control the device output

5) close function releases resources

two。 Put the .c file into the directory specified by the Ubantu system through SSH, and use the arm cross compiler to compile the .c file into a binary file.

3. Copy the binary file to the U disk through SSH, insert it into the development board with the smallest system, and mount it.

4. Execute the binary file, passing the parameters cmd (on, off), req. (which LED). (end)

Specific operation steps of ADC peripherals:

1. Write a C program

1) header file reference (same as read reference)

2) declare char cache array variables and initialize the array with the memset function.

3) the open function opens the driver file (here is a judgment to facilitate debug)

4) after successfully opening it, call the read function to read the data and store it in the cache (determine the return value to facilitate debug), and strongly convert the char in the cache to int type for standby.

5) the range is converted to output the resistance value (of course, the range can be customized, such as percentage, etc.)

6) close function releases resources

two。 Put the .c file into the directory specified by the Ubantu system through SSH, and use the arm cross compiler to compile the .c file into a binary file.

3. Copy the binary file to the U disk through SSH, insert it into the development board with the smallest system, and mount it.

4. Execute the binary file, adjust the potentiometer, execute again, adjust again. The changing trend of numerical value was observed. (end)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report