-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCW_Excite.cpp
More file actions
117 lines (96 loc) · 4.58 KB
/
CW_Excite.cpp
File metadata and controls
117 lines (96 loc) · 4.58 KB
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
#ifndef BEENHERE
#include "SDT.h"
#endif
//===================== file all new AFP 09-01-22
/*****
Purpose: to send a Morse code dit
Parameter list:
void
Return value:
void
*****/
void KeyTipOn()
{
if (digitalRead(KEYER_DIT_INPUT_TIP) == LOW && xmtMode == CW_MODE ) {
keyPressedOn = 1;
}
}
/*****
Purpose: CW Key interrupt //AFP 09-01-22
Parameter list:
Return value;
voidKeyRingOn(
*****/
void KeyRingOn() //AFP 09-25-22
{
if (keyType == 1) {
if (digitalRead(KEYER_DAH_INPUT_RING) == LOW && xmtMode == CW_MODE ) {
keyPressedOn = 1;
}
}
}
/*****
Purpose: Create I and Q signals from Mic input
Parameter list:
Return value;
void
Notes:
There are several actions in this function
1. Read in the data from the ADC into the Left Channel at 192KHz
2. Format the L data and Decimate (downsample and filter)the sampled data by x8
- the new effective sampling rate is now 24KHz
3. Process the L data through the 7 EQ filters and combine to a single data stream
4. Copy the L channel to the R channel
5. Process the R and L through two Hilbert Transformers - L 0deg phase shift and R 90 deg ph shift
- This create the I (L) and Q(R) channels
6. Interpolate 8x (upsample and filter) the data stream to 192KHz sample rate
7. Output the data stream thruogh the DACs at 192KHz
*****/
void CW_ExciterIQData() //AFP 08-20-22
{
uint32_t N_BLOCKS_EX = N_B_EX;
arm_scale_f32 (cosBuffer2, 0.127, float_buffer_L_EX, 256); // AFP 10-13-22 Use pre-calculated sin & cos instead of Hilbert
arm_scale_f32 (sinBuffer2, 0.127, float_buffer_R_EX, 256); // AFP 10-13-22
/**********************************************************************************
Additional scaling, if nesessary to compensate for down-stream gain variations
**********************************************************************************/
#ifdef G0ORX_AUDIO_DISPLAY
arm_copy_f32 (float_buffer_L_EX, mic_audio_buffer, 256);
#endif
//============================== AFP 10-21-22 Begin new
if (bands[currentBand].mode == DEMOD_LSB) {
//arm_scale_f32 (float_buffer_L_EX, IQXAmpCorrectionFactor[currentBandA], float_buffer_L_EX, 256); //Adjust level of L buffer
arm_scale_f32(float_buffer_L_EX, -IQXAmpCorrectionFactor[currentBand], float_buffer_L_EX, 256); //Adjust level of L buffer KF5N flipped sign, original was +
IQPhaseCorrection(float_buffer_L_EX, float_buffer_R_EX, IQXPhaseCorrectionFactor[currentBand], 256); // Adjust phase
} else {
if (bands[currentBand].mode == DEMOD_USB) {
//arm_scale_f32 (float_buffer_L_EX, -IQXAmpCorrectionFactor[currentBandA], float_buffer_L_EX, 256);
arm_scale_f32 (float_buffer_L_EX, + IQXAmpCorrectionFactor[currentBand], float_buffer_L_EX, 256); // KF5N flipped sign, original was minus
IQPhaseCorrection(float_buffer_L_EX, float_buffer_R_EX, IQXPhaseCorrectionFactor[currentBand], 256);
}
}
/**********************************************************************************
Interpolate (upsample the data streams by 8X to create the 192KHx sample rate for output
Requires a LPF FIR 48 tap 10KHz and 8KHz
**********************************************************************************/
//24KHz effective sample rate here
arm_fir_interpolate_f32(&FIR_int1_EX_I, float_buffer_L_EX, float_buffer_LTemp, 256);
arm_fir_interpolate_f32(&FIR_int1_EX_Q, float_buffer_R_EX, float_buffer_RTemp, 256);
// interpolation-by-4, 48KHz effective sample rate here
arm_fir_interpolate_f32(&FIR_int2_EX_I, float_buffer_LTemp, float_buffer_L_EX, 512);
arm_fir_interpolate_f32(&FIR_int2_EX_Q, float_buffer_RTemp, float_buffer_R_EX, 512);
// 192KHz effective sample rate here
arm_scale_f32(float_buffer_L_EX, 20, float_buffer_L_EX, 2048); //Scale to compensate for losses in Interpolation
arm_scale_f32(float_buffer_R_EX, 20, float_buffer_R_EX, 2048);
/********************************************************************************** AFP 12-31-20
CONVERT TO INTEGER AND PLAY AUDIO
**********************************************************************************/
for (unsigned i = 0; i < N_BLOCKS_EX; i++) { //N_BLOCKS_EX=16 BUFFER_SIZE=128 16x128=2048
sp_L2 = Q_out_L_Ex.getBuffer();
sp_R2 = Q_out_R_Ex.getBuffer();
arm_float_to_q15 (&float_buffer_L_EX[BUFFER_SIZE * i], sp_L2, BUFFER_SIZE);
arm_float_to_q15 (&float_buffer_R_EX[BUFFER_SIZE * i], sp_R2, BUFFER_SIZE);
Q_out_L_Ex.playBuffer(); // play it !
Q_out_R_Ex.playBuffer(); // play it !
}
}