在X2000 Linux 调试VL53L4CD驱动章节中已从官方下载了驱动文件,文件如下:
将user拷贝到sdk\demo下,如下所示:
修改\user\test\Makefile指令CC为mips-linux-gnu-gcc
CC := mips-linux-gnu-gcc
去掉CFLAGS_RELEASE += -DSTMVL53L4CD_KERNEL 的注释,使能STMVL53L4CD_KERNEL宏定义。
先cd到sdk的build目录,然后执行x2100_nand_defconfig设置交叉编译器路径,再cd到demo\user\test目录,执行make即可完成编译。编译之后demo\user\test目录下会生成menu执行文件。
将menu其推送到目标板的usr\data路径下。
执行以下命令修改menu的权限
# cd /usr/data/
# chmod 755 menu
运行menu
# ./menu
Kernel com init
Opened ST TOF Dev = 3
Starting examples of VL53L4CD driver (version 2.1.1.0)
----------------------------------------------------------------------------------------------------------
VL53L4CD uld driver test example menu
------------------ Ranging menu ------------------
1 : basic ranging
2 : low power
3 : high accuracy
4 : fast ranging
5 : calibrate offset and Xatlk
6 : detection thresholds - need to catch GPIO1 interrupt for this example
7 : exit
----------------------------------------------------------------------------------------------------------
Your choice ?
需要输入一个数字选择要运行的example或exit。
1、输入1运行basic ranging:
Starting Test 1
VL53L4CD ULD ready !
Status = 4, Distance = 2073, Signal = 2
Status = 4, Distance = 0, Signal = 2
Status = 4, Distance = 2116, Signal = 2
Status = 2, Distance = 0, Signal = 2
Status = 4, Distance = 2100, Signal = 2
Status = 2, Distance = 0, Signal = 2
Status = 4, Distance = 2102, Signal = 2
Status = 4, Distance = 0, Signal = 2
Status = 4, Distance = 2093, Signal = 2
Status = 4, Distance = 0, Signal = 2
Status = 4, Distance = 2088, Signal = 1
Status = 2, Distance = 0, Signal = 2
Status = 4, Distance = 0, Signal = 2
Status = 2, Distance = 0, Signal = 2
Status = 4, Distance = 2062, Signal = 1
Status = 4, Distance = 0, Signal = 2
Status = 4, Distance = 2187, Signal = 6
Status = 7, Distance = 124, Signal = 137
Status = 0, Distance = 118, Signal = 297
Status = 0, Distance = 112, Signal = 383
Status = 0, Distance = 99, Signal = 502
Status = 0, Distance = 89, Signal = 593
Status = 0, Distance = 81, Signal = 742
...
返回结果:
status:执行结果,没找明确的说明,为0时结果可信;
Distance:实测距离,单位mm;
Signal:返回的信号强度,距离被测物体越近,此值越大;