Interface Definition

Overall Interface Definition

The LPB3568 offers a rich set of interfaces, detailed as follows:

../../_images/interface.png

Silk Screen Device Node Remarks
USB1 Type-A USB2.0 host
USB2 Type-A USB2.0 host
USB3 Type-A USB3.0 host
USB4 Type-A USB3.0 OTG port for programming
SYS-CTL Debug&Key Product Manual J14
PWR LED Power indicator light
4G LED 4G indicator light 4G/5G Dialing
SYS LED work1 System indicator light
STA LED work2 STA indicator light
RS485 /dev/ttyS9 Serial port, default baud rate 9600
UART1 /dev/ttyS7 Serial port, default baud rate 9600
UART2 /dev/ttyS4 Serial port, default baud rate 9600
CAN1 can1 CAN bus
CAN2 can0 CAN bus
CTL1 gpio40 GPIO, output mode
CTL2 gpio42 GPIO, output mode
CTL3 gpio20 GPIO, output mode
CTL4 gpio19 GPIO, output mode
D/I IN1 gpio58 GPIO, input mode, default is 1, input 5~36V is 0
D/I IN2 gpio57 GPIO, input mode, default is 1, input 5~36V is 0
D/I IN3 gpio60 GPIO, input mode, default is 1, input 5~36V is 0
D/I IN4 gpio56 GPIO, input mode, default is 1, input 5~36V is 0
A/I IN1 in_voltage7_raw Analog input, used to connect some industrial sensors
A/I IN2 in_voltage6_raw Analog input, used to connect some industrial sensors
A/I IN3 in_voltage5_raw Analog input, used to connect some industrial sensors
A/I IN4 in_voltage4_raw Analog input, used to connect some industrial sensors
COM1 /dev/ttysWK2 Serial port RS232, default baud rate 9600
COM2 /dev/ttysWK0 Serial port RS232, default baud rate 9600
COM3 /dev/ttysWK1 Serial port RS232, default baud rate 9600
COM4 /dev/ttysWK3 Serial port RS232, default baud rate 9600
HDMIIN /dev/video0 HDMI input, supports up to 4K@30fps resolution
HDMI1 card0-HDMI-A-1 HDMI output, supports up to 4K@60fps
HDMI2 card0-DSI-1 HDMI output, supports up to 4K@30fps
MIC Input sound, record audio files
LINE Play audio files
ETH0 enP2p33s0 Gigabit network card
ETH1 eth0 Gigabit network card
WIFI wlan0 2.4/5GHz
RTC /dev/rtc0 RTC clock

UART Usage

The serial port is a common communication interface used for serial communication with external devices. This product provides multiple serial ports, each corresponding to different device nodes. Before using the serial port, ensure that the port is correctly connected and the baud rate and other parameters are set consistently.

The RS485 device file is /dev/ttyS9. Run the following command on the development board device:

Send a string to the host:

echo "neardi RS485 test..." > /dev/ttyS9

The host’s serial terminal will receive the string “neardi RS485 test…”. The development board receives data:

Receive a string sent by the host:

cat /dev/ttyS9

Similarly, the device files for UART1 and UART2 are /dev/ttyS7 and /dev/ttyS4.

CAN Usage

CAN is a bus standard used to enable communication between devices. This product provides two CAN interfaces, corresponding to can0 and can1 devices. Before using CAN, ensure that the CAN device is correctly connected and the baud rate and other parameters are set consistently. The default firmware includes using candump and cansend tools for sending and receiving message tests. If the tools are not available, they can be downloaded from github.

# Turn off the can0 device at both sending and receiving ends
ip link set can0 down
# Set the bitrate at both sending and receiving ends
ip link set can0 up type can bitrate 1000000 dbitrate 3000000 fd on
# Execute candump at the receiving end, blocking waiting for messages
candump can0
# Execute cansend at the sending end, sending messages
cansend can0 123#1122334455667788

More commands:

1. ip link set canX down               // Turn off the CAN device;
2. ip link set canX up                 // Turn on the CAN device;
3. ip -details link show canX          // Show detailed information of the CAN device;
4. candump canX                        // Receive data sent by the CAN bus;
5. ifconfig canX down                  // Turn off the CAN device for configuration;
6. ip link set canX up type can bitrate 1000000 // Set the CAN baud rate
7. conconfig canX bitrate + baud rate;
8. canconfig canX start                // Start the CAN device;
9. canconfig canX ctrlmode loopback on // Loopback test;
10. canconfig canX restart             // Restart the CAN device;
11. canconfig canX stop                // Stop the CAN device;
12. canecho canX                       // Check the status of the CAN bus;
13. cansend canX --identifier=ID+data  // Send data;
14. candump canX --filter=ID:mask      // Use a filter to receive data matching the ID

CTL Usage

For controlling CTL1 as an example:

echo 40 > /sys/class/gpio/export;
echo out > /sys/class/gpio/gpio40/direction;
#Set high
echo 1 > /sys/class/gpio/gpio40/value;
#Set low
echo 0 > /sys/class/gpio/gpio40/value;

