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

📄 ogold.c

📁 在linux系统下开发研究移动通信的工具型代码
💻 C
字号:
/* * $Log: ogold.c,v $ * Revision 1.1  2000/05/03 14:30:04  bjc97r * Initial revision * */char *_ogold_id = "$Id: ogold.c,v 1.1 2000/05/03 14:30:04 bjc97r Exp $";#include <stdio.h>#include <stdlib.h>#include "ogold.h"/* * It create an OGold code generator with the two preferred m-sequences * with the given index. The OGold code generator is returned. * The possible range of index is 0 to (2^deg - 1). */OGold *ogold_create( unsigned deg, unsigned long p0, unsigned long p1,		     unsigned long index ){  OGold *ogold;  if ( deg > 31 ) {    fprintf(stderr, "ogold_create: ..cannot handle deg > 31\n");    return NULL;  }  ogold = (OGold*) malloc( sizeof(OGold) );  ogold->gold    = gold_create( deg, p0, p1, index, 1 );  ogold->period  = 1 << deg; /* 2^deg */  ogold->counter = 1;  return ogold;}/* ogold_free() deallocates the memory space for the OGold code generator. */void ogold_free( OGold *ogold ){  gold_free( ogold->gold );  free( ogold );}/* ogold() gives the next OGold sequence in unipolar value, ie 1 or 0. */char ogold( OGold *id ){  if ( id->counter == id->period ) {    id->counter = 1;    return 0;  }  id->counter++;  return gold(id->gold);}

⌨️ 快捷键说明

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