⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nmea_8c-source.html

📁 ATMEL的AVR单片机库文件
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Procyon AVRlib: nmea.c Source File</title><link href="dox.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.6 --><div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div><h1>nmea.c</h1><a href="nmea_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*! \file nmea.c \brief NMEA protocol function library. */</span>00002 <span class="comment">//*****************************************************************************</span>00003 <span class="comment">//</span>00004 <span class="comment">// File Name    : 'nmea.c'</span>00005 <span class="comment">// Title        : NMEA protocol function library</span>00006 <span class="comment">// Author       : Pascal Stang - Copyright (C) 2002</span>00007 <span class="comment">// Created      : 2002.08.27</span>00008 <span class="comment">// Revised      : 2002.08.27</span>00009 <span class="comment">// Version      : 0.1</span>00010 <span class="comment">// Target MCU   : Atmel AVR Series</span>00011 <span class="comment">// Editor Tabs  : 4</span>00012 <span class="comment">//</span>00013 <span class="comment">// NOTE: This code is currently below version 1.0, and therefore is considered</span>00014 <span class="comment">// to be lacking in some functionality or documentation, or may not be fully</span>00015 <span class="comment">// tested.  Nonetheless, you can expect most functions to work.</span>00016 <span class="comment">//</span>00017 <span class="comment">// This code is distributed under the GNU Public License</span>00018 <span class="comment">//      which can be found at http://www.gnu.org/licenses/gpl.txt</span>00019 <span class="comment">//</span>00020 <span class="comment">//*****************************************************************************</span>00021 00022 <span class="preprocessor">#ifndef WIN32</span>00023 <span class="preprocessor"></span><span class="preprocessor">    #include &lt;avr/io.h&gt;</span>00024 <span class="preprocessor">    #include &lt;avr/signal.h&gt;</span>00025 <span class="preprocessor">    #include &lt;avr/interrupt.h&gt;</span>00026 <span class="preprocessor">    #include &lt;avr/pgmspace.h&gt;</span>00027 <span class="preprocessor">    #include &lt;string.h&gt;</span>00028 <span class="preprocessor">    #include &lt;stdlib.h&gt;</span>00029 <span class="preprocessor">#endif</span>00030 <span class="preprocessor"></span>00031 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>00032 <span class="preprocessor">#include "<a class="code" href="buffer_8h.html">buffer.h</a>"</span>00033 <span class="preprocessor">#include "<a class="code" href="rprintf_8h.html">rprintf.h</a>"</span>00034 <span class="preprocessor">#include "<a class="code" href="gps_8h.html">gps.h</a>"</span>00035 00036 <span class="preprocessor">#include "<a class="code" href="nmea_8h.html">nmea.h</a>"</span>00037 00038 <span class="comment">// Program ROM constants</span>00039 00040 <span class="comment">// Global variables</span>00041 <span class="keyword">extern</span> GpsInfoType GpsInfo;00042 <span class="preprocessor">#define BUFFERSIZE  80</span>00043 <span class="preprocessor"></span>u08 NmeaPacket[BUFFERSIZE];00044 u08 debug;00045 00046 <span class="keywordtype">void</span> nmeaInit(<span class="keywordtype">void</span>)00047 {00048     debug = 0;00049 }00050 00051 u08 nmeaProcess(cBuffer* rxBuffer)00052 {00053     u08 foundpacket = FALSE;00054     u08 startFlag = FALSE;00055     <span class="comment">//u08 data;</span>00056     u08 i,j;00057 00058     <span class="comment">// process the receive buffer</span>00059     <span class="comment">// go through buffer looking for packets</span>00060     <span class="keywordflow">while</span>(rxBuffer-&gt;datalength)00061     {00062         <span class="comment">// look for a start of NMEA packet</span>00063         <span class="keywordflow">if</span>(<a class="code" href="buffer_8h.html#a4">bufferGetAtIndex</a>(rxBuffer,0) == <span class="charliteral">'$'</span>)00064         {00065             <span class="comment">// found start</span>00066             startFlag = TRUE;00067             <span class="comment">// done looking for start</span>00068             <span class="keywordflow">break</span>;00069         }00070         <span class="keywordflow">else</span>00071             <a class="code" href="buffer_8h.html#a2">bufferGetFromFront</a>(rxBuffer);00072     }00073     00074     <span class="comment">// if we detected a start, look for end of packet</span>00075     <span class="keywordflow">if</span>(startFlag)00076     {00077         <span class="keywordflow">for</span>(i=1; i&lt;(rxBuffer-&gt;datalength)-1; i++)00078         {00079             <span class="comment">// check for end of NMEA packet &lt;CR&gt;&lt;LF&gt;</span>00080             <span class="keywordflow">if</span>((<a class="code" href="buffer_8h.html#a4">bufferGetAtIndex</a>(rxBuffer,i) == <span class="charliteral">'\r'</span>) &amp;&amp; (<a class="code" href="buffer_8h.html#a4">bufferGetAtIndex</a>(rxBuffer,i+1) == <span class="charliteral">'\n'</span>))00081             {00082                 <span class="comment">// have a packet end</span>00083                 <span class="comment">// dump initial '$'</span>00084                 <a class="code" href="buffer_8h.html#a2">bufferGetFromFront</a>(rxBuffer);00085                 <span class="comment">// copy packet to NmeaPacket</span>00086                 <span class="keywordflow">for</span>(j=0; j&lt;(i-1); j++)00087                     NmeaPacket[j] = <a class="code" href="buffer_8h.html#a2">bufferGetFromFront</a>(rxBuffer);00088                 <span class="comment">// null terminate it</span>00089                 NmeaPacket[j] = 0;00090                 <span class="comment">// dump &lt;CR&gt;&lt;LF&gt; from rxBuffer</span>00091                 <a class="code" href="buffer_8h.html#a2">bufferGetFromFront</a>(rxBuffer);00092                 <a class="code" href="buffer_8h.html#a2">bufferGetFromFront</a>(rxBuffer);00093 00094                 <span class="keywordflow">if</span>(debug)00095                 {00096                     rprintf(<span class="stringliteral">"Rx NMEA packet type: "</span>);00097                     <a class="code" href="rprintf_8h.html#a9">rprintfStrLen</a>(NmeaPacket, 0, 5);00098                     <a class="code" href="rprintf_8h.html#a9">rprintfStrLen</a>(NmeaPacket, 5, (i-1)-5);00099                     <a class="code" href="rprintf_8c.html#a9">rprintfCRLF</a>();00100                 }00101                 <span class="comment">// found a packet</span>00102                 <span class="comment">// done with this processing session</span>00103                 foundpacket = TRUE;00104                 <span class="keywordflow">break</span>;00105             }00106         }00107     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -