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

📄 ogrt_monosat.c

📁 The OpenGPSRec receiver software runs on the real time operating system RTAI-Linux. It compiles with
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ************************************************************************    *                                                                      *   *                            OpenGPS Receiver                          *   *                                                                      *   * -------------------------------------------------------------------- *   *                                                                      *   *    Module:   ogrt_monosat.c                                          *   *                                                                      *   *   Version:   0.1                                                     *   *                                                                      *   *      Date:   09.12.02                                                *   *                                                                      *   *    Author:   C. Kelley, G. Beyerle                                   *   *                                                                      *   * -------------------------------------------------------------------- *   *                                                                      *   * Copyright (C) 2001-2003  C. Kelley, G. Beyerle                       *   *                                                                      *   * This program is free software; you can redistribute it and/or modify *   * it under the terms of the GNU General Public License as published by *   * the Free Software Foundation; either version 2 of the License, or    *   * (at your option) any later version.                                  *   *                                                                      *   * This program is distributed in the hope that it will be useful,      *   * but WITHOUT ANY WARRANTY; without even the implied warranty of       *   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *   * GNU General Public License for more details.                         *   *                                                                      *   * You should have received a copy of the GNU General Public License    *   * along with this program; if not, write to the Free Software          *   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.            *   *                                                                      *   * -------------------------------------------------------------------- *   *                                                                      *   * OpenGPS is based on Clifford Kelley's OpenSourceGPS distribution.    *   * The OpenSourceGPS distribution can be obtained from                  *   *             http://www.home.earthlink.net/~cwkelley                  *   *                                                                      *   * -------------------------------------------------------------------- *   *                                                                      *   *                         Real-time process                            *   *                                                                      *   ************************************************************************ *//* ******************************* changes ********************************   26.01.03 - replace 'trackch' by 'RT_Ctrl->leadch'              use fields RT_Ctrl->accum_missed & ->accum_new   18.07.03 - Chan[].ms_count wraps at 6000 (instead of 30000)   18.07.03 - move Ms_Count to struct Chan[]   31.07.03 - fixed bug in find/read_preamble()   03.08.03 - copy carrier-aided code tracking from OpenSourceGPS   ************************************************************************ *//***********************************************************************  GPS RECEIVER (GPSRCVR) Ver. 1.02  12 Channel All-in-View GPS Receiver Program based on   Mitel GP2021 chipset  Clifford Kelley cwkelley@earthlink.net  Copyright (c) 1996-2002 Clifford Kelley.  All Rights Reserved.  This LICENSE must be included with the OGR code.***********************************************************************//*Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions aremet:      CONDITIONS1. Redistributions of GPSRCVR source code must retain the above copyrightnotice, this list of conditions, and the following disclaimer.2. Redistributions in binary form must contain the above copyrightnotice, this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution.3. All modifications to the source code must be clearly marked assuch.  Binary redistributions based on modified source code must beclearly marked as modified versions in the documentation and/or othermaterials provided with the distribution.4. Notice must be given of the location of the availability of theunmodified current source code, e.g.,  http://www.Kelley.com/or  ftp://ftp.Kelley.comin the documentation and/or other materials provided with thedistribution.5. All advertising and published materials mentioning features or useof this software must display the following acknowledgment:  "Thisproduct includes software developed by Clifford Kelley and othercontributors."6. The name of Clifford Kelley may not be used to endorse or promoteproducts derived from this software without specific prior writtenpermission.      DISCLAIMERThis software is provided by Clifford Kelley and contributors "as is" andany expressed or implied warranties, including, but not limited to, theimplied warranties of merchantability and fitness for a particularpurpose are disclaimed.  In no event shall Clifford Kelley orcontributors be liable for any direct, indirect, incidental, special,exemplary, or consequential damages (including, but not limited to,procurement of substitute goods or services; loss of use, data, orprofits; or business interruption) however caused and on any theory ofliability, whether in contract, strict liability, or tort (includingnegligence or otherwise) arising in any way out of the use of thissoftware, even if advised of the possibility of such damage.*//* ------------------------------- includes ------------------------------- */#include <linux/kernel.h>#include <linux/module.h>#include <linux/slab.h>#include <rtai.h>#include <rtai_sched.h>#include <rtai_fifos.h>#include <rtai_shm.h>#include  "port.h"#include  "ogr_defines.h"#include  "ogr_structs.h"#include  "ogrt_defines.h"#include  "ogrt_globals.h"#include  "ogrt_prototypes.h"MODULE_LICENSE( "GPL");/* ------------------------------- defines -------------------------------- *//* ------------------------------ globals --------------------------------- *///static long delta_carrier[NOFCHN], delta_code[NOFCHN];/* ------------------------------ prototypes ------------------------------ *//* ------------------------------ procedures ------------------------------ *//* ------------------------------------------------------------------------- *FUNCTION init_monosatriseset()RETURNS  None.PARAMETERS  ch   channel number (0-11)PURPOSE  init 'monosat' and 'riseset' modes: all 12 channels track  the same PRN tracked by channel no. 'RT_Ctrl->leadch'* ------------------------------------------------------------------------- */void init_monosatriseset( INT16 mode){  INT16 i, ch, leadch, mask, dithermode;  leadch = RT_Ctrl->leadch;  i = 1;  // RT_Ctrl->monosat_cod_ofs[0] is zero!  for ( ch=0; ch<NOFCHN; ch++)  {    if ( ch != leadch)      monosat_cod_ofs[ch] = RT_Ctrl->monosat_cod_ofs[i++];    else      monosat_cod_ofs[ch] = 0;  }//  activate UPDATE mode// 0x8000: GPS mode, early select, UPDATE mode// 0x9000: GPS mode, early select, PRESET mode// 0xa000: GPS mode, late select, UPDATE mode// 0xb000: GPS mode, late select, PRESET mode  if ( RT_Ctrl->earlylate > 0)    dithermode = 0xa000;  else    dithermode = 0x8000;  mask = (~(0x1 << leadch)) & 0xfff;  multi_channel_select( mask);//  all_cntl( PRN_Code[Chan[leadch].prn] | dithermode);  // add G2 load //  Note: writes to code and carrier DCOs take effect immediately! //  all_carrier( Chan[leadch].car_frq);//  all_code( Chan[leadch].cod_frq);// add G2 load  multi_cntl( PRN_Code[Chan[leadch].prn] | dithermode);   //  write to code and carrier DCOs take effect immediately!   multi_carrier( Chan[leadch].car_frq);  multi_code( Chan[leadch].cod_frq);//  all_code_DCO_preset_phase( 0);//  256/6.5 ~  39//  256/5.5 ~  47//  256/4.5 ~  57//  256/3.5 ~  73//  256/2.5 ~ 102//  256/1.5 ~ 171//  *** CHECKME: does a TIC event right now interfere? ***//  It shouldn't: only write to EPOCH_COUNT_LOAD activates PRESET  //  preset chip phases//  ofs = # halfchips (range) / 12 * 256//  ofs =  73; // 3.42 halfchips//  ofs =  85; // 3.98 halfchips//  ofs = 102; // 4.78 halfchips// activates PRESET at next TIC//  all_epoch_count_load( 0);//  update chan structure accordingly  for ( ch=0; ch<NOFCHN; ch++)  {    if ( ch != leadch)    {      Chan[ch].state     = follow_monosat;       Chan[ch].prn       = Chan[leadch].prn;      Chan[ch].n_freq    = search_min_f;      Chan[ch].delta_frq = 1;      Chan[ch].car_frq   = Chan[leadch].car_frq;      Chan[ch].cod_frq   = Chan[leadch].cod_frq;    }    else if ( mode == trans2monosat)      Chan[ch].state     = track_monosat;    else      Chan[ch].state     = track_riseset;  }#if 0  multi_code_DCO_preset_phase( 0);  multi_code_slew( 2);                     // must be non-zero  multi_epoch_count_load( 0);#endif#if 0  all_carrier( Chan[trackch].car_frq);                   // select carrier  all_code( Chan[trackch].cod_frq);                      // 1.023 MHz chipping rate  all_code_DCO_preset_phase( 0);  all_code_slew( 2);                     // must be non-zero// activates PRESET at next TIC  all_epoch_count_load( 0);#endif#if 0//  write header info to data file  ptr = buf;//  data file format (increment if you change something!)  tmp = 6;                              // offset  memcpy( ptr, &tmp, sizeof( INT16));   // 2 bytes  ptr += sizeof( INT16);//  header size in bytes  headersize = MSG_HEADERSIZE;  memcpy( ptr, &headersize, sizeof( INT16));   // 4 bytes  ptr += sizeof( INT16);//  data body size in bytes  tmp = MSG_DATASIZE;  memcpy( ptr, &tmp, sizeof( INT16));   // 6 bytes  ptr += sizeof( INT16);////  GPS week//  memcpy( buf+6, &RT_Ctrl->gps_week, sizeof( INT16)); // 8 bytes//  time of week  memcpy( ptr, &Chan[leadch].tow_HOW, sizeof( long)); // 12 bytes   ptr += sizeof( long);//  TIC  memcpy( ptr, &RT_Ctrl->tow_tic_count, sizeof( long));  // 16 bytes  ptr += sizeof( long);//  which channel leads the gang?  memcpy( ptr, &RT_Ctrl->leadch, sizeof( INT16));  // 70 bytes  ptr += sizeof( INT16);// +1 late arm, -1 : early arm  memcpy( ptr, &RT_Ctrl->earlylate, sizeof( INT16));  // 72 bytes  ptr += sizeof( INT16);//  PRN of leading channel  memcpy( ptr, &Chan[leadch].prn, sizeof( INT16)); // 18 bytes  ptr += sizeof( INT16);//  code phase offset (monosat mode)  memcpy( ptr, monosat_cod_ofs, 12*sizeof( INT16)); // 44 bytes  ptr += 12 * sizeof( INT16);////  carrier offset (monosat mode)//  memcpy( ptr, monosat_car_ofs, 12*sizeof( INT16)); // 68 bytes  ptr += 12 * sizeof( INT16);  rtf_put( 1, buf, headersize);  // write to FIFO#endif  return;

⌨️ 快捷键说明

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