进入新公司参加的第一个项目,采用的是海思的Hi35xxVxx芯片。
我这边负责的模块是GPS模块,利用SDK代码框架,配置海思Hi35xx 芯片的串口,从串口读取GPS模块数据。
首先第一步,配置内核uart:
通过看芯片数据手册,GPS预留接口是 UART4。但是海思芯片未配置UART4。于是我们得从内核源码树配置UART4。
当然,得基于海思的内核patch 来配置,因为,原生内核是未对hi35xx芯片做适配的。
我们进入:osdrv/opensource/kernel/linux-4.9.y/arch/arm/boot/dts/ 目录
修改patch:
diff -Naur linux-4.9.y.sdk/arch/arm/boot/dts/hi3559v200-demb.dts linux-4.9.y/arch/arm/boot/dts/hi3559v200-demb.dts
--- linux-4.9.y.sdk/arch/arm/boot/dts/hi3559v200-demb.dts 2019-07-09 07:51:20.578954127 +0000
+++ linux-4.9.y/arch/arm/boot/dts/hi3559v200-demb.dts 2019-07-09 07:52:49.770587238 +0000
@@ -39,6 +39,9 @@
&uart3 {
status = "okay";
};
+&uart4 {
+ status = "okay";
+};
&i2c_bus3 {
status = "okay";
diff -Naur linux-4.9.y.sdk/arch/arm/boot/dts/hi3559v200.dtsi linux-4.9.y/arch/arm/boot/dts/hi3559v200.dtsi
--- linux-4.9.y.sdk/arch/arm/boot/dts/hi3559v200.dtsi 2019-07-09 07:51:20.578954127 +0000
+++ linux-4.9.y/arch/arm/boot/dts/hi3559v200.dtsi 2019-07-09 07:52:16.336181440 +0000
@@ -22,6 +22,7 @@
/ {
aliases {
serial0 = &uart0;
+ serial4 = &uart4;
i2c3 = &i2c_bus3;
i2c7 = &i2c_bus7;
#ifndef CONFIG_ARCH_HISI_BVT_AMP
这样,就配置好了内核UART4
然后,在SDK 中,根据数据手册 配置引脚复用:
#define HAL_GPS_DEV "/dev/ttyAMA4"
/* pinmux config UART4 for Hi35xxVx00 */
himm(0x111f0000, 0x532); //RX
himm(0x111f0004, 0x432); //TX
至此,编译SDK之后,串口就应该有GPS数据了。
cat dev/ttyAMA4
$GPRMC,,V,,,,,,,,,,N*53
$GPVTG,,,,,,,,,N*30
$GPGGA,,,,,,0,00,99.99,,,,,,*48
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGLL,,,,,,V,N*64
$GPRMC,,V,,,,,,,,,,N*53
$GPVTG,,,,,,,,,N*30
$GPGGA,,,,,,0,00,99.99,,,,,,*48
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGLL,,,,,,V,N*64
出现这样不完整的数据说明GPS在室内无信号,需要去室外才能获取到完整数据。
接下来,就是解析GPS数据,写入结构体了。
SDK:gps_data_analys.c 解析数据函数:static HI_BOOL GPSMNG_Scan(const HI_CHAR* message, const HI_CHAR* format, ...)
HI_S32 GPSMNG_ParserRawData(GPSMNG_RAW_DATA* gpsRawData, HI_GPSMNG_MSG_PACKET* gpsMsgPack)
HI_BOOL GPSMNG_ParseRMC(HI_GPSMNG_MSG_RMC* gpsMsg, const HI_CHAR* message)
————————————————
版权声明:本文为CSDN博主「陈老湿」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/chen_old_wet/article/details/95227436