FreeCalypso > hg > leo2moko-debug
comparison chipsetsw/layer1/gtt_include/ctm/wait_for_sync.h @ 0:509db1a7b7b8
initial import: leo2moko-r1
| author | Space Falcon <falcon@ivan.Harhan.ORG> |
|---|---|
| date | Mon, 01 Jun 2015 03:24:05 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:509db1a7b7b8 |
|---|---|
| 1 /* | |
| 2 ******************************************************************************* | |
| 3 * | |
| 4 * COPYRIGHT (C) 2000 BY ERICSSON EUROLAB DEUTSCHLAND GmbH | |
| 5 * 90411 NUERNBERG, GERMANY, Tel Int + 49 911 5217 100 | |
| 6 * | |
| 7 * The program(s) may be used and/or copied only with the | |
| 8 * written permission from Ericsson or in accordance | |
| 9 * with the terms and conditions stipulated in the agreement or | |
| 10 * contract under which the program(s) have been supplied. | |
| 11 * | |
| 12 ******************************************************************************* | |
| 13 * | |
| 14 * File : wait_for_sync.h | |
| 15 * Purpose : synchronization routine for the deinterleaver | |
| 16 * | |
| 17 ******************************************************************************* | |
| 18 */ | |
| 19 #ifndef wait_for_sync_h | |
| 20 #define wait_for_sync_h "$Id: $" | |
| 21 | |
| 22 /* | |
| 23 ******************************************************************************* | |
| 24 * INCLUDE FILES | |
| 25 ******************************************************************************* | |
| 26 */ | |
| 27 | |
| 28 #include "ctm_typedefs.h" | |
| 29 | |
| 30 /* | |
| 31 ******************************************************************************* | |
| 32 * DECLARATION OF PROTOTYPES | |
| 33 ******************************************************************************* | |
| 34 */ | |
| 35 | |
| 36 typedef struct { | |
| 37 WORD16 *shift_reg; /* shift register */ | |
| 38 WORD16 *m_sequence; /* maximum length sequence (preamble) */ | |
| 39 WORD16 *m_sequence_resync; /* maximum length sequence (resync) */ | |
| 40 WORD16 *sync_index_vec; /* positions/indices of the preamble */ | |
| 41 WORD16 *resync_index_vec; /* positions/indices of the resync sequence */ | |
| 42 WORD16 length_shift_reg; /* length of the vector shift_reg */ | |
| 43 WORD16 offset; /* */ | |
| 44 WORD16 num_sync_bits; /* length of the preamble */ | |
| 45 BOOL sync_found; /* true if receiver is "in sync" */ | |
| 46 BOOL alreadyCTMreceived; /* true if burst has been received earlier */ | |
| 47 WORD16 *xcorr1_shiftreg; | |
| 48 WORD16 *xcorr2_shiftreg; | |
| 49 UWORD16 cntSymbolsSinceEndOfBurst; | |
| 50 } wait_for_sync_state_t; | |
| 51 | |
| 52 | |
| 53 | |
| 54 /* ----------------------------------------------------------------------- */ | |
| 55 /* Function init_wait_for_sync() */ | |
| 56 /* ***************************** */ | |
| 57 /* Initialization of the synchronization detector. The dimensions of the */ | |
| 58 /* corresponding interleaver at the TX side must be specified: */ | |
| 59 /* B (horizontal) blocklength */ | |
| 60 /* D (vertical) interlace factor */ | |
| 61 /* num_sync_lines2 number of interleaver lines with additional sync bits */ | |
| 62 /* ptr_wait_state pointer to the state variable of the sync detector */ | |
| 63 /* ----------------------------------------------------------------------- */ | |
| 64 | |
| 65 void init_wait_for_sync(wait_for_sync_state_t *ptr_wait_state, | |
| 66 WORD16 B, WORD16 D, | |
| 67 WORD16 num_sync_lines2); | |
| 68 | |
| 69 /* | |
| 70 *********************************************************************** | |
| 71 * Shutdown_wait_for_sync() * | |
| 72 * ************************ * | |
| 73 * Deallocate dyamically created buffers. * | |
| 74 * * | |
| 75 * Input variables: * | |
| 76 * intl_state : pointer to a variable of wait_for_sync_state_t * | |
| 77 * containing the wait_for_sync state machine. * | |
| 78 *********************************************************************** | |
| 79 */ | |
| 80 void Shutdown_wait_for_sync(wait_for_sync_state_t *ptr_wait_state); | |
| 81 | |
| 82 /* ----------------------------------------------------------------------- */ | |
| 83 /* Function reinit_wait_for_sync() */ | |
| 84 /* ******************************* */ | |
| 85 /* Reinitialization of synchronization detector. This function is used in */ | |
| 86 /* case that a burst has been finished and the transmitter has switched */ | |
| 87 /* into idle mode. After calling reinit_wait_for_sync(), the function */ | |
| 88 /* wait_for_sync() inhibits the transmission of the demodulated bits to */ | |
| 89 /* the deinterleaver, until the next synchronization sequence can be */ | |
| 90 /* detected. */ | |
| 91 /* ----------------------------------------------------------------------- */ | |
| 92 | |
| 93 void reinit_wait_for_sync(wait_for_sync_state_t *ptr_wait_state); | |
| 94 | |
| 95 | |
| 96 | |
| 97 /* ----------------------------------------------------------------------- */ | |
| 98 /* Function wait_for_sync() */ | |
| 99 /* ************************ */ | |
| 100 /* This function shall be inserted between the demodulator and the */ | |
| 101 /* deinterleaver. The function searches the synchronization bitstream */ | |
| 102 /* and cuts all received heading bits. As long as no sync is found, this */ | |
| 103 /* function returns *ptr_num_valid_out_bits=0 so that the main program */ | |
| 104 /* is able to skip the deinterleaver as long as no valid bits are */ | |
| 105 /* available. If the sync info is found, the complete internal shift */ | |
| 106 /* register is copied to out_bits so that wait_for_sync can be transparent */ | |
| 107 /* and causes no delay for future calls. */ | |
| 108 /* *ptr_wait_interval returns a value of 0 after such a synchronization */ | |
| 109 /* indicating that this was a regular synchronization. */ | |
| 110 /* */ | |
| 111 /* Regularly, the initial preamble of each burst is used as sync info. */ | |
| 112 /* In addition, the resynchronization sequences, which occur periodically */ | |
| 113 /* during a running burst, are used as "back-up" synchronization in order */ | |
| 114 /* to avoid loosing all characters of a burst, if the preamble was not */ | |
| 115 /* detected. */ | |
| 116 /* If the receiver is already synchronized on a running burst */ | |
| 117 /* and the resynchronization sequence is detected, *ptr_resync_detected */ | |
| 118 /* returns a non-negative value in the range 0...num_in_bits-1 indicating */ | |
| 119 /* at which bit the resynchronization sequence has been detected. If no */ | |
| 120 /* resynchronization has been detected, *ptr_resync_detected is -1. */ | |
| 121 /* If the receiver is NOT synchronized and the resynchronization sequence */ | |
| 122 /* is detected, the resynchronization sequence is used as initial */ | |
| 123 /* synchronization. *ptr_wait_interval returns a value of 32 in this case */ | |
| 124 /* due to the different alignments of the synchronizations based on the */ | |
| 125 /* preamble or the resynchronization sequence, respectively. */ | |
| 126 /* */ | |
| 127 /* In order to carry all bits, the minimum length of the vector out_bits */ | |
| 128 /* must be: */ | |
| 129 /* in_bits.size()-1 + ptr_wait_state->shift_reg_length */ | |
| 130 /* */ | |
| 131 /* in_bits Vector with bits from the demodulator. The */ | |
| 132 /* vector's length can be arbitrarily chosen, */ | |
| 133 /* i.e. according to the block length of the */ | |
| 134 /* signal processing of the main program. */ | |
| 135 /* num_in_bits length of vector in_bits */ | |
| 136 /* num_received_idle_symbols number of idle symbols received coherently */ | |
| 137 /* out_bits Vector with bits for the deinterleaver. */ | |
| 138 /* The number of the valid bits is indicated */ | |
| 139 /* by *ptr_num_valid_out_bits. */ | |
| 140 /* *ptr_num_valid_out_bits returns the number of valid output bits */ | |
| 141 /* *ptr_wait_interval returns either 0 or 32 */ | |
| 142 /* *ptr_resync_detected returns a value -1, 0,...num_in_bits */ | |
| 143 /* *ptr_early_muting_required returns whether the original audio signal */ | |
| 144 /* must not be forwarded. This is to guarantee */ | |
| 145 /* that the preamble or resync sequence is */ | |
| 146 /* detected only by the first CTM device, if */ | |
| 147 /* several CTM devices are cascaded */ | |
| 148 /* subsequently. */ | |
| 149 /* *ptr_wait_state state information. This variable must be */ | |
| 150 /* initialized with init_wait_for_sync() */ | |
| 151 /* ----------------------------------------------------------------------- */ | |
| 152 | |
| 153 #if(TTY_SYNC_MCU_2 == 0) | |
| 154 BOOL wait_for_sync(WORD16 *out_bits, | |
| 155 WORD16 *in_bits, | |
| 156 WORD16 num_in_bits, | |
| 157 WORD16 num_received_idle_symbols, | |
| 158 WORD16 *ptr_num_valid_out_bits, | |
| 159 WORD16 *ptr_wait_interval, | |
| 160 WORD16 *ptr_resync_detected, | |
| 161 BOOL *ptr_early_muting_required, | |
| 162 wait_for_sync_state_t *ptr_wait_state); | |
| 163 #else | |
| 164 BOOL wait_for_sync(WORD16 *out_bits, | |
| 165 WORD16 *in_bits, | |
| 166 WORD16 num_in_bits, | |
| 167 WORD16 num_received_idle_symbols, | |
| 168 WORD16 *ptr_num_valid_out_bits, | |
| 169 WORD16 *ptr_wait_interval, | |
| 170 WORD16 *ptr_resync_detected, | |
| 171 BOOL *ptr_early_muting_required, | |
| 172 wait_for_sync_state_t *ptr_wait_state, | |
| 173 BOOL *sync_after_resync); | |
| 174 #endif | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 /* ----------------------------------------------------------------------- */ | |
| 180 /* Function generate_resync_sequence() */ | |
| 181 /* *********************************** */ | |
| 182 /* Generation of the sequence for resynchronization. The sequence, which */ | |
| 183 /* has a length according to the value of the constant RESYNC_SEQ_LENGTH, */ | |
| 184 /* is written to the vector *sequence, which must have been allocated */ | |
| 185 /* before calling this function. */ | |
| 186 /* ----------------------------------------------------------------------- */ | |
| 187 | |
| 188 void generate_resync_sequence(WORD16 *sequence); | |
| 189 | |
| 190 | |
| 191 #endif | |
| 192 |
