Serial configuration of Hisilicon HI35xx platform

Foreword

The serial interface is abbreviated as serial port (commonly referred to as COM interface), which is an extended interface using serial communication. Its characteristic is that the communication line is simple. As long as a pair of transmission lines can achieve two-way communication, which greatly reduces the cost, but the transmission speed is general, The data transmission rate is 115kbps ~ 230kbps. Asynchronous serial UART (Universal Asynchronous Receiver / Transmitter), that is, universal asynchronous receiver / transmitter. UART is a chip that converts parallel input to serial output (such as MAX232, MAX485, etc.), and they are usually integrated on the motherboard. Another function of the UART chip is to convert the TTL logic level, which is a hardware logic implementation and does not require software intervention. Common interface standards of UART are RS-232 and RS-485, among which the maximum transmission distance of RS-232 is about 15 meters and the maximum rate is 20kb / s; and the maximum transmission distance of RS-485 is about 1219 meters and the maximum transmission rate 10Mb / s. The difference between the transmission rate and the transmission speed of these two interface standards is mainly due to the difference in the logic level and the anti-interference ability of the signal transmission. .
 

 

Hisilicon UART

In the HiSilicon chip architecture, the UART mainly transfers the data from the peripheral device to the internal bus after serial-to-parallel conversion, and outputs the data to the peripheral device after parallel-to-serial conversion, thereby achieving communication between the two chips. Hi35XX provides 3 UART units:

UART0: 4-wire UART, can be used for debugging, alarm and PTZ control.

UART1: 2-wire UART, can be used for debugging and alarm.

UART3: 2-wire UART, can be used for debugging and alarm.

UART configuration:

1. Support programmable bit width of data bit and stop bit. The data bit can be set to 5/6/7/8 bits by programming, and the stop bit can be set to 1bit or 2bit by over programming.

2. Support odd or even check mode or no check.

3. Support rate programmable, support 9600bit / s, 14400bit / s, 19200bit / s, 38400bit / s, 57600bit / s, 76800bit / s, 115200bit / s, 230400bit / s, 460800bit / s baud rate optional .

 

Hass UART enabled

HiSilicon only enables the UART0 unit as a debugging function by default . In practical applications, we often need to use UART1 and UART2 to interface with peripheral devices to achieve serial communication. At this point we need to configure the UART1 and UART2 units to be enabled . This process is divided into 3 steps:

Ensure that the hardware IO port design and clock frequency are normal.
Check the IO port multiplexing relationship used by the UART unit.
Configure the kernel and map the UART to the device file. The
hardware circuit part is wired and connected as required. There is generally no problem. Configuration and kernel configuration.

The above table is the HiSilicon chip IO port multiplexing relationship table. It can be seen that most of the default functions of the IO ports are not used as UART units, so you need to configure their multiplexing relationship. You can use the following command in the system startup script To configure the multiplexing relationship of the IO port:

sky 0x120F00F8 0x1

sky 0x120F00FC 0x1

……

The next step is to configure the kernel to map the UART unit to a device file under linux. This is mainly related to the change of HiSilicon's device tree, which is relatively simple. Enter the SDK directory \ osdrv \ opensource \ kernel \ linux-3.18.y \ arch \ arm \ boot \ dts and find the following device tree file.
 

 

Modify the following: 

At this point, the configuration of the HiSilicon UART unit is complete, recompile the kernel, and burn the kernel to run. If there is nothing abnormal, the following three device files will appear in the / dev / directory on the device, and then the software can program the device file.

/ dev / ttyAMA0

/ dev / ttyAMA1

/dev/ttyAMA2

 

Published 115 original articles · Like 29 · Visitors 50,000+

Guess you like

Origin blog.csdn.net/huabiaochen/article/details/103401366