UART
Update time:2018-04-13 Views:2918
1 Intro
AIO-3288J support SPI bridge / expansion of four enhanced functions of the serial port (UART), respectively UART2, RS232 (上), RS485, UART3 and three master comes with serial ports, respectively, UART1, RS232(下) Debug serial port. Each UART has a 256-byte FIFO buffer for data reception and transmission. among them:
UART1 ~ UART3 are TTL level interface, RS232 is RS232 level interface, RS485 is RS485 level interface
Each sub-channel UART baud rate, word length, parity format can be set independently, up to 2Mbps communication rate
Each sub-channel has a receive / send independent 256 BYTE FIFO, FIFO interrupt can be programmed according to user needs Trigger point
With sub-serial port receive FIFO timeout interrupt
Support for start bit error detection
AIO-3288J development board serial interface interface as follows:
2 Configuration Steps
The spi to uart node have already been created in file kernel/arch/arm/boot/dts/firefly-rk3288-AIO.dts, Enable this node to use it:
&spi0 { status = "okay"; max-freq = <48000000>; spidev@00 { status = "disabled"; compatible = "linux,spidev"; reg = <0x00>; spi-max-frequency = <48000000>; }; spi_wk2xxx: spi_wk2xxx@00{ status = "okay"; compatible = "firefly,spi-wk2xxx"; reg = <0x00>; spi-max-frequency = <10000000>; reset-gpio = <&gpio0 GPIO_C2 GPIO_ACTIVE_HIGH>; irq-gpio = <&gpio0 GPIO_A7 IRQ_TYPE_EDGE_FALLING>; cs-gpio = <&gpio5 GPIO_B5 GPIO_ACTIVE_HIGH>; pwr-en-gpio = <&gpio3 GPIO_B6 GPIO_ACTIVE_HIGH>; }; };
2 Debug method
Configure the serial port, the hardware interface corresponding to the software node are:
RS485:/dev/ttysWK3 RS232(上):/dev/ttysWK1 RS232(下):/dev/ttyS3 UART1:/dev/ttyS1 UART2:/dev/ttysWK0 UART3:/dev/ttysWK2
The user can use different host according to different interface USB to serial port adapter to send and receive data to the serial port of the development board, for example, the debugging steps of RS485 are as follows:
(1) Hardware connection.
Connect the A, B, GND pins of the development board RS485 to the A, B, GND pins of the host serial port adapter (USB to 485 serial port module) respectively.
(2) Open the host's serial terminal.
Run kermit on the terminal and set the baud rate:
$ sudo kermit C-Kermit> set line /dev/ttyUSB0 C-Kermit> set speed 9600 C-Kermit> set flow-control none C-Kermit> connect
/dev/ttyUSB0 is a device file for USB to serial adapter
baud is the "current-speed" attribute in the DTS node.
(3) Transmit data.
The device file for RS485 is /dev/ttysWK3. Run the following command in device:
echo firefly RS485 test... > /dev/ttysWK3
The serial terminal in the host PC will receive string "firefly RS485 test...".
(4) Receive data.
First, run the following command in device:
cat /dev/ttysWK3
Then input string "Firefly RS485 test..." in the serial terminal. You can see the same string received in the device.