kopia lustrzana https://github.com/kamocat/uSDX
Working on audio out
rodzic
37a4078b5f
commit
45b914dbb8
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* hilbert.c
|
||||||
|
*
|
||||||
|
* Created on: Jul 9, 2020
|
||||||
|
* Author: marshal
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
int16_t hilbert19(int16_t * src){
|
||||||
|
const size_t M = 19/2;
|
||||||
|
const int32_t coef[M/2+1];
|
||||||
|
int32_t sum;
|
||||||
|
sum = (src[M-1]-src[M+1]) * coef[0];
|
||||||
|
sum += (src[M-3]-src[M+3]) * coef[1];
|
||||||
|
sum += (src[M-5]-src[M+5]) * coef[2];
|
||||||
|
sum += (src[M-7]-src[M+7]) * coef[3];
|
||||||
|
sum += (src[M-9]-src[M+9]) * coef[4];
|
||||||
|
return sum>>16;
|
||||||
|
}
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rx.h"
|
#include "rx.h"
|
||||||
|
#include "ssb.h"
|
||||||
|
|
||||||
/** Mailbox for received data */
|
/** Mailbox for received data */
|
||||||
mailbox_t new_sample;
|
mailbox_t new_sample;
|
||||||
|
@ -22,7 +23,11 @@ THD_FUNCTION(radio_rx, arg){
|
||||||
data[i++] = c.real;
|
data[i++] = c.real;
|
||||||
data[i++] = c.imag;
|
data[i++] = c.imag;
|
||||||
}
|
}
|
||||||
/** Here would be a good place to do a FFT or other processing */
|
/** Process the received data */
|
||||||
|
int16_t out[len];
|
||||||
|
ssb(out, data, len);
|
||||||
|
/** Fill buffer for audio out */
|
||||||
|
speaker_update(out, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,3 +116,28 @@ void adc_rx_init(void){
|
||||||
adcStartConversion(&ADCD1, &qsd_in, samples, len);
|
adcStartConversion(&ADCD1, &qsd_in, samples, len);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Copies audio data to PWM
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void speaker_callback(PWMDriver * pwmp){
|
||||||
|
//FIXME: Copy data into DMA buffer. Or interrupt every period.
|
||||||
|
}
|
||||||
|
|
||||||
|
static PWMConfig spkr = {
|
||||||
|
4096000, /* 4MHz PWM clock frequency. */
|
||||||
|
4096, /* Initial PWM period 1ms. */
|
||||||
|
speaker_callback,
|
||||||
|
{
|
||||||
|
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
|
||||||
|
{PWM_OUTPUT_DISABLED, NULL},
|
||||||
|
{PWM_OUTPUT_DISABLED, NULL},
|
||||||
|
{PWM_OUTPUT_DISABLED, NULL}
|
||||||
|
},
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
void speaker_init(void){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,19 @@
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
|
|
||||||
|
/** Starts radio reception and demodulation
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void rxStart(uint8_t mode);
|
||||||
|
|
||||||
|
/* Pauses radio reception and demodulation
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void rxStop(void);
|
||||||
|
|
||||||
|
/** Handles the radio reception
|
||||||
|
*
|
||||||
|
*/
|
||||||
THD_FUNCTION(radio_rx, arg);
|
THD_FUNCTION(radio_rx, arg);
|
||||||
|
|
||||||
/** Datatype for complex numbers
|
/** Datatype for complex numbers
|
||||||
|
@ -25,8 +38,28 @@ union complex{
|
||||||
msg_t msg;
|
msg_t msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Radio RX thread
|
||||||
|
*
|
||||||
|
* This thread handles the data received from the ADC callback.
|
||||||
|
* It calls the specific radio protocol being run (CW, SSB, etc)
|
||||||
|
*/
|
||||||
|
THD_FUNCTION(radio_rx, arg);
|
||||||
|
|
||||||
|
/** ADC streaming callback.
|
||||||
|
*
|
||||||
|
* Performs initial low-pass filter and downsamples to 5kHz
|
||||||
|
* Passes data to the Radio RX thread
|
||||||
|
*/
|
||||||
|
static void adccallback(ADCDriver *adcp);
|
||||||
|
|
||||||
/** ADC init
|
/** ADC init
|
||||||
|
*
|
||||||
|
* Configures the ADC for radio reception
|
||||||
*/
|
*/
|
||||||
void adc_rx_init(void);
|
void adc_rx_init(void);
|
||||||
|
|
||||||
|
void speaker_init(void);
|
||||||
|
|
||||||
|
void speaker_update(int16_t data, int len);
|
||||||
|
|
||||||
#endif /* RX_H_ */
|
#endif /* RX_H_ */
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* ssb.c
|
||||||
|
*
|
||||||
|
* Created on: Jul 9, 2020
|
||||||
|
* Author: marshal
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "ssb.h"
|
||||||
|
|
||||||
|
void ssb_rx(int16_t * dest, int16_t * src, size_t qty){
|
||||||
|
// Source data is interlieved In-phase / Quadrature phase
|
||||||
|
// Destination is single-channel
|
||||||
|
for(int i = 0; i < qty; ++i){
|
||||||
|
*dest++ = *src++ + *src++; // Return the sum of I and Q
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ssb_tx(int16_t * amp, int32_t * freq, int16_t * src, size_t qty){
|
||||||
|
// Source data is single-channel audio
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* ssb.h
|
||||||
|
*
|
||||||
|
* Created on: Jul 9, 2020
|
||||||
|
* Author: marshal
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Single sideband decoder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void ssb_rx(int16_t * dest, int16_t * src, size_t qty);
|
||||||
|
|
||||||
|
/** Singgle sideband encoder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void ssb_tx(int16_t * amp, int32_t * freq, int16_t * src, size_t qty);
|
Ładowanie…
Reference in New Issue