blob: 8bb9df57e22f0f00ca9918968494efc118dbf724 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*============================================================================*/
2/* eCall ANSI C fixed-point reference source code */
3/* */
4/* File: ecall_defines.h */
5/* Version: 8.6.0 (Rel8) / 9.4.0 (Rel9) */
6/* Date: 2011-02-08 */
7/* Description: constants and common data structures */
8/*----------------------------------------------------------------------------*/
9
10#ifndef ECALL_DEFINES_H_
11#define ECALL_DEFINES_H_
12
13#include <limits.h>
14
15//#define __ECALL_MODEM_SUPPORT_PSAP__
16#define ECALL_ENUM2STR
17
18/*============================================================================*/
19/* General conventions */
20/*----------------------------------------------------------------------------*/
21
22typedef enum { False, True } Bool;
23typedef enum { Minus = -1, Zero, Plus } Tern;
24
25typedef signed char Int8; /* 8 bit signed variable */
26typedef signed short int Int16; /* 16 bit signed variable */
27typedef signed int Int32; /* 32 bit signed variable */
28
29typedef unsigned char Ord1; /* 1 bit variable */
30typedef unsigned char Ord8; /* 8 bit unsigned variable */
31typedef unsigned short int Ord16; /* 16 bit unsigned variable */
32typedef unsigned int Ord32; /* 32 bit unsigned variable */
33
34#define MAX(a,b) ((a)>(b) ? (a) : (b)) /* macro: maximum */
35#define MIN(a,b) ((a)<(b) ? (a) : (b)) /* macro: minimum */
36#define ABS(a) ((a)< 0 ? -(a) : (a)) /* macro: absolute value */
37#define SIGN(a) ((a)< 0 ? (-1) : (1)) /* macro: sign */
38
39#ifndef PCM_LENGTH
40#define PCM_LENGTH (160) /* length of PCM frame in samples */
41#endif
42#ifndef ECALL_MSD_MAX_LENGTH
43#define ECALL_MSD_MAX_LENGTH (140) /* length of MSD message in bytes */
44#endif
45#ifndef PCM_MIN
46#define PCM_MIN (SHRT_MIN) /* minimum PCM value */
47#endif
48#ifndef PCM_MAX
49#define PCM_MAX (SHRT_MAX) /* maximum PCM value */
50#endif
51
52/*============================================================================*/
53/* Synchronization */
54/*----------------------------------------------------------------------------*/
55
56#define SYNC_BADCHECK (3) /* sync consecutive bad check */
57#define SYNC_BADTRACK (4) /* sync consecutive bad track */
58#define SYNC_IDXLEN (75) /* sync index length */
59#define SYNC_THRESHOLD (10e6) /* sync threshold */
60
61#define LOCK_RESYNC (2) /* messages to lock after sync loss */
62#define LOCK_START_UL (2) /* START messages to lock sync (UL) */
63#define LOCK_START_DL (3) /* START messages to lock sync (DL) */
64#define FAIL_RESTART (3) /* START messages to restart */
65
66#define NRF_WAKEUP (3) /* number of wakeup frames */
67#define NRF_SYNC (13) /* number of sync frames */
68#define NRF_OBSERVE (10) /* number of sync observer frames */
69#define NRF_RESYNC (60) /* resync frames after sync loss */
70
71#define NRS_CHECK (480) /* number of samples to check */
72#define NRS_TRACK (240) /* number of samples to track */
73#define NRS_CP (2) /* number of samples next to peaks */
74
75#define PNSEQ_OSF (22) /* oversampling of PN sequence */
76#define PEAK_DIST_PP (30*PNSEQ_OSF) /* distance outer positive peaks */
77#define PEAK_DIST_NN (54*PNSEQ_OSF) /* distance negative peaks */
78#define PEAK_DIST_PN (12*PNSEQ_OSF) /* distance positive to negative */
79
80/*============================================================================*/
81/* Uplink/Downlink format */
82/*----------------------------------------------------------------------------*/
83
84#define ARQ_MAX (8) /* number of redundancy versions */
85#define NRB_TAIL (3) /* number of encoder tail bits */
86#define NRB_CRC (28) /* order of CRC polynomial */
87
88#define NRB_INFO (8*ECALL_MSD_MAX_LENGTH)
89#define NRB_INFO_CRC (8*ECALL_MSD_MAX_LENGTH + NRB_CRC)
90#define NRB_CODE_ARQ (1380)
91#define NRB_CODE_BUFFER (3*(8*ECALL_MSD_MAX_LENGTH + NRB_CRC) + 4*NRB_TAIL)
92
93#define SET_LLMSG (16) /* set size lower-layer messages */
94#define SET_HLMSG (16) /* set size higher-layer messages */
95
96#define NRF_DLDATA (3) /* downlink data frames */
97#define NRF_DLMUTE1LL (3) /* 1st muting lower-layer message */
98#define NRF_DLMUTE1HL (1) /* 1st muting higher-layer message */
99#define NRF_DLCHUNK (NRF_SYNC + NRF_DLMUTE1HL + 2*NRF_DLDATA)
100
101/*============================================================================*/
102/* IVS/PSAP processing */
103/*----------------------------------------------------------------------------*/
104
105#define NRF_MEMCTRL (7)
106#define NRS_MEMSYNC (508 + 38*NRS_CP)
107
108#define IVS_NUMSEND (5) /* number of SEND messages */
109#define IVS_THRESHOLD (40000) /* threshold for control messages */
110#define IVS_GOSTART (6) /* threshold for unreliable START */
111#define IVS_TXFAST (10) /* fast modulator NACK condition */
112#define IVS_TXINC (87) /* sample increment at restart */
113
114#define PSAP_NUMSTART (500) /* number of START messages */
115#define PSAP_NUMACK (5) /* number of ACK messages */
116#define PSAP_NUMHLACK (5) /* number of HLACK messages */
117#define PSAP_THRESHOLD (40) /* threshold for modulator type */
118
119#define FEC_VAR (30206) /* variance: 1/4550000 in Q37 */
120#define FEC_MEAN (0xB9999A) /* mean: 5.8 in Q21 */
121#define FEC_ITERATIONS (8) /* number of decoder iterations */
122#define FEC_STATES (8) /* number of decoder states */
123
124#define IntLLR Int16
125#define LLR_MAX ((Int32)(0x7fff-1))
126#define LOGEXP_RES (401) /* resolution of logexp table */
127#define LOGEXP_DELTA (-6) /* internal Q-factor */
128#define LOGEXP_QIN (8) /* input Q-factor of LLR values */
129
130#endif