qipp
2025-09-16 e7ac407a6aa40e94a34a772dee14e8d5fb55c45b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include "drv/global.h"
#include "f2f.h"
 
 
 
static float rx_channel[PHY_NUM_INPUTS][NUM_SAMPLES];
static float tx_channel[PHY_NUM_OUTPUTS][NUM_SAMPLES];
 
 
extern int    sport0a_buf[2][NUM_SAMPLES*2];
extern int    sport0b_buf[2][NUM_SAMPLES*2];
 
extern int    sport1a_buf[2][NUM_SAMPLES*2];
extern int    sport1b_buf[2][NUM_SAMPLES*2];
 
extern int    sport2a_buf[2][NUM_SAMPLES*2];
extern int    sport2b_buf[2][NUM_SAMPLES*2];
 
extern int    sport3a_buf[2][NUM_SAMPLES*2];
extern int    sport3b_buf[2][NUM_SAMPLES*2];
 
extern int    sport4a_buf[2][NUM_SAMPLES*2];
extern int    sport4b_buf[2][NUM_SAMPLES*2];
 
extern int    sport5a_buf[2][NUM_SAMPLES*2];
extern int    sport5b_buf[2][NUM_SAMPLES*2];
 
extern int    sport6a_buf[2][NUM_SAMPLES*2];
extern int    sport6b_buf[2][NUM_SAMPLES*2];
 
extern int    sport7a_buf[2][NUM_SAMPLES*2];
extern int    sport7b_buf[2][NUM_SAMPLES*2];
 
 
float* rx_channel_ptr[]={
    rx_channel[0],rx_channel[1],rx_channel[2],rx_channel[3]
    ,rx_channel[4],rx_channel[5],rx_channel[6],rx_channel[7]
#if PHY_NUM_INPUTS>8    
    ,rx_channel[8],rx_channel[9],rx_channel[10]    ,rx_channel[11]
    ,rx_channel[12],rx_channel[13]    ,rx_channel[14]    ,rx_channel[15]
#endif
};
float* tx_channel_ptr[]={
    tx_channel[0]    ,tx_channel[1]    ,tx_channel[2]    ,tx_channel[3]
    ,tx_channel[4]    ,tx_channel[5]    ,tx_channel[6]    ,tx_channel[7]
#if PHY_NUM_INPUTS>8    
    ,tx_channel[8]    ,tx_channel[9]    ,tx_channel[10]    ,tx_channel[11]
    ,tx_channel[12]    ,tx_channel[13]    ,tx_channel[14]    ,tx_channel[15]
#endif
};
 
// Structures to hold floating point data for each AD1939
//ad1939_float_data fBlockA;
 
