blob: 6696396a5bc6944f8f1798675cf2df62f0291199 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*============================================================================*/
2/* eCall ANSI C fixed-point reference source code */
3/* */
4/* File: modemx.h */
5/* Version: 8.6.0 (Rel8) / 9.4.0 (Rel9) */
6/* Date: 2011-02-08 */
7/* Description: IVS and PSAP structures and functions (header file) */
8/*----------------------------------------------------------------------------*/
9
10#ifndef MODEMX_H_
11#define MODEMX_H_
12
13#include <stdio.h>
14#include <string.h>
15
16#include "ecall_defines.h"
17#include "ecall_control.h"
18#include "ecall_modem.h"
19#include "ecall_sync.h"
20#include "ecall_fec.h"
21#include "ecall_rom.h"
22
23#include "kal_public_api.h"
24#include "kal_trace.h"
25#include "l1sp_trc.h"
26
27/* callback functions: to be implemented by the user application */
28
29void Abort(const char *format, ...);
30void LogInfo(const char *format, ...);
31
32/*============================================================================*/
33/* IVS declarations */
34/*----------------------------------------------------------------------------*/
35
36typedef enum {
37 IVSEVENT_SENDINGSTART,
38 IVSEVENT_SENDINGMSD,
39 IVSEVENT_RESTARTMSD,
40 IVSEVENT_CONTROLSYNC,
41 IVSEVENT_CONTROLLOCK,
42 IVSEVENT_LLACKRECEIVED,
43 IVSEVENT_HLACKRECEIVED,
44 IVSEVENT_IDLEPOSTRESET,
45 IVSEVENT_IDLEPOSTSTART,
46 IVSEVENT_TIMEOUT,
47 IVSEVENT_NACKRECEIVED,
48 IVSEVENT_RECEIVESTART //self defined
49} IvsEvent;
50
51/* callback functions: to be implemented by the user application */
52
53void IvsCatchEvent(IvsEvent ie);
54void IvsReceiveHlack(const Ord8 data);
55
56/*----------------------------------------------------------------------------*/
57
58void IvsReset(const Ord8 *msd, int length);
59void IvsProcess(Int16 *pcm);
60void IvsSendStart(void);
61
62void IvsRxReset(void);
63void IvsRxProcess(const Int16 *pcm);
64
65void IvsTxReset(const Ord8 *msd, int length);
66void IvsTxProcess(Int16 *pcm);
67void IvsTxState(Int16 msg, Int16 metric, Bool syncLock);
68
69/*----------------------------------------------------------------------------*/
70
71typedef enum {
72 IvsIdle,
73 IvsTrigger,
74 IvsStart,
75 IvsSendMsd,
76 IvsAck,
77 IvsHlack
78} IvsState;
79
80typedef struct {
81 IvsState state; /* IVS transmitter state */
82 CtrlTxData ctrl; /* IVS control struct */
83 ModState mod; /* IVS modulator struct */
84
85 Int16 rv; /* redundancy version */
86 Int16 ulN; /* uplink number of frames */
87 Int16 ulIndex; /* uplink frame counter */
88 Int16 ulDelay; /* uplink transmit offset in samples */
89 Int16 dlMsgOld; /* previous control message */
90
91 Bool pendingStart; /* indicates pending START message */
92 Int16 overallNack; /* cumulative NACK count */
93
94 Int16 stateCnt[SET_LLMSG + SET_HLMSG+1];
95 Int16 stateIgn[SET_LLMSG + SET_HLMSG+1];
96
97 Ord1 memCode[NRB_CODE_BUFFER];
98 Int16 memDelay[2*PCM_LENGTH];
99
100 Int8 Ivs_eCall_LIB_Status;
101} IvsTxData;
102
103typedef struct {
104 IvsState state; /* IVS receiver state */
105 CtrlRxData ctrl; /* IVS control struct */
106 SyncState sync; /* IVS sync struct */
107
108 Int16 dlData; /* downlink message symbol */
109 Int16 dlIndex; /* donwlink frame counter */
110 Int16 dlMsgCnt; /* downlink message counter */
111
112 Int16 memCtrl[NRF_MEMCTRL*PCM_LENGTH];
113 Int32 memSync[NRS_MEMSYNC];
114} IvsRxData;
115
116typedef struct {
117 IvsRxData rx; /* IVS receiver struct */
118 IvsTxData tx; /* IVS transmitter struct */
119} IvsData;
120
121// KH: add for integration
122void IvsInit(void *addr);
123void IvsDeinit(void);
124int IvsGetMemSize(void);
125IvsState IvsTxGetState(void);
126IvsState IvsRxGetState(void);
127
128void PsapInit(void *addr);
129void PsapDeinit(void);
130int PsapGetMemSize(void);
131
132void Ivs_Set_Ecall_Lib_Status(Int8 status);
133Int8 Ivs_Get_Ecall_Lib_Status(void);
134
135
136
137
138typedef enum{
139 Ivs_ECALL_DISABLE = 0,
140 Ivs_ECALL_SDT_ONLY,
141 Ivs_ECALL_ENABLE,
142 Ivs_ECALL_MAX = 3
143} Ivs_ECALL_STATUS;
144
145/*============================================================================*/
146/* PSAP declarations */
147/*----------------------------------------------------------------------------*/
148
149typedef enum {
150 PSAPEVENT_SENDINGSTART,
151 PSAPEVENT_SENDINGRESTART,
152 PSAPEVENT_SENDINGLLACK,
153 PSAPEVENT_SENDINGHLACK,
154 PSAPEVENT_CONTROLSYNC,
155 PSAPEVENT_CONTROLLOCK,
156 PSAPEVENT_MSDSYNC,
157 PSAPEVENT_MSDRECEIVED,
158 PSAPEVENT_IDLEPOSTRESET,
159 PSAPEVENT_IDLEPOSTSTART,
160 PSAPEVENT_IDLEPOSTLLACK,
161 PSAPEVENT_IDLEPOSTHLACK,
162 PSAPEVENT_TIMEOUT
163} PsapEvent;
164
165/* callback functions: to be implemented by the user application */
166
167void PsapCatchEvent(PsapEvent pe);
168void PsapReceiveMsd(const Ord8 *msd, int length);
169
170/*----------------------------------------------------------------------------*/
171
172void PsapReset(void);
173void PsapProcess(Int16 *pcm);
174void PsapSendStart(void);
175void PsapSendHlack(const Ord8 data);
176
177void PsapRxReset(void);
178void PsapRxProcess(const Int16 *pcm);
179void PsapRxUplink(const Int16 *pcm);
180void PsapRxDownlink(void);
181void PsapRxSetMod(const SyncState *sync, ModState *mod);
182
183void PsapTxReset(void);
184void PsapTxProcess(Int16 *pcm);
185
186/*----------------------------------------------------------------------------*/
187
188typedef enum {
189 PsapIdle,
190 PsapTrigger,
191 PsapStart,
192 PsapNack,
193 PsapAck,
194 PsapHlack
195} PsapState;
196
197typedef struct {
198 PsapState state; /* PSAP receiver state */
199 CtrlRxData ctrl; /* PSAP control struct */
200 SyncState sync; /* PSAP sync struct */
201 ModState mod; /* PSAP modulator struct */
202
203 Int16 rv; /* redundancy version */
204 Int16 ulN; /* uplink number of frames without muting */
205 Int16 ulIndex; /* uplink frame counter */
206 Int16 mgIndex; /* uplink position in muting gap table */
207 Int16 ulTrials; /* uplink decoding trails */
208 Int16 ulSyncTail; /* sync observation counter after sync success */
209
210 Ord8 dlHlackData; /* downlink higher-layer message (4 bits) */
211 Int16 dlData; /* downlink message symbol */
212 Int16 dlIndex; /* donwlink frame counter */
213 Int16 dlMsgCnt; /* downlink message counter */
214
215 Ord8 *msd; /* MSD in byte representation */
216 Ord1 *msdBin; /* MSD in binary representation */
217 Int16 *memCtrl; /* buffer for control and data demodulation */
218 IntLLR *memCode; /* soft bit buffer for decoding */
219
220 char buffer[0
221 + sizeof(IntLLR)* NRB_CODE_ARQ
222 + sizeof(Int16) * NRF_MEMCTRL*PCM_LENGTH
223 + sizeof(Int32) * NRS_MEMSYNC
224 + sizeof(Int32) * 2*(NRF_SYNC+1)];
225} PsapRxData;
226
227typedef struct {
228 CtrlTxData ctrl; /* PSAP control struct */
229} PsapTxData;
230
231typedef struct {
232 PsapRxData rx; /* PSAP receiver struct */
233 PsapTxData tx; /* PSAP transmitter struct */
234} PsapData;
235
236PsapData* PsapGetData(void);
237
238#endif