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

📄 ogrt_gp2021.c

📁 The OpenGPSRec receiver software runs on the real time operating system RTAI-Linux. It compiles with
💻 C
字号:
/* ************************************************************************    *                                                                      *   *                            OpenGPS Receiver                          *   *                                                                      *   * -------------------------------------------------------------------- *   *                                                                      *   *    Module:   ogrt_gp2021.c                                           *   *                                                                      *   *   Version:   0.1                                                     *   *                                                                      *   *      Date:   13.10.03                                                *   *                                                                      *   *    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"/* ------------------------------ procedures ------------------------------ */inline void to_gps( INT16 adr, INT16 data){  outpw( IO_COMMAND, adr);  outpw( IO_DATA, data);  return;}inline INT16 from_gps( INT16 adr){  INT16 res;  outpw( IO_COMMAND, adr);  res = inpw( IO_DATA);  return (res);}void ch_carrier( INT16 ch, long freq){  INT16 freq_hi, freq_lo;  UINT16 adr;  freq_hi = (INT16)( freq >> 16);  freq_lo = (INT16)( freq & 0xffff);  adr = CHx_CNTL_BASE + (ch << 3) + CARRIER_DCO_INCR_HIGH;//  carr_incr_hi(ch,freq_hi);  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_hi);  adr++;//  carr_incr_lo(ch,freq_lo);  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_lo);}#if 1void multi_carrier( long freq){  INT16 freq_hi, freq_lo;  UINT16 adr;  freq_hi = (INT16)( freq >> 16);  freq_lo = (INT16)( freq & 0xffff);  adr = MULTI_CONTROL + CARRIER_DCO_INCR_HIGH;//  carr_incr_hi(ch,freq_hi);  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_hi);  adr++;//  carr_incr_lo(ch,freq_lo);  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_lo);}#endifvoid all_carrier( long freq){  INT16 freq_hi, freq_lo;  UINT16 adr;  freq_hi = (INT16)( freq >> 16);  freq_lo = (INT16)( freq & 0xffff);  adr = ALL_CONTROL + CARRIER_DCO_INCR_HIGH;//  carr_incr_hi(ch,freq_hi);  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_hi);  adr++;//  carr_incr_lo(ch,freq_lo);  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_lo);}void ch_code( INT16 ch, long freq){  INT16 freq_hi, freq_lo;  UINT16 adr;  freq_hi = (INT16)( freq >> 16);  freq_lo = (INT16)( freq & 0xffff);  adr = CHx_CNTL_BASE + (ch<<3) + CODE_DCO_INCR_HIGH;  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_hi);//  ch_code_incr_hi(ch,freq_hi);  adr++;  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_lo);//  ch_code_incr_lo(ch,freq_lo);}#if 1void multi_code( long freq){  INT16 freq_hi, freq_lo;  UINT16 adr;  freq_hi = (INT16)( freq >> 16);  freq_lo = (INT16)( freq & 0xffff);  adr = MULTI_CONTROL + CODE_DCO_INCR_HIGH;  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_hi);//  ch_code_incr_hi(ch,freq_hi);  adr++;  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_lo);//  ch_code_incr_lo(ch,freq_lo);}#endifvoid all_code( long freq){  INT16 freq_hi, freq_lo;  UINT16 adr;  freq_hi = (INT16)( freq >> 16);  freq_lo = (INT16)( freq & 0xffff);  adr = ALL_CONTROL + CODE_DCO_INCR_HIGH;  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_hi);//  ch_code_incr_hi(ch,freq_hi);  adr++;  outpw( IO_COMMAND, adr);  outpw( IO_DATA, freq_lo);//  ch_code_incr_lo(ch,freq_lo);  return;}inline INT16 accum_status( void){  return( from_gps( ACCUM_STATUS_A));}#if 0void data_tst( INT16 data){  to_gps( DATABUSTEST, data);  return;}#endif#if 0UINT16 ch_epoch(INT16 ch){  return (from_gps( CHx_CNTL_BASE + (ch<<3) + EPOCH));}#endif#if 0UINT16 ch_epoch_check(INT16 ch){  return (from_gps( CHx_CNTL_BASE + (ch<<3) + EPOCH_CHECK));}#endifvoid ch_epoch_count_load( INT16 ch, UINT16 data){  to_gps( CHx_CNTL_BASE + (ch<<3) + EPOCH_COUNT_LOAD, data);  return;}#if 0void multi_epoch_count_load( UINT16 data){  to_gps( MULTI_CONTROL + EPOCH_COUNT_LOAD, data);  return;}#endifvoid all_epoch_count_load( UINT16 data){  to_gps( ALL_CONTROL + EPOCH_COUNT_LOAD, data);  return;}#if 0long ch_carrier_cycle(INT16 ch){  long res;  res = from_gps( (ch<<3)+CARRIER_CYCLE_HIGH);  res = res << 16;  res += from_gps( (ch<<3)+CARRIER_CYCLE_LOW);  return (res);}#endif#if 0INT16 ch_code_DCO_phase( INT16 ch){  return (from_gps( (ch<<3)+CODE_DCO_PHASE));}#endif#if 0void ch_code_DCO_preset_phase( INT16 ch, INT16 data){//  to_gps( (ch<<2) + CODE_DCO_PRESET_PHASE, data);  to_gps( CHx_ACCUM_BASE + (ch<<2) + CODE_DCO_PRESET_PHASE, data);  return;}#endif#if 0void multi_code_DCO_preset_phase( INT16 data){  to_gps( MULTI_ACCUM + CODE_DCO_PRESET_PHASE, data);//  to_gps( (ch<<2) + CODE_DCO_PRESET_PHASE, data);  return;}#endif#if 0void all_code_DCO_preset_phase( INT16 data){  to_gps( ALL_ACCUM + CODE_DCO_PRESET_PHASE, data);//  to_gps( (ch<<2) + CODE_DCO_PRESET_PHASE, data);  return;}#endif#if 0void ch_code_incr_hi(INT16 ch,INT16 data){  to_gps( (ch<<3)+CODE_DCO_INCR_HIGH, data);  return;}#endif#if 0void ch_code_incr_lo(INT16 ch,INT16 data){  to_gps( (ch<<3) + CODE_DCO_INCR_LOW, data);  return;}#endif#if 0INT16 ch_code_phase( INT16 ch){  return (from_gps( (ch<<3) + CODE_PHASE));}#endif#if 0INT16 ch_carrier_DCO_phase( INT16 ch){  return (from_gps( (ch<<3) + CARRIER_DCO_PHASE));}#endif#if 0void carr_incr_hi( INT16 ch, INT16 data){  to_gps( (ch<<3) + CARRIER_DCO_INCR_HIGH, data);  return;}#endif#if 0void carr_incr_lo(INT16 ch,INT16 data){  to_gps( (ch<<3) + CARRIER_DCO_INCR_LOW, data);  return;}#endifvoid ch_cntl( INT16 ch, INT16 data){//  printf( "ch=%d  port=%x\n", ch, port(ch<<3));  to_gps( (ch<<3) + SATCNTL, data);  return;}#if 0 void all_cntl(INT16 data){  to_gps( ALL_CONTROL, data);  return;}#endif#if 1void multi_cntl(INT16 data){  to_gps( MULTI_CONTROL, data);  return;}#endifvoid ch_accum_reset( INT16 ch){//  to_gps( (ch<<2) + ACCUM_RESET, 0);  to_gps( CHx_ACCUM_BASE + (ch<<2) + ACCUM_RESET, 0);  return;}void ch_code_slew( INT16 ch, INT16 data){  to_gps( CHx_ACCUM_BASE + (ch<<2) + CODE_SLEW_COUNTER, data);  return;}#if 0void multi_code_slew( INT16 data){//  to_gps( MULTI_CONTROL, data);  to_gps( MULTI_ACCUM + CODE_SLEW_COUNTER, data);  return;}#endif#if 0void all_code_slew( INT16 data){//  to_gps( ALL_CONTROL, data);  to_gps( ALL_ACCUM + CODE_SLEW_COUNTER, data);  return;}#endifvoid data_retent_w( INT16 data){  to_gps( DATA_RETENT, data);  return;}INT16 data_retent_r( void){  return (from_gps( DATA_RETENT));}void data_bus_test_w( INT16 data){  to_gps( DATABUSTEST, data);  return;}INT16 data_bus_test_r( void){  return (from_gps( DATABUSTEST));}inline INT16 meas_status( void){  return (from_gps( MEAS_STATUS_A));}#if 0void program_TIC( long data){  UINT16 high, low;  high = (INT16)( data >> 16);  low  = (INT16)( data & 0xffff);  to_gps( PROC_TIC_HIGH, high);  to_gps( PROC_TIC_LOW, low);  return;}#endifvoid reset_cntl( INT16 data){//  ch_status = data;   // save register content to global  to_gps( RESET_CONTROL, data);  return;}#if 0void ch_on( INT16 ch){  ch_status |= (0x1 << ch);  reset_cntl( ch_status);  return;}void ch_off( INT16 ch){  ch_status &= ~(0x1 << ch);  reset_cntl( ch_status);  return;}#endifvoid system_setup( INT16 data){  to_gps( SYSTEM_SETUP, data);  return;}void test_control( INT16 data){  to_gps( TEST_CONTROL, data);  return;}#if 0void status_latch( void){  to_gps( STATUS, 0);  return;}#endifvoid io_config( INT16 data){  to_gps( IO_CONFIG, data);  return;}void multi_channel_select( INT16 data){  to_gps( MULTI_CHANNEL_SELECT, data);  return;}/* ------------------------------------------------------------------------- *FUNCTION self_testRETURNS  result of self testPARAMETERS  nonePURPOSE  test access to GP2021* ------------------------------------------------------------------------- */int self_test( void){  UINT16 indata1, indata2, indata3, indata4;  data_retent_w( BITPATTERN1);  data_bus_test_w( BITPATTERN2);  indata1 = data_retent_r();  indata2 = data_bus_test_r();  data_retent_w( BITPATTERN3);  data_bus_test_w( BITPATTERN4);  indata3 = data_retent_r();  indata4 = data_bus_test_r();  if ((indata1 != BITPATTERN1) ||       (indata2 != BITPATTERN2) ||       (indata3 != BITPATTERN3) ||       (indata4 != BITPATTERN4))  {    rt_printk( "self_test() failed: data line error\n");    rt_printk( "indata1 = 0x%x, indata2 = 0x%x\n", indata1, indata2);    rt_printk( "indata3 = 0x%x, indata4 = 0x%x\n", indata3, indata4);    return (-1);  }#if 0  else  {    printf( "self test passed!\n");    printf( "indata1 = %x\n", indata1);    printf( "indata2 = %x\n", indata2);    printf( "indata3 = %x\n", indata3);    printf( "indata4 = %x\n", indata4);    getchar();  }#endif  return (0);}/*  *  switch off PROTO-3 LED */void switch_off_proto3_LED( void){#ifdef PCIBOARD  outb( 0, PCIBASE + 0x8); #endif  return;}/* ------------------------------- end of file ---------------------------- */

⌨️ 快捷键说明

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