[Beijing Xunwei] i.MX6ULL Terminator Linux RS232/485 driver experiment RS232 driver

The UART driver NXP of I.MX6U has been written, so we don’t need to write it. What we need to do is to add the device node corresponding to UART3 in the device tree.

1 Add UART3 node to device tree

Open the topeet_emmc_4_3.dts file, first add the pinctrl child node corresponding to UART3, and add the following content in iomuxc:

1 pinctrl_uart3: uart3grp {
    
     
2 	fsl,pins = < 
3 			MX6UL_PAD_UART3_TX_DATA__UART3_DCE_TX 0X1b0b1 
4 			MX6UL_PAD_UART3_RX_DATA__UART3_DCE_RX 0X1b0b1 
5 	>; 
6 };

Then check if the two pins UART3_TX and UART3_RX are used for other functions, and if so, shield them to ensure that these two IOs are only used for UART3.
After adding the pinctrl child node, add the uart3 node, which is still in the topeet_emmc_4_3.dts file. There are two nodes uart1 and uart2 in the topeet_emmc_4_3.dts file by default, as shown in Figure 1.1:
Insert picture description here

Figure 1.1

Because uart2 is not used, and the IO of uart3 is used in the pin node of uart2, uart2 needs to be commented or deleted. Then add uart3 node, the content is as follows:

1 &uart3 {
    
     
2 		pinctrl-names = "default"; 
3 		pinctrl-0 = <&pinctrl_uart3>; 
4 		status = "okay"; 
5 }; 

After the addition is complete, recompile the device tree file, and then use the new device tree file to start the Linux system. After the system is started, a device file named "/dev/ttymxc2" will be generated. ttymxc2 is the device file corresponding to UART3. The application program can access ttymxc2 to realize the operation of UART3.

Insert picture description here

Guess you like

Origin blog.csdn.net/BeiJingXunWei/article/details/112650429