D/I Usage

To read D/I IN1 as an example:

echo 58 > /sys/class/gpio/export;
echo in > /sys/class/gpio/gpio58/direction;
#Read
cat /sys/class/gpio/gpio58/value;

Default is 1, input 5~36V is 0.

A/I Usage

Analog input is an interface that can detect the voltage or current of external devices. This product provides four analog inputs, each corresponding to different device nodes. Before using analog input, ensure that the external device is correctly connected and the voltage or current range meets the requirements.

To test the analog input, use the following commands to read the value of the analog input:

Voltage value(V)=15/4096 * Reading value;

Current value(MA)=30/4096 * Reading value;

# Read the value of A/I IN1
cat /sys/devices/platform/fe720000.saradc/iio:device0/in_voltage7_raw
# Read the value of A/I IN2
cat /sys/devices/platform/fe720000.saradc/iio:device0/in_voltage6_raw
# Read the value of A/I IN3
cat /sys/devices/platform/fe720000.saradc/iio:device0/in_voltage5_raw
# Read the value of A/I IN4
cat /sys/devices/platform/fe720000.saradc/iio:device0/in_voltage4_raw

COM Usage

The usage method for COM is similar to RS485, UART1, and UART2; just replace the device file accordingly.

HDMI/DP Explanation

The xrandx command can be used to check the current HDMI connection:

neardi@3568:~$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1920x1080     60.00*+  60.00    50.00    30.00    24.00
   4096x2160     24.00
   3840x2160     30.00    25.00    24.00
   1920x1080i    60.00    50.00
   1280x720      60.00    60.00    50.00    50.00    30.00    24.00
   720x576       50.00    50.00
   720x480       59.94    59.94    59.94
DSI-1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1920x1080     60.00*+

Complete Node Definitions:

HDMI1:/sys/devices/platform/display-subsystem/drm/card0/card0-HDMI-A-1/
HDMI2:/sys/devices/platform/display-subsystem/drm/card0/card0-DSI-1/

HDMIIN Usage

HDMI input is an interface that can receive external HDMI signals and convert them into MIPI signals. This product provides one HDMI input. Before using the HDMI input, ensure that the HDMI device is correctly connected and the resolution and frame rate settings are consistent.

Refer to 《HDMIIN》

ETH Explanation

You can check the IP address via the debug serial port, ssh, or adb, for example:

neardi@3568:~$ ifconfig -a
enP2p33s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.65  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::7df7:e74d:497e:345d  prefixlen 64  scopeid 0x20<link>
        ether 62:ea:fb:ca:95:e7  txqueuelen 1000  (Ethernet)
        RX packets 2548  bytes 210938 (210.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 338  bytes 46899 (46.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 140  base 0xd000

Wi-Fi Explanation

Check the current Wi-Fi model with the following commands:

cat /sys/bus/sdio/devices/mmc2\:0001\:1/vendor
cat /sys/bus/sdio/devices/mmc2\:0001\:1/device

0x02d00xaae8 is AP6275S,0x024c0xb852 is RTL8852

Starting a Hotspot

LED Explanation

Complete nodes:

SYS LED:cat /sys/devices/platform/leds/leds/work1/brightness
STA LED:cat /sys/devices/platform/leds/leds/work2/brightness

MIC Usage

Use the following command to record audio files, supporting formats such as wav, mp3, etc.

Record dual-channel 16-bit little-endian audio at a sampling rate of 48000Hz, then save it as a 001.wav file.

arecord  -Dhw:0,0 -r48000 -f S16_LE -c2 > 001.wav

• -Dhw:0,0 specifies the recording device, 0,0 is card 0 device 0, which is the first sound card’s first device.

• -r48000 specifies the sampling rate in Hz, 48000 means 48000 samples per second.

• -f S16_LE specifies the sample format, S16_LE means signed 16-bit little-endian format, each sample point occupies 2 bytes, with the low byte first and the high byte last.

• -c2 specifies the number of channels, 2 means stereo.

• > 001.wav specifies the output file, > redirects standard output to a file, 001.wav is the file name, wav is the file format.

LINE Usage

Use the first sound card’s first device to play the 001.wav file.

aplay -D hw:0,0 001.wav

• -D hw:0,0 specifies the playback device, hw:0,0 is card 0 device 0, which is the first sound card’s first device.

• 001.wav specifies the audio file, wav is the file format, 001 is the file name.

RTC Clock

HYM8563 serves as the RTC clock.

How to change the RTC clock to ‘2018-11-11 12:00:00’

#Turn off the Network Time Protocol (NTP) service so that the RTC clock is not affected by network time
timedatectl set-ntp false
#Set the RTC clock time to November 11, 2018, at 12:00:00
timedatectl set-time '2018-11-11 12:00:00'
#Synchronize the RTC clock time to the system clock to keep the system clock and RTC clock consistent, can be added in /etc/init.d/rockchip.sh
hwclock --hctosys