xpmr.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  1. /*
  2. * xpmr.h - for Xelatec Private Mobile Radio Processes
  3. *
  4. * All Rights Reserved. Copyright (C)2007, Xelatec, LLC
  5. *
  6. * 20070808 1235 Steven Henke, W9SH, sph@xelatec.com
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. * This version may be optionally licenced under the GNU LGPL licence.
  23. *
  24. * A license has been granted to Digium (via disclaimer) for the use of
  25. * this code.
  26. *
  27. */
  28. /*! \file
  29. *
  30. * \brief Private Land Mobile Radio Channel Voice and Signaling Processor
  31. *
  32. * \author Steven Henke, W9SH <sph@xelatec.com> Xelatec, LLC
  33. */
  34. #ifndef XPMR_H
  35. #define XPMR_H 1
  36. #define XPMR_DEV 0 // when running in test mode
  37. #define XPMR_TRACE_LEVEL 0
  38. #ifdef RADIO_RTX
  39. #define DTX_PROG 1 // rf transceiver module
  40. #define XPMR_PPTP 0 // parallel port test probe
  41. #else
  42. #define DTX_PROG 0
  43. #define XPMR_PPTP 0
  44. #endif
  45. #if (DTX_PROG == 1) || XPMR_PPTP == 1
  46. #include <parapindriver.h>
  47. #endif
  48. #ifdef CHAN_USBRADIO
  49. #define XPMR_DEBUG0 1
  50. #define XPMR_TRACE 1
  51. #define TRACEO(level,a) { if ( o->tracelevel >= level ) {printf a;} }
  52. #else
  53. #define XPMR_DEBUG0 1
  54. #define XPMR_TRACE 1
  55. #define TRACEO(level,a)
  56. #endif
  57. #define LSD_DFS 5
  58. #define LSD_DFD 1
  59. #if(XPMR_DEBUG0 == 1)
  60. #define XPMR_DEBUG_CHANS 16
  61. #define TSCOPE(a) {strace a;}
  62. #else
  63. #define XPMR_DEBUG_CHANS 0
  64. #define TSCOPE(a)
  65. #endif
  66. #define XPMR_TRACE_AMP 8192
  67. // TRACEM(3,TSYS_LSD,("pmr_lsdctl_exec() RX FRAME UNPROCESSED.\n"));
  68. #if(XPMR_TRACE == 1)
  69. #define TRACEX(a) {printf a;}
  70. #define TRACEXL(a) {printf("%s @ %u : ",__FILE__ ,__LINE__); printf a; }
  71. #define TRACEXT(a) {struct timeval hack; gettimeofday(&hack,NULL); printf("%ld.",hack.tv_sec%100000); printf("%i : ",(int)hack.tv_usec); printf a; }
  72. #define TRACEXR(a) {printf a;}
  73. #define TRACEC(level,a) {if(pChan->tracelevel>=level){printf("%08i ",pChan->frameCountRx);printf a;} }
  74. #define TRACEF(level,a) {if(pChan->tracelevel>=level){printf a;} }
  75. #define TRACEJ(level,a) {if(XPMR_TRACE_LEVEL>=level){printf a;} }
  76. #define TRACES(level,a) {if(mySps->parentChan->tracelevel >= level){printf a;} }
  77. #define TRACET(level,a) {if(pChan->tracelevel>=level){printf("%08i %02i",pChan->frameCountRx,pChan->rptnum);printf a;} }
  78. #define TRACEXR(a) {printf a;}
  79. #define TRACEM(level,sys,a) {if(pChan->tracelevel>=level || (pChan->tracesys[sys])){printf a;} }
  80. #else
  81. #define TRACEX(a)
  82. #define TRACEXL(a)
  83. #define TRACEXT(a)
  84. #define TRACEC(level,a)
  85. #define TRACEF(level,a)
  86. #define TRACEJ(level,a)
  87. #define TRACES(level,a)
  88. #define TRACET(level,a)
  89. #define TRACEXR(a)
  90. #define TRACEM(level,sys,a)
  91. #endif
  92. #define i8 int8_t
  93. #define u8 u_int8_t
  94. #define i16 int16_t
  95. #define u16 u_int16_t
  96. #define i32 int32_t
  97. #define u32 u_int32_t
  98. #define i64 int64_t
  99. #define u64 u_int64_t
  100. #define M_Q31 0x80000000 //
  101. #define M_Q30 0x40000000 //
  102. #define M_Q29 0x20000000 //
  103. #define M_Q28 0x10000000 //
  104. #define M_Q27 0x08000000 //
  105. #define M_Q26 0x04000000 //
  106. #define M_Q25 0x02000000 //
  107. #define M_Q24 0x01000000 //
  108. #define M_Q23 0x00800000 //
  109. #define M_Q22 0x00400000 //
  110. #define M_Q21 0x00200000 // undsoweiter
  111. #define M_Q20 0x00100000 // 1048576
  112. #define M_Q19 0x00080000 // 524288
  113. #define M_Q18 0x00040000 // 262144
  114. #define M_Q17 0x00020000 // 131072
  115. #define M_Q16 0x00010000 // 65536
  116. #define M_Q15 0x00008000 // 32768
  117. #define M_Q14 0x00004000 // 16384
  118. #define M_Q13 0x00002000 // 8182
  119. #define M_Q12 0x00001000 // 4096
  120. #define M_Q11 0x00000800 // 2048
  121. #define M_Q10 0x00000400 // 1024
  122. #define M_Q9 0x00000200 // 512
  123. #define M_Q8 0x00000100 // 256
  124. #define M_Q7 0x00000080 // 128
  125. #define M_Q6 0x00000040 // 64
  126. #define M_Q5 0x00000020 // 32
  127. #define M_Q4 0x00000010 // 16
  128. #define M_Q3 0x00000008 // 16
  129. #define M_Q2 0x00000004 // 16
  130. #define M_Q1 0x00000002 // 16
  131. #define M_Q0 0x00000001 // 16
  132. #define RADIANS_PER_CYCLE (2*M_PI)
  133. #define SAMPLE_RATE_INPUT 48000
  134. #define SAMPLE_RATE_NETWORK 8000
  135. #define SAMPLES_PER_BLOCK 160
  136. #define MS_PER_FRAME 20
  137. #define SAMPLES_PER_MS 8
  138. #define CTCSS_NULL -1
  139. #define CTCSS_RXONLY -2
  140. #define CTCSS_NUM_CODES 38 // 0 - 37
  141. #define CTCSS_SCOUNT_MUL 100
  142. #define CTCSS_INTEGRATE 3932 // 32767*.120 // 120/1000 // 0.120
  143. #define CTCSS_INPUT_LIMIT 1000
  144. #define CTCSS_DETECT_POINT 1989
  145. #define CTCSS_HYSTERSIS 200
  146. #define CTCSS_TURN_OFF_TIME 160 // ms
  147. #define CTCSS_TURN_OFF_SHIFT 240 // degrees
  148. #define TOC_NOTONE_TIME 600 // ms
  149. #define DDB_FRAME_SIZE 160 // clock de-drift defaults
  150. #define DDB_FRAMES_IN_BUFF 8
  151. #define DDB_ERR_MODULUS 10000
  152. #define DCS_TURN_OFF_TIME 180
  153. #define NUM_TXLSD_FRAMEBUFFERS 4
  154. #define CHAN_TXSTATE_IDLE 0
  155. #define CHAN_TXSTATE_ACTIVE 1
  156. #define CHAN_TXSTATE_TOC 2
  157. #define CHAN_TXSTATE_HANGING 3
  158. #define CHAN_TXSTATE_FINISHING 4
  159. #define CHAN_TXSTATE_COMPLETE 5
  160. #define CHAN_TXSTATE_USURPED 9
  161. #define SMODE_NULL 0
  162. #define SMODE_CARRIER 1
  163. #define SMODE_CTCSS 2
  164. #define SMODE_DCS 3
  165. #define SMODE_LSD 4
  166. #define SMODE_MPT 5
  167. #define SMODE_DST 6
  168. #define SMODE_P25 7
  169. #define SMODE_MDC 8
  170. #define SPS_OPT_START 1
  171. #define SPS_OPT_STOP 2
  172. #define SPS_OPT_TURNOFF 3
  173. #define SPS_OPT_STOPNOW 4
  174. #define SPS_STAT_STOPPED 0
  175. #define SPS_STAT_STARTING 1
  176. #define SPS_STAT_RUNNING 2
  177. #define SPS_STAT_HALTING 3
  178. #define PP_BIT_TEST 6
  179. #define PP_REG_LEN 32
  180. #define PP_BIT_TIME 100000
  181. #define DTX_CLK LP_PIN02
  182. #define DTX_DATA LP_PIN03
  183. #define DTX_ENABLE LP_PIN04
  184. #define DTX_TX LP_PIN05 // only used on older mods
  185. #define DTX_TXPWR LP_PIN06 // not used
  186. #define DTX_TP1 LP_PIN07 // not used
  187. #define DTX_TP2 LP_PIN08 // not used
  188. #define BIN_PROG_0 LP_PIN06
  189. #define BIN_PROG_1 LP_PIN07
  190. #define BIN_PROG_2 LP_PIN08
  191. #define BIN_PROG_3 LP_PIN09
  192. #ifndef CHAN_USBRADIO
  193. enum {RX_AUDIO_NONE,RX_AUDIO_SPEAKER,RX_AUDIO_FLAT};
  194. enum {TX_AUDIO_NONE,TX_AUDIO_FLAT,TX_AUDIO_FILTERED,TX_AUDIO_PROC};
  195. enum {CD_IGNORE,CD_XPMR_NOISE,CD_XPMR_VOX,CD_HID,CD_HID_INVERT};
  196. enum {SD_IGNORE,SD_HID,SD_HID_INVERT,SD_XPMR}; // no,external,externalinvert,software
  197. enum {RX_KEY_CARRIER,RX_KEY_CARRIER_CODE};
  198. enum {TX_OUT_OFF,TX_OUT_VOICE,TX_OUT_LSD,TX_OUT_COMPOSITE,TX_OUT_AUX};
  199. enum {TOC_NONE,TOC_PHASE,TOC_NOTONE};
  200. #endif
  201. enum dbg_pts {
  202. RX_INPUT,
  203. RX_NOISE_AMP,
  204. RX_NOISE_TRIG,
  205. RX_CTCSS_LPF,
  206. RX_CTCSS_CENTER,
  207. RX_CTCSS_NRZ,
  208. RX_CTCSS_CLK,
  209. RX_CTCSS_P0,
  210. RX_CTCSS_P1,
  211. RX_CTCSS_ACCUM,
  212. RX_CTCSS_DVDT,
  213. RX_CTCSS_DECODE,
  214. RX_DCS_CENTER,
  215. RX_DCS_DEC,
  216. RX_DCS_DIN,
  217. RX_DCS_CLK,
  218. RX_DCS_DAT,
  219. RX_LSD_LPF,
  220. RX_LSD_CLK,
  221. RX_LSD_DAT,
  222. RX_LSD_DEC,
  223. RX_LSD_CENTER,
  224. RX_LSD_SYNC,
  225. RX_LSD_STATE,
  226. RX_LSD_ERR,
  227. RX_LSD_INTE,
  228. RX_SMODE,
  229. TX_PTT_IN,
  230. TX_PTT_OUT,
  231. TX_DEDRIFT_LEAD,
  232. TX_DEDRIFT_ERR,
  233. TX_DEDRIFT_FACTOR,
  234. TX_DEDRIFT_DRIFT,
  235. TX_DEDRIFT_TWIDDLE,
  236. TX_CTCSS_GEN,
  237. TX_SIGGEN_0,
  238. TX_DCS_CLK,
  239. TX_DCS_DAT,
  240. TX_DCS_LPF,
  241. TX_LSD_CLK,
  242. TX_LSD_DAT,
  243. TX_LSD_GEN,
  244. TX_LSD_LPF,
  245. TX_NET_INT,
  246. TX_VOX_HPF,
  247. TX_VOX_LIM,
  248. TX_VOX_LPF,
  249. TX_OUT_A,
  250. TX_OUT_B,
  251. NUM_DEBUG_PTS
  252. };
  253. typedef struct
  254. {
  255. i16 mode;
  256. i16 point[NUM_DEBUG_PTS];
  257. i16 trace[16];
  258. i16 scale[16];
  259. i16 offset[16];
  260. i16 buffer[16 * SAMPLES_PER_BLOCK]; // allocate for rx and tx
  261. i16 *source[16];
  262. } t_sdbg;
  263. typedef struct
  264. {
  265. i16 lock;
  266. i16 option; // 1 = data in, 0 = data out
  267. i16 debug;
  268. i16 debugcnt;
  269. i32 rxframecnt;
  270. i32 txframecnt;
  271. i32 skew;
  272. i16 frames;
  273. i16 framesize;
  274. i16 buffersize;
  275. i32 timer;
  276. i32 x0,x1,y0,y1;
  277. i16 inputindex;
  278. i16 outputindex;
  279. i16 lead;
  280. i16 err;
  281. i16 accum;
  282. i16 *ptr; // source or destination
  283. i16 *buff;
  284. i16 inputcnt;
  285. i16 initcnt;
  286. i32 factor;
  287. i32 drift;
  288. i32 modulus;
  289. i32 z1;
  290. struct {
  291. unsigned rxlock:1;
  292. unsigned txlock:1;
  293. unsigned twiddle:1;
  294. unsigned doitnow:1;
  295. }b;
  296. }
  297. t_dedrift;
  298. /*
  299. one structure for each ctcss tone to decode
  300. */
  301. typedef struct
  302. {
  303. i16 counter; // counter to next sample
  304. i16 counterFactor; // full divisor used to increment counter
  305. i16 binFactor;
  306. i16 fudgeFactor;
  307. i16 peak; // peak amplitude now maw sph now
  308. i16 enabled;
  309. i16 state; // dead, running, error
  310. i16 zIndex; // z bucket index
  311. i16 z[4];
  312. i16 zi;
  313. i16 dvu;
  314. i16 dvd;
  315. i16 zd;
  316. i16 setpt;
  317. i16 hyst;
  318. i16 decode;
  319. i16 diffpeak;
  320. i16 debug;
  321. #if XPMR_DEBUG0 == 1
  322. i16 lasttv0;
  323. i16 lasttv1;
  324. i16 lasttv2;
  325. i16 lasttv3;
  326. i16 *pDebug0; // pointer to debug output
  327. i16 *pDebug1; // pointer to debug output
  328. i16 *pDebug2; // pointer to debug output
  329. i16 *pDebug3; // pointer to debug output
  330. #endif
  331. } t_tdet;
  332. typedef struct
  333. {
  334. i16 enabled; // if 0 none, 0xFFFF all tones, or single tone
  335. i16 *input; // source data
  336. i16 clamplitude;
  337. i16 center;
  338. i16 decode; // current ctcss decode index
  339. i32 BlankingTimer;
  340. u32 TurnOffTimer;
  341. i16 gain;
  342. i16 limit;
  343. i16 debugIndex;
  344. i16 *pDebug0;
  345. i16 *pDebug1;
  346. i16 *pDebug2;
  347. i16 *pDebug3;
  348. i16 testIndex;
  349. i16 multiFreq;
  350. i8 relax;
  351. t_tdet tdet[CTCSS_NUM_CODES];
  352. i8 numrxcodes;
  353. i16 rxCtcssMap[CTCSS_NUM_CODES];
  354. char *rxctcss[CTCSS_NUM_CODES]; // pointers to each tone in string above
  355. char *txctcss[CTCSS_NUM_CODES];
  356. i32 txctcssdefault_index;
  357. float txctcssdefault_value;
  358. struct{
  359. unsigned valid:1;
  360. }b;
  361. } t_dec_ctcss;
  362. /*
  363. Low Speed Data
  364. */
  365. /*
  366. general purpose pmr signal processing element
  367. */
  368. struct t_pmr_chan;
  369. typedef struct t_pmr_sps
  370. {
  371. i16 index; // unique to each instance
  372. i16 enabled; // enabled/disabled
  373. struct t_pmr_chan *parentChan;
  374. i16 *source; // source buffer
  375. i16 *sourceB; // source buffer B
  376. i16 *sink; // sink buffer
  377. i16 numChanOut; // allows output direct to interleaved buffer
  378. i16 selChanOut;
  379. i32 ticks;
  380. i32 timer;
  381. i32 count;
  382. void *buff; // this structure's internal buffer
  383. i16 *debugBuff0; // debug buffer
  384. i16 *debugBuff1; // debug buffer
  385. i16 *debugBuff2; // debug buffer
  386. i16 *debugBuff3; // debug buffer
  387. i16 nSamples; // number of samples in the buffer
  388. u32 buffSize; // buffer maximum index
  389. u32 buffInIndex; // index to current input point
  390. u32 buffOutIndex; // index to current output point
  391. u32 buffLead; // lead of input over output through cb
  392. i16 decimate; // decimation or interpolation factor (could be put in coef's)
  393. i16 interpolate;
  394. i16 decimator; // like the state this must be saved between calls (could be put in x's)
  395. u32 sampleRate; // in Hz for elements in this structure
  396. u32 freq; // in 0.1 Hz
  397. i16 measPeak; // do measure Peak
  398. i16 amax; // buffer amplitude maximum
  399. i16 amin; // buffer amplitude minimum
  400. i16 apeak; // buffer amplitude peak value (peak to peak)/2
  401. i16 setpt; // amplitude set point for amplitude comparator
  402. i16 hyst; // hysterysis for amplitude comparator
  403. i16 compOut; // amplitude comparator output
  404. i32 discounteru; // amplitude detector integrator discharge counter upper
  405. i32 discounterl; // amplitude detector integrator discharge counter lower
  406. i32 discfactor; // amplitude detector integrator discharge factor
  407. i16 err; // error condition
  408. i16 option; // option / request zero
  409. i16 state; // stopped, start, stopped assumes zero'd
  410. i16 pending;
  411. struct {
  412. unsigned hit:1;
  413. unsigned hitlast:1;
  414. unsigned hita:1;
  415. unsigned hitb:1;
  416. unsigned bithit:1;
  417. unsigned now:1;
  418. unsigned next:1;
  419. unsigned prev:1;
  420. unsigned clock:1;
  421. unsigned hold:1;
  422. unsigned opt1:1;
  423. unsigned opt2:1;
  424. unsigned polarity:1;
  425. unsigned dotting:1;
  426. unsigned lastbitpending:1;
  427. unsigned outzero:1;
  428. unsigned settling:1;
  429. unsigned syncing:1;
  430. }b;
  431. i16 cleared; // output buffer cleared
  432. i16 delay;
  433. i16 decode;
  434. i32 inputGain; // apply to input data ? in Q7.8 format
  435. i32 inputGainB; // apply to input data ? in Q7.8 format
  436. i32 outputGain; // apply to output data ? in Q7.8 format
  437. i16 mixOut;
  438. i16 monoOut;
  439. i16 filterType; // iir, fir, 1, 2, 3, 4 ...
  440. i16 (*sigProc)(struct t_pmr_sps *sps); // function to call
  441. i32 calcAdjust; // final adjustment
  442. i16 nx; // number of x history elements
  443. i16 ncoef; // number of coefficients
  444. i16 size_x; // size of each x history element
  445. i16 size_coef; // size of each coefficient
  446. void *x; // history registers
  447. void *x2; // history registers, 2nd bank
  448. void *coef; // coefficients
  449. void *coef2; // coefficients 2
  450. void *nextSps; // next Sps function
  451. } t_pmr_sps;
  452. struct t_dec_dcs;
  453. struct t_lsd_control;
  454. struct t_decLsd;;
  455. struct t_encLsd;
  456. /*
  457. pmr channel
  458. */
  459. typedef struct t_pmr_chan
  460. {
  461. i16 index; // which one
  462. i16 devicenum; // belongs to
  463. char *name;
  464. i16 enabled; // enabled/disabled
  465. i16 status; // ok, error, busy, idle, initializing
  466. i16 tracelevel;
  467. i16 tracetype;
  468. u32 tracemask;
  469. i16 nSamplesRx; // max frame size
  470. i16 nSamplesTx;
  471. i32 inputSampleRate; // in S/s 48000
  472. i32 baseSampleRate; // in S/s 8000
  473. i16 inputGain;
  474. i16 inputOffset;
  475. i32 ticks; // time ticks
  476. u32 frameCountRx; // number processed
  477. u32 frameCountTx;
  478. i8 txframelock;
  479. i32 txHangTime;
  480. i32 txHangTimer;
  481. i32 txTurnOff;
  482. i16 txBufferClear;
  483. u32 txfreq;
  484. u32 rxfreq;
  485. i8 txpower;
  486. i32 txsettletime; // in samples
  487. i32 txsettletimer;
  488. i16 rxDC; // average DC value of input
  489. i16 rxSqSet; // carrier squelch threshold
  490. i16 rxSqHyst; // carrier squelch hysterysis
  491. i16 rxRssi; // current Rssi level
  492. i16 rxQuality; // signal quality metric
  493. i16 rxCarrierDetect; // carrier detect
  494. i16 rxCdType;
  495. i16 rxSqVoxAdj;
  496. i16 rxExtCarrierDetect;
  497. i32 inputBlanking; // Tx pulse eliminator
  498. i16 rxDemod; // see enum
  499. i16 txMod; //
  500. i16 rxNoiseSquelchEnable;
  501. i16 rxHpfEnable;
  502. i16 rxDeEmpEnable;
  503. i16 rxCenterSlicerEnable;
  504. i16 rxCtcssDecodeEnable;
  505. i16 rxDcsDecodeEnable;
  506. i16 rxDelayLineEnable;
  507. i16 txHpfEnable;
  508. i16 txLimiterEnable;
  509. i16 txPreEmpEnable;
  510. i16 txLpfEnable;
  511. char radioDuplex;
  512. char *pStr;
  513. // start channel signaling codes source
  514. char *pRxCodeSrc; // source
  515. char *pTxCodeSrc; // source
  516. char *pTxCodeDefault; // source
  517. // end channel signaling codes source
  518. // start signaling code info derived from source
  519. i16 numrxcodes;
  520. i16 numtxcodes;
  521. char *pRxCodeStr; // copied and cut up
  522. char **pRxCode; // pointers to subs
  523. char *pTxCodeStr;
  524. char **pTxCode;
  525. char txctcssdefault[16]; // codes from higher level
  526. char *rxctcssfreqs; // rest are derived from this
  527. char *txctcssfreqs;
  528. char numrxctcssfreqs;
  529. char numtxctcssfreqs;
  530. char *rxctcss[CTCSS_NUM_CODES]; // pointers to each tone in string above
  531. char *txctcss[CTCSS_NUM_CODES];
  532. i16 rxCtcssMap[CTCSS_NUM_CODES];
  533. i8 txcodedefaultsmode;
  534. i16 txctcssdefault_index;
  535. float txctcssdefault_value;
  536. char txctcssfreq[32]; // encode now
  537. char rxctcssfreq[32]; // decode now
  538. // end most of signaling code info derived from source
  539. struct t_lsd_control *pLsdCtl;
  540. i16 rptnum;
  541. i16 area;
  542. char *ukey;
  543. u32 idleinterval;
  544. char turnoffs;
  545. char pplock;
  546. t_dedrift dd;
  547. i16 dummy;
  548. i32 txScramFreq;
  549. i32 rxScramFreq;
  550. i16 gainVoice;
  551. i16 gainSubAudible;
  552. i16 txMixA; // Off, Ctcss, Voice, Composite
  553. i16 txMixB; // Off, Ctcss, Voice, Composite
  554. i16 rxMuting;
  555. i16 rxCpuSaver;
  556. i16 txCpuSaver;
  557. i8 rxSqMode; // 0 open, 1 carrier, 2 coded
  558. i8 cdMethod;
  559. i16 rxSquelchPoint;
  560. i16 rxCarrierPoint;
  561. i16 rxCarrierHyst;
  562. i16 txCtcssTocShift;
  563. i16 txCtcssTocTime;
  564. i8 txTocType;
  565. i16 smode; // ctcss, dcs, lsd
  566. i16 smodecode;
  567. i16 smodewas; // ctcss, dcs, lsd
  568. i32 smodetimer; // in ms
  569. i32 smodetime; // to set in ms
  570. t_dec_ctcss *rxCtcss;
  571. struct t_dec_dcs *decDcs;
  572. struct t_decLsd *decLsd;
  573. struct t_encLsd *pLsdEnc;
  574. i16 clamplitudeDcs;
  575. i16 centerDcs;
  576. u32 dcsBlankingTimer;
  577. i16 dcsDecode; // current dcs decode value
  578. i16 clamplitudeLsd;
  579. i16 centerLsd;
  580. i16 txPttIn; // from external request
  581. i16 txPttOut; // to radio hardware
  582. i16 txPttHid;
  583. i16 bandwidth; // wide/narrow
  584. i16 txCompand; // type
  585. i16 rxCompand; //
  586. i16 txEqRight; // muted, flat, pre-emp limited filtered
  587. i16 txEqLeft;
  588. i16 txPotRight; //
  589. i16 txPotLeft; //
  590. i16 rxPotRight; //
  591. i16 rxPotLeft; //
  592. i16 function;
  593. i16 txState; // off,settling,on,hangtime,turnoff
  594. i16 spsIndex;
  595. t_pmr_sps *spsMeasure; // measurement block
  596. t_pmr_sps *spsRx; // 1st signal processing struct
  597. t_pmr_sps *spsRxLsd;
  598. t_pmr_sps *spsRxLsdNrz;
  599. t_pmr_sps *spsRxDeEmp;
  600. t_pmr_sps *spsRxHpf;
  601. t_pmr_sps *spsRxVox;
  602. t_pmr_sps *spsDelayLine; // Last signal processing struct
  603. t_pmr_sps *spsRxOut; // Last signal processing struct
  604. t_pmr_sps *spsTx; // 1st signal processing struct
  605. t_pmr_sps *spsTxOutA; // Last signal processing struct
  606. t_pmr_sps *spsTxOutB; // Last signal processing struct
  607. t_pmr_sps *spsSigGen0; // ctcss
  608. t_pmr_sps *spsSigGen1; // test and other tones
  609. t_pmr_sps *spsLsdGen;
  610. t_pmr_sps *spsTxLsdLpf;
  611. // tune tweaks
  612. i32 rxVoxTimer; // Vox Hang Timer
  613. i16 *prxSquelchAdjust;
  614. // i16 *prxNoiseMeasure; // for autotune
  615. // i32 *prxNoiseAdjust;
  616. i16 *prxVoiceMeasure;
  617. i32 *prxVoiceAdjust;
  618. i16 *prxCtcssMeasure;
  619. i32 *prxCtcssAdjust;
  620. i16 *ptxVoiceAdjust; // from calling application
  621. i32 *ptxCtcssAdjust; // from calling application
  622. i32 *ptxLimiterAdjust; // from calling application
  623. struct {
  624. unsigned pmrNoiseSquelch:1;
  625. unsigned rxHpf:1;
  626. unsigned txHpf:1;
  627. unsigned txLpf:1;
  628. unsigned rxDeEmphasis:1;
  629. unsigned txPreEmphasis:1;
  630. unsigned startSpecialTone:1;
  631. unsigned stopSpecialTone:1;
  632. unsigned doingSpecialTone:1;
  633. unsigned extCarrierDetect:1;
  634. unsigned txCapture:1;
  635. unsigned rxCapture:1;
  636. unsigned reprog:1;
  637. unsigned radioactive:1;
  638. unsigned rxplmon:1;
  639. unsigned remoted:1;
  640. unsigned loopback:1;
  641. unsigned rxpolarity:1;
  642. unsigned txpolarity:1;
  643. unsigned dcsrxpolarity:1;
  644. unsigned dcstxpolarity:1;
  645. unsigned lsdrxpolarity:1;
  646. unsigned lsdtxpolarity:1;
  647. unsigned txsettling:1;
  648. unsigned smodeturnoff:1;
  649. unsigned ctcssRxEnable:1;
  650. unsigned ctcssTxEnable:1;
  651. unsigned dcsRxEnable:1;
  652. unsigned dcsTxEnable:1;
  653. unsigned lmrRxEnable:1;
  654. unsigned lmrTxEnable:1;
  655. unsigned mdcRxEnable:1;
  656. unsigned mdcTxEnable:1;
  657. unsigned dstRxEnable:1;
  658. unsigned dstTxEnable:1;
  659. unsigned p25RxEnable:1;
  660. unsigned p25TxEnable:1;
  661. unsigned ax25Enable:1;
  662. unsigned txCtcssInhibit:1;
  663. unsigned rxkeyed:1;
  664. unsigned rxhalted:1;
  665. unsigned txhalted:1;
  666. unsigned pptp_p1:1;
  667. unsigned pptp_p2:1;
  668. unsigned tuning:1;
  669. unsigned pttwas:1;
  670. }b;
  671. i16 *pRxDemod; // buffers
  672. i16 *pRxBase; // decimated lpf input
  673. i16 *pRxNoise;
  674. i16 *pRxLsd; // subaudible only
  675. i16 *pRxHpf; // subaudible removed
  676. i16 *pRxDeEmp; // EIA Audio
  677. i16 *pRxSpeaker; // EIA Audio
  678. i16 *pRxDcTrack; // DC Restored LSD
  679. i16 *pRxLsdLimit; // LSD Limited
  680. i16 *pRxCtcss; //
  681. i16 *pRxSquelch;
  682. i16 *prxVoxMeas;
  683. i16 *prxMeasure;
  684. i16 *pTxInput; // input data
  685. i16 *pTxBase; // input data
  686. i16 *pTxHpf;
  687. i16 *pTxPreEmp;
  688. i16 *pTxLimiter;
  689. i16 *pTxLsd;
  690. i16 *pTxLsdLpf;
  691. i16 *pTxComposite;
  692. i16 *pTxMod; // upsampled, low pass filtered
  693. i16 *pTxOut; //
  694. i16 *pSigGen0;
  695. i16 *pSigGen1;
  696. i16 *pAlt0;
  697. i16 *pAlt1;
  698. i16 *pNull;
  699. #if XPMR_DEBUG0 == 1
  700. i16 *pRxLsdCen;
  701. i16 *pTstTxOut;
  702. i16 *prxDebug; // consolidated debug buffer
  703. i16 *ptxDebug; // consolidated debug buffer
  704. i16 *prxDebug0;
  705. i16 *prxDebug1;
  706. i16 *prxDebug2;
  707. i16 *prxDebug3;
  708. i16 *ptxDebug0;
  709. i16 *ptxDebug1;
  710. i16 *ptxDebug2;
  711. i16 *ptxDebug3;
  712. #endif
  713. i16 numDebugChannels;
  714. t_sdbg *sdbg;
  715. } t_pmr_chan;
  716. /*
  717. function prototype declarations
  718. */
  719. void strace(i16 point, t_sdbg *sdbg, i16 index, i16 value);
  720. void strace2(t_sdbg *sdbg);
  721. static i16 TxTestTone(t_pmr_chan *pChan, i16 function);
  722. t_pmr_chan *createPmrChannel(t_pmr_chan *tChan, i16 numSamples);
  723. t_pmr_sps *createPmrSps(t_pmr_chan *pChan);
  724. i16 destroyPmrChannel(t_pmr_chan *pChan);
  725. i16 destroyPmrSps(t_pmr_sps *pSps);
  726. i16 pmr_rx_frontend(t_pmr_sps *mySps);
  727. i16 pmr_gp_fir(t_pmr_sps *mySps);
  728. i16 pmr_gp_iir(t_pmr_sps *mySps);
  729. i16 gp_inte_00(t_pmr_sps *mySps);
  730. i16 gp_diff(t_pmr_sps *mySps);
  731. i16 CenterSlicer(t_pmr_sps *mySps);
  732. i16 ctcss_detect(t_pmr_chan *pmrChan);
  733. i16 SoftLimiter(t_pmr_sps *mySps);
  734. i16 SigGen(t_pmr_sps *mySps);
  735. i16 pmrMixer(t_pmr_sps *mySps);
  736. i16 DelayLine(t_pmr_sps *mySps);
  737. i16 PmrRx(t_pmr_chan *PmrChan, i16 *input, i16 *outputrx, i16 *outputtx );
  738. i16 PmrTx(t_pmr_chan *PmrChan, i16 *input);
  739. i16 string_parse(char *src, char **dest, char ***ptrs);
  740. i16 code_string_parse(t_pmr_chan *pChan);
  741. i16 CtcssFreqIndex(float freq);
  742. i16 MeasureBlock(t_pmr_sps *mySps);
  743. void dedrift (t_pmr_chan *pChan);
  744. void dedrift_write (t_pmr_chan *pChan, i16 *src);
  745. void ppspiout (u32 spidata);
  746. void progdtx (t_pmr_chan *pChan);
  747. void ppbinout (u8 chan);
  748. #if XPMR_PPTP == 1
  749. void pptp_init (void);
  750. void pptp_write (i16 bit, i16 state);
  751. #endif
  752. #endif /* ! XPMR_H */
  753. /* end of file */