2950 views|0 replies

146

Posts

0

Resources
The OP
 

Practical information! The most comprehensive Linux application development case sharing, including key codes! [Copy link]

Table of contents

1. tl_led_flash example

1.1 Case Function

1.2 Operation Instructions

1.3 Key Code

2. tl_key_test case

2.1 Case Function

2.2 Operation Instructions

2.3 Key Code

3. tl_uart_rw example

3.1 Case Function

3.2 Operation Instructions

3.3 Key Code

I have met many newbies who asked, "Can you share some Linux application development cases?" I have always used Windows for development, but now I want to try Linux for development, etc.

In response to the needs of our users, today we will share with you
a series of development boards based on the TL335x-EVM (AM3352/AM3354/AM3358/AM3359) ARM Cortex-A8 architecture of Chuanglong Technology, and explain in detail the application development cases of Linux, covering the tl_led_flash case, tl_key_test case, tl_uart_rw case, tl_can_echo case, tl_devmem_rw case, tcp_udp_demos case, Python development case, etc.

If you need to recompile the Linux common development cases, please copy the corresponding case src directory to the Ubuntu working directory, enter the src directory and execute the following command to load the Linux Processor SDK environment variable, and execute the make command to compile the case. After the compilation is complete, an executable file will be generated in the current directory.

Host# source /home/tronlong/ti-processor-sdk-linux-rt-am335x-evm-04.03.00.05/linux-devkit/environment-setup

Host# make

If you need to recompile the Linux common development cases, please copy the corresponding case src directory to the Ubuntu working directory, enter the src directory and execute the following command to load the Linux Processor SDK environment variable, and execute the make command to compile the case. After the compilation is complete, an executable file will be generated in the current directory.

Host# source /home/tronlong/ti-processor-sdk-linux-rt-am335x-evm-04.03.00.05/linux-devkit/environment-setup

Host# make

figure 1

Common Linux development cases

1. tl_led_flash case

1.1 Case Function

In this case, the LED flashing effect is achieved by repeatedly writing 1 and 0 values to the evaluation board user indicator LED device node. The LED on and off time is 0.5s.

The program flow is shown in the figure below:

Figure 2

The LED device node is brightness in the "/sys/class/leds/user-ledX/" directory.

Figure 3

1.2 Operation Instructions

Copy the executable program tl_led_flash in the bin directory of this case to the evaluation board file system, and execute the following command in the directory where the executable program is located to run the program. You can see that the evaluation board LED flashes at an interval of 0.5s. At the same time, the serial terminal prints the system's entire LED device information and the LED device information currently controlled by the program.

Target# ./tl_led_flash -help

Target# ./tl_led_flash -n 3

Figure 4

1.3 Key Code

  1. Predefined LED array. The program obtains LED information from this array. The array information must be the LED information already in the system, otherwise the program will report an error.

Figure 5

2.LED on and off operation and time interval.

Figure 6

2. tl_key_test case

2.1 Case Function

This case detects key events by monitoring the status of the user key KEY5 device node.

The program flow is shown in the figure below:

Figure 7

The user key device node is "/dev/input/event1". After obtaining the key event, the key value is matched and then the event is processed.

2.2 Operation Instructions

Copy the executable program tl_key_test in the bin directory of this case to the evaluation board file system, and execute the following command in the directory where the executable program is located to run the program. The serial terminal will print prompt information. Then press the evaluation board user button KEY5, the program will detect the key event and print the key status information.

Target# ./tl_key_test -help

Target# ./tl_key_test -d /dev/input/event1

Figure 8

2.3 Key Code

1. Define the buttons.

Figure 9

2. Listen for key events.

Figure 10

3. Loop monitoring.

Figure 11

3tl_uart_rw example

3.1 Case Function

This case mainly implements serial port reading and writing functions.

The program flow is shown in the figure below:

Figure 12

The device nodes of RS232 and RS485 serial ports are "/dev/ttyS0" and "/dev/ttyS1" respectively. When the serial port is initialized, the baud rate, mode, data bits, stop bits and other parameters will be set. The serial port is read and written through the device file descriptor.

3.2 Operation Instructions

Use an RS232 crossover female serial cable and a USB to RS232 male serial cable to connect the RS232 serial port of the evaluation board to the USB port of the PC, as shown in the figure below.

Figure 13

Copy the executable program tl_uart_rw in the bin directory of this example to the evaluation board file system, enter the directory where the executable program is located, and execute the following command to view the program parameter information.

Target# ./tl_uart_rw -h

Figure 14

Execute the following command to read RS232 serial port data.

Target# ./tl_uart_rw -d /dev/ttyS0 -r -s 8

Open the serial debugging tool SerialDebug.exe in the directory "4-Product Information\Tools\Windows\" in the product information, open the PC device manager, confirm the RS232 serial port COM port number, and follow the steps in the figure below to operate or set up, and send data from the serial debugging tool to the RS232 serial port. The debugging serial terminal will print the data read from the RS232 serial port.

Figure 15

Figure 16

Execute the following command to write RS232 serial port data. The data has been defined in the program. The serial port debugging tool will print the data received from the RS232 serial port.

Target# ./tl_uart_rw -d /dev/ttyS0 -w -s 8

Figure 17

Figure 18

Use the RS232 to RS485 module and USB to RS232 male serial cable to connect the RS485 serial port of the evaluation board to the USB port of the PC, as shown in the figure below.

The method of connecting the RS232 to RS485 module and the RS485 serial port on the evaluation board is as follows:

  1. The 485+ terminal of the RS232 to RS485 module is connected to the RS485 serial port A terminal of the evaluation board.
  2. The 485-terminal of the RS232 to RS485 module is connected to the RS485 serial port B terminal of the evaluation board.
  3. The GND terminal of the RS232 to RS485 module is connected to the GND terminal of the RS485 serial port on the evaluation board.

Execute the following command to read and write data from the RS458 serial port. The test steps and phenomena of the RS485 serial port are similar to those of RS232. Just change the device node in the command from ttyS0 to ttyS1.

Target# ./tl_uart_rw -d /dev/ttyS1 -r -s 8 //RS485 serial port data read operation

Target# ./tl_uart_rw -d /dev/ttyS1 -w -s 8 //RS485 serial port data write operation

3.3 Key Code

  1. Serial port initialization function.

Figure 20

2.Serial port reading and writing functions.

Figure 21

Figure 22

3. Loopback test.

Figure 23

4. Related logic.

Figure 24

Since the development case is too long, I divide it into several versions. Today I will talk about the tl_led_flash case, tl_key_test case, and tl_uart_rw case. If you are interested, please like and leave a message in the comment area to discuss with me!

This post is from ARM Technology
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list