inline void floatData(float *output, const int *input, unsigned int instep, unsigned int length)
{
    int i;
 
    for(i = 0; i < length; i++)
    {
        output[i] = __builtin_conv_RtoF(input[instep*i]);
    }
}
 
 
// Unoptimized function to convert the outgoing floating-point data to 1.31 fixed-point format.
inline void fixData(int *output, const float *input, unsigned int outstep, unsigned int length)
{
    int i;
 
    for(i = 0; i < length; i++)
    {
        output[outstep*i] = __builtin_conv_FtoR(input[i]);
    }
}
 
 
 
 
void input_fflush(const unsigned int blockIndex)
{
    // Float ADC data from 
#ifndef DEMO_BOARD    
    floatData(get_rx_channel(4), sport1a_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(5), sport1a_buf[blockIndex]+1, 2, NUM_SAMPLES);
 
    floatData(get_rx_channel(6), sport1b_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(7), sport1b_buf[blockIndex]+1, 2, NUM_SAMPLES);
 
    floatData(get_rx_channel(0), sport3a_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(1), sport3a_buf[blockIndex]+1, 2, NUM_SAMPLES);
 
    floatData(get_rx_channel(2), sport3b_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(3), sport3b_buf[blockIndex]+1, 2, NUM_SAMPLES);
#if PHY_NUM_INPUTS>8    
    floatData(get_rx_channel(9), sport5a_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(8), sport5a_buf[blockIndex]+1, 2, NUM_SAMPLES);
 
    floatData(get_rx_channel(11), sport5b_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(10), sport5b_buf[blockIndex]+1, 2, NUM_SAMPLES);
 
    floatData(get_rx_channel(13), sport7a_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(12), sport7a_buf[blockIndex]+1, 2, NUM_SAMPLES);
 
    floatData(get_rx_channel(15), sport7b_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(14), sport7b_buf[blockIndex]+1, 2, NUM_SAMPLES);
#endif    
#else
    floatData(get_rx_channel(0), sport1a_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(1), sport1a_buf[blockIndex]+1, 2, NUM_SAMPLES);
 
    floatData(get_rx_channel(2), sport1b_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(3), sport1b_buf[blockIndex]+1, 2, NUM_SAMPLES);
 
    floatData(get_rx_channel(4), sport3a_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(5), sport3a_buf[blockIndex]+1, 2, NUM_SAMPLES);
 
    floatData(get_rx_channel(6), sport3b_buf[blockIndex]+0, 2, NUM_SAMPLES);
    floatData(get_rx_channel(7), sport3b_buf[blockIndex]+1, 2, NUM_SAMPLES);
#endif
}
 
 
 
 
void output_fflush(const unsigned int blockIndex)
{
#ifndef DEMO_BOARD    
    fixData(sport0a_buf[blockIndex]+0, get_rx_channel(1), 2, NUM_SAMPLES);
    fixData(sport0a_buf[blockIndex]+1, get_rx_channel(0), 2, NUM_SAMPLES);
 
    fixData(sport0b_buf[blockIndex]+0, get_rx_channel(3), 2, NUM_SAMPLES);
    fixData(sport0b_buf[blockIndex]+1, get_rx_channel(2), 2, NUM_SAMPLES);
 
    fixData(sport2a_buf[blockIndex]+0, get_rx_channel(5), 2, NUM_SAMPLES);
    fixData(sport2a_buf[blockIndex]+1, get_rx_channel(4), 2, NUM_SAMPLES);
 
    fixData(sport2b_buf[blockIndex]+0, get_rx_channel(7), 2, NUM_SAMPLES);
    fixData(sport2b_buf[blockIndex]+1, get_rx_channel(6), 2, NUM_SAMPLES);
#if PHY_NUM_INPUTS>8    
    fixData(sport4a_buf[blockIndex]+0, get_rx_channel(9), 2, NUM_SAMPLES);
    fixData(sport4a_buf[blockIndex]+1, get_rx_channel(8), 2, NUM_SAMPLES);
 
    fixData(sport4b_buf[blockIndex]+0, get_rx_channel(11), 2, NUM_SAMPLES);
    fixData(sport4b_buf[blockIndex]+1, get_rx_channel(10), 2, NUM_SAMPLES);
 
    fixData(sport6a_buf[blockIndex]+0, get_rx_channel(13), 2, NUM_SAMPLES);
    fixData(sport6a_buf[blockIndex]+1, get_rx_channel(12), 2, NUM_SAMPLES);
 
    fixData(sport6b_buf[blockIndex]+0, get_rx_channel(15), 2, NUM_SAMPLES);
    fixData(sport6b_buf[blockIndex]+1, get_rx_channel(14), 2, NUM_SAMPLES);
#endif
#else
    fixData(sport0a_buf[blockIndex]+0, get_rx_channel(0), 2, NUM_SAMPLES);
    fixData(sport0a_buf[blockIndex]+1, get_rx_channel(1), 2, NUM_SAMPLES);
 
    fixData(sport0b_buf[blockIndex]+0, get_rx_channel(2), 2, NUM_SAMPLES);
    fixData(sport0b_buf[blockIndex]+1, get_rx_channel(3), 2, NUM_SAMPLES);
 
    fixData(sport2a_buf[blockIndex]+0, get_rx_channel(4), 2, NUM_SAMPLES);
    fixData(sport2a_buf[blockIndex]+1, get_rx_channel(5), 2, NUM_SAMPLES);
 
    fixData(sport2b_buf[blockIndex]+0, get_rx_channel(6), 2, NUM_SAMPLES);
    fixData(sport2b_buf[blockIndex]+1, get_rx_channel(7), 2, NUM_SAMPLES);
#endif
}