赞
踩
该驱动比较简单,gps模组是基于uart的独立模块,rk3188通过gpio控制gps(打开与关闭),然后将gps uart的NMEA data接收,并传递给上层(gpstest.apk)。
1. gps 模组gpio的控制: gps vcc_en,gps_reset pin的定义:
platform_device :
#if defined(CONFIG_RK29_GPS)
#include "../../../drivers/misc/gps/rk29_gps.h"
#define RK29_GPS_POWER_PIN RK30_PIN1_PB5
#define RK29_GPS_RESET_PIN RK30_PIN0_PD5
int rk29_gps_power_up(void)
{
int ret;
printk("%s \n", __FUNCTION__);
ret = gpio_request(RK29_GPS_POWER_PIN, NULL);
if (ret != 0) {
gpio_free(RK29_GPS_POWER_PIN);
printk("gps power error\n");
return -EIO;
}
//gpio_pull_updown(RK29_GPS_POWER_PIN, PullEnable);
gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH);
return 0;
}
int rk29_gps_power_down(void)
{
printk("%s \n", __FUNCTION__);
//gpio_request(RK29_GPS_POWER_PIN, NULL);
gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW);
return 0;
}
int rk29_gps_reset_set(int level)
{
gpio_request(RK29_GPS_RESET_PIN, NULL);
if (level)
gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);
else
gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);
return 0;
}
struct rk29_gps_data rk29_gps_info = {
.power_up = rk29_gps_power_up,
.power_down = rk29_gps_power_down,
.reset = rk29_gps_reset_set,
.uart_id = 3,
};
struct platform_device rk29_device_gps = {
.name = "gps",//.name = "rk29_gps",
.id = -1,
.dev = {
.platform_data = &rk29_gps_info,
}
};
#endif
在系统中添加该device
static struct platform_device *devices[] __initdata = {
.....
//add liuxd 20141231
#if defined(CONFIG_RK29_GPS)
&rk29_device_gps,
#endif
.......
};
/kernel/driver/misc/gps/下面添加gps driver:
注册成功后/dev/gps结点会生成,下文的gps.default.so可以通过/dev/gps打开与关闭gps。
2.rk3188 uart3的打开。
2.1打开gps uart3的config
2.2保证 uart3所复用的gpio 在软件里被初始化为uart func pin.
2.3 chmod 777 /dev/ttyS3
如果此时成功,就可以用串口助手读取到gps 的nmea 数据了。
3.在gps在hal层添加gps.default.so
struct hw_module_t HAL_MODULE_INFO_SYM = {
.tag = HARDWARE_MODULE_TAG,
.version_major = 1,
.version_minor = 0,
.id = GPS_HARDWARE_MODULE_ID,
.name = "QUECTEL GPS Module",
.author = "Joe.Wang",
.methods = &gps_module_methods,
};
4.app下安装gpstest.apk
5.收星测试。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。