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

📄 gp2021.cpp

📁 开源GPS源码
💻 CPP
字号:
/***********************************************************************
  GPS RECEIVER (GPSRCVR) Ver. 1.11
  See comments in GPSRCVR.CPP
  12 Channel All-in-View GPS Receiver Program based on Mitel GP2021
  chipset
  Clifford Kelley <cwkelley@earthlink.net>
  This program is licensed under GNU GENERAL PUBLIC LICENSE
  This LICENSE file must be included with the GPSRCVR code.
***********************************************************************/


#include  <stdio.h>
#include  <stdlib.h>
#include  <conio.h>
#include  <math.h>
#include  <string.h>
#include  <io.h>
#include  <Dos.h>
#include  <time.h>

#include  "structs.h"
#include  "consts.h"
#undef MAIN
#include  "globals.h"
#include  "gp2021.h"



//inline void to_gps(int add,int data)
void to_gps(int add,int data)
{
 outpw(Register_address,add);
 outpw(Data_address,data);
}

//inline int from_gps(int add)
int from_gps(int add)
{
  outpw(Register_address,add);
  return(inpw(Data_address));
}

inline int accum_status(void)
{
  return(from_gps(0x82));
}

void all_accum_reset(void)
{
}

void data_tst(int data)
{
  to_gps(0xf2,data);
}

unsigned int  ch_epoch(char ch)
{
  return(from_gps((ch<<3)+4));
}

unsigned int  ch_epoch_chk(char ch)
{
  return(from_gps((ch<<3)+7));
}

long   ch_carrier_cycle(char ch)
{
  long result;
  result=from_gps((ch<<3)+6);
  result=result<<16;
  result=result+from_gps((ch<<3)+2);
  return(result);
}

int  ch_code_DCO_phase(char ch)
{
  return(from_gps((ch<<3)+5));
}

void ch_code_incr_hi(char ch,int data)
{
  to_gps((ch<<3)+0x5,data);
}

void ch_code_incr_lo(char ch,int data)
{
  to_gps((ch<<3)+0x6,data);
}

int ch_code_phase(char ch)
{
 return(from_gps((ch<<3)+0x1));
}

int ch_carrier_DCO_phase(char ch)
{
  return(from_gps((ch<<3)+0x3));
}

void carr_incr_hi(char ch,int data)
{
  to_gps((ch<<3)+0x3,data);
}

void carr_incr_lo(char ch,int data)
{
  to_gps((ch<<3)+0x4,data);
}

void ch_cntl(char ch,int data)
{
//  printf("ch=%d  port=%x\n",ch,port(ch<<3));
  to_gps(ch<<3,data);
}


void all_cntl(int data)
{
  to_gps(0x70,data);

}
void multi_cntl(int data)
{
  to_gps(0x60,data);

}

int ch_i_track(char ch)
{
  return(from_gps((ch<<2)+0x84));
}

int ch_q_track(char ch)
{
  return(from_gps((ch<<2)+0x85));
}

int ch_i_prompt(char ch)
{
  return(from_gps((ch<<2)+0x86));
}

int ch_q_prompt(char ch)
{
  return(from_gps((ch<<2)+0x87));
}

void ch_accum_reset(char ch)
{
  to_gps((ch<<2)+0x85,0);
}

void ch_code_slew(char ch,int data)
{
  to_gps((ch<<2)+0x84,data);
}

void all_code_slew(int data)
{
  to_gps(0x70,data);
}

void data_retent_w(int data)
{
  to_gps(0xe4,data);
}

int data_retent_r(void)
{
  return(from_gps(0xe4));
}

void data_bus_test_w(int data)
{
  to_gps(0xf2,data);
}

int data_bus_test_r(void)
{
  return(from_gps(0xf2));
}


inline int meas_status(void)
{
  return(from_gps(0x81));
}

void program_TIC(long data)
{
  unsigned int high,low;
  high=int(data>>16);
  low =int(data & 0xffff);
  to_gps(0x6d,high);
  to_gps(0x6f,low);
}

void reset_cntl(int data)
{
  to_gps(0x7f,data);
//  fprintf(out,"reset data=%x\n",data);
}

void ch_carrier(char ch,long freq)
{
  int freq_hi,freq_lo;
  unsigned int add;
  freq_hi=int(freq>>16);
  freq_lo=int(freq&0xffff);
  add=(ch<<3)+3;
  to_gps(add,freq_hi);
  add++;
  to_gps(add,freq_lo);
}

void ch_code(char ch,long freq)
{
  int freq_hi,freq_lo;
  unsigned int add;
  freq_hi=int(freq>>16);
  freq_lo=int(freq&0xffff);
  add=(ch<<3)+5;
  to_gps(add,freq_hi);
  add++;
  to_gps(add,freq_lo);
}

void ch_epoch_load(char ch,unsigned int data)
{
  to_gps((ch<<3)+7,data);
}

void ch_on(char ch)
{
  ch_status=ch_status | bit_pat[ch];
  reset_cntl(ch_status);
}

void ch_off(char ch)
{
  ch_status=ch_status & !bit_pat[ch];
  reset_cntl(ch_status);
}

void system_setup(int data)
{
  to_gps(0x7e,data);
}

void test_control(int data)
{
  to_gps(0x7c,data);
}

void status_latch(void)
{
  to_gps(0x80,0);
}
void io_config(int data)
{
  to_gps(0xf0,data);
}

void self_test(void)
{
  unsigned int indataaax,indata55x,indataaay,indata55y,error;
  error=0;
  data_retent_w(0x5500);
  data_bus_test_w(0xaa55);
  indata55x=data_retent_r();
  indataaax=data_bus_test_r();
  data_retent_w(0xaa00);
  data_bus_test_w(0x55aa);
  indataaay=data_retent_r();
  indata55y=data_bus_test_r();
  if ((indata55x != 0x5500) || (indataaax != 0xaa55)
	|| (indataaay != 0xaa00) || (indata55y != 0x55aa))
  {
	 error=1;
	 printf("data line error\n");
	 printf("indata55x=%x , indataaax=%x\n",indata55x,indataaax);
	 printf("indataaay=%x , indata55y=%x\n",indataaay,indata55y);
  }
  if (error==1) exit(0);
}

⌨️ 快捷键说明

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