mcy_cool 发表于 2012-12-26 11:12:00

GPS驱动开发全纪录 -- EB365

本帖最后由 mcy_cool 于 2012-12-26 11:25 编辑

前几天在网上买的一个GPS模块到货了,准备为其写一个GPS驱动。
硬件平台采用购买的arduino接口的GPS模块,GPS芯片是EB-365,该芯片完全兼容U-Blox。下面是模块图片:

主控板采用CooCox推出的Cookie板,该主控板完全兼容arduino接口,同时还扩展和丰富了其功能,详细情况可参见CooCox官网中关于Cookie板的介绍。
软件采用CooCox推出的CoIDE编译器,函数库采用的是CooCox为了实现基于M3、M0、M0+、M4内核的各种芯片上平滑移植的目标而推出的CoX固件库。

初步阅读芯片手册,整理出一下指令方式和信息:
GGA:时间、位置、定位类型
GLL:UTC时间、经度、纬度
GSA:GPS接收机操作模式、定位使用的卫星、DOP值
GSV:可见GPS卫星信息、仰角、方位角、信噪比(SNR)
RMC:时间、日期、位置、速度
注意:输出的信息、频率与设置有关

同时注意北京时间比UTC时间快8小时,因此在处理时间时应特别注意时间变换和闰平年的问题。

下面开始具体编写驱动程序……

kevinstar888 发表于 2012-12-26 11:12:54

楼主你的图呢

mcy_cool 发表于 2012-12-26 11:26:27

kevinstar888 发表于 2012-12-26 11:12 static/image/common/back.gif
楼主你的图呢

呵呵,刚刚网络不给力啊,现在上传了GPS模块的实物图片

zwh751279833 发表于 2012-12-26 12:04:35

不错不错

mcy_cool 发表于 2012-12-27 10:32:29

该GPS模块采用的是UART接口,默认波特率是9600,对应的是arduino的UART1,因此我将Cookie板的UART1设为9600,8,1,0.同时采用中断接收,GPS的数据帧都是以'$'为开头标志,以'\n'为结束标志,在接收时我们就以这为根据一次接收一帧数据,同时申请一个全局标志,当接收完成,该标志置1,当接收到的数据处理完成,该标志置0. 串口中断初始化与接收程序如下:
//*****************************************************************************
//
//! \brief UART1 Interrupt Receive Service.
//!
//! \param None.
//!
//! \return None.
//
//*****************************************************************************
unsigned char num = 0;
//
//! You need to define these variables in the main.c and initialize to 0.
//
extern char rev_buf;      //Receive Buffer
extern unsigned char rev_start, //Receiving start flag
                     rev_stop,//Receiving end flag
                     gps_flag;//GPS Processed flag
unsigned long
uart1CallbackFunc(void *pvCBData, unsigned long ulEvent,
                   unsigned long ulMsgParam, void *pvMsgData)                                  
{
    unsigned char ch;
    ch = UARTCharGet(sUART_BASE);
    if ((ch == '$') && (gps_flag == 0))
    {
      rev_start = 1;
      rev_stop= 0;                  
    }
    if (rev_start == 1)
    {
      rev_buf = ch;
      if (ch == '\n')      
      {
            rev_buf = '\0';
            rev_start = 0;
            rev_stop= 1;          
            gps_flag = 1;
            num = 0;
      }
    }
    return 0;
}

//*****************************************************************************
//
//! \brief UART1 Initialize.
//!
//! \param ulBaudrate is the baud rate of UART1.
//!
//! \return None.
//
//*****************************************************************************
void
UART1_Init(unsigned long ulBaudrate)
{
    xSysCtlPeripheralReset(xSYSCTL_PERIPH_UART1);
    xSysCtlPeripheralEnable(xSYSCTL_PERIPH_UART1);
    xSysCtlPeripheralClockSourceSet(xSYSCTL_UART0_MAIN, 1);
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(sD0));

    sPinTypeUART(sUART_BASE);
       
    xUARTConfigSet(sUART_BASE, ulBaudrate, (UART_CONFIG_WLEN_8   |
                                          UART_CONFIG_STOP_ONE |
                                          UART_CONFIG_PAR_NONE));
    xUARTIntEnable(sUART_BASE, xUART_INT_RX);
    UARTIntCallbackInit(sUART_BASE, uart1CallbackFunc);
    xUARTEnable(sUART_BASE, (UART_BLOCK_UART | UART_BLOCK_TX | UART_BLOCK_RX));
    xIntEnable(xINT_UART1);
}

//*****************************************************************************
//
//! \brief GPS Initialize.
//!
//! \param ulBaudrate is the baud rate of GPS.
//!
//! \return None.
//
//*****************************************************************************
void
GPS_Init(unsigned long ulBaudrate)
{
    UART1_Init(ulBaudrate);   // 默认是9600
}

现在正在调试各个数据帧的解析程序,调试成功将一起上传。

guowanling8061 发表于 2013-1-8 15:45:40

期待中......

mcy_cool 发表于 2013-1-14 09:39:06

现将驱动代码全部上传

Facelessvoid 发表于 2016-1-8 16:09:19

好东西谢谢分享

z13900139000 发表于 2016-1-8 16:22:06

好东西谢谢分享{:smile:}{:smile:}

openmcu(WB1) 发表于 2016-1-16 17:49:36

支持!!谢谢分享

308594151 发表于 2016-1-16 22:42:13

mark一下
页: [1]
查看完整版本: GPS驱动开发全纪录 -- EB365