Clean up typedefs

This commit is contained in:
Christian W. Zuckschwerdt 2019-02-16 11:08:37 +00:00
parent 7c6bf6515d
commit 22370cac20
7 changed files with 36 additions and 31 deletions

View file

@ -16,7 +16,7 @@
#define PULSE_DATA_SIZE 4000 /* maximum number of pulses */ #define PULSE_DATA_SIZE 4000 /* maximum number of pulses */
typedef struct { typedef struct am_analyze {
int32_t *level_limit; int32_t *level_limit;
int override_short; int override_short;
int override_long; int override_long;

View file

@ -34,39 +34,39 @@ void magnitude_true_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len);
#define FILTER_ORDER 1 #define FILTER_ORDER 1
/// Filter state buffer. /// Filter state buffer.
typedef struct { typedef struct filter_state {
int16_t y[FILTER_ORDER]; int16_t y[FILTER_ORDER];
int16_t x[FILTER_ORDER]; int16_t x[FILTER_ORDER];
} FilterState; } filter_state_t;
/// FM_Demod state buffer. /// FM_Demod state buffer.
typedef struct { typedef struct demodfm_state {
int32_t br, bi; // Last I/Q sample int32_t br, bi; // Last I/Q sample
int32_t xlp, ylp; // Low-pass filter state int32_t xlp, ylp; // Low-pass filter state
} DemodFM_State; } demodfm_state_t;
/** Lowpass filter. /** Lowpass filter.
Function is stateful Function is stateful
@param *x_buf: input samples to be filtered @param x_buf: input samples to be filtered
@param *y_buf: output from filter @param[out] y_buf: output from filter
@param len: number of samples to process @param len: number of samples to process
@param FilterState: State to store between chunk processing @param[in,out] state: State to store between chunk processing
*/ */
void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, FilterState *state); void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, filter_state_t *state);
/** FM demodulator. /** FM demodulator.
Function is stateful Function is stateful
@param *x_buf: input samples (I/Q samples in interleaved uint8) @param x_buf: input samples (I/Q samples in interleaved uint8)
@param *y_buf: output from FM demodulator @param[out] y_buf: output from FM demodulator
@param len: number of samples to process @param len: number of samples to process
@param DemodFM_State: State to store between chunk processing @param[in,out] state: State to store between chunk processing
*/ */
void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state); void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state);
/// For evaluation. /// For evaluation.
void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state); void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state);
/** Initialize tables and constants. /** Initialize tables and constants.
Should be called once at startup. Should be called once at startup.

View file

@ -25,7 +25,7 @@
#define PD_MAX_PULSE_MS 100 // Pulse width in ms to exceed to declare End Of Package (e.g. for non OOK packages) #define PD_MAX_PULSE_MS 100 // Pulse width in ms to exceed to declare End Of Package (e.g. for non OOK packages)
/// Data for a compact representation of generic pulse train. /// Data for a compact representation of generic pulse train.
typedef struct { typedef struct pulse_data {
uint64_t offset; ///< Offset to first pulse in number of samples from start of stream. uint64_t offset; ///< Offset to first pulse in number of samples from start of stream.
uint32_t sample_rate; ///< Sample rate the pulses are recorded with. uint32_t sample_rate; ///< Sample rate the pulses are recorded with.
unsigned start_ago; ///< Start of first pulse in number of samples ago. unsigned start_ago; ///< Start of first pulse in number of samples ago.

View file

@ -14,7 +14,7 @@
#include <stdint.h> #include <stdint.h>
typedef struct { typedef struct samp_grab {
uint32_t *frequency; uint32_t *frequency;
uint32_t *samp_rate; uint32_t *samp_rate;
int *sample_size; int *sample_size;

View file

@ -120,7 +120,7 @@ void magnitude_true_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len)
but the b coeffs are small so it wont happen but the b coeffs are small so it wont happen
Q15.14>>14 = Q15.0 \o/ Q15.14>>14 = Q15.0 \o/
*/ */
void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, FilterState *state) void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, filter_state_t *state)
{ {
/// [b,a] = butter(1, 0.01) -> 3x tau (95%) ~100 samples /// [b,a] = butter(1, 0.01) -> 3x tau (95%) ~100 samples
//static int const a[FILTER_ORDER + 1] = {FIX(1.00000), FIX(0.96907)}; //static int const a[FILTER_ORDER + 1] = {FIX(1.00000), FIX(0.96907)};
@ -175,7 +175,7 @@ int16_t atan2_int16(int16_t y, int16_t x)
return angle; return angle;
} }
void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state) void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state)
{ {
/// [b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples /// [b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples
//static int const alp[2] = {FIX(1.00000), FIX(0.72654)}; //static int const alp[2] = {FIX(1.00000), FIX(0.72654)};
@ -246,7 +246,7 @@ int32_t atan2_int32(int32_t y, int32_t x)
} }
/// for evaluation. /// for evaluation.
void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state) void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state)
{ {
/// [b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples /// [b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples
//static int const alp[2] = {FIX32(1.00000), FIX32(0.72654)}; //static int const alp[2] = {FIX32(1.00000), FIX32(0.72654)};

View file

@ -71,6 +71,18 @@
#define VERSION "version unknown" #define VERSION "version unknown"
#endif #endif
char const *version_string(void)
{
return "rtl_433 " VERSION " inputs file rtl_tcp"
#ifdef RTLSDR
" RTL-SDR"
#endif
#ifdef SOAPYSDR
" SoapySDR"
#endif
;
}
r_device *flex_create_device(char *spec); // maybe put this in some header file? r_device *flex_create_device(char *spec); // maybe put this in some header file?
void data_acquired_handler(r_device *r_dev, data_t *data); void data_acquired_handler(r_device *r_dev, data_t *data);
@ -87,8 +99,8 @@ struct dm_state {
float f32_buf[MAXIMAL_BUF_LENGTH]; // format conversion buffer float f32_buf[MAXIMAL_BUF_LENGTH]; // format conversion buffer
int sample_size; // CU8: 1, CS16: 2 int sample_size; // CU8: 1, CS16: 2
pulse_detect_t *pulse_detect; pulse_detect_t *pulse_detect;
FilterState lowpass_filter_state; filter_state_t lowpass_filter_state;
DemodFM_State demod_FM_state; demodfm_state_t demod_FM_state;
int enable_FM_demod; int enable_FM_demod;
samp_grab_t *samp_grab; samp_grab_t *samp_grab;
am_analyze_t *am_analyze; am_analyze_t *am_analyze;
@ -111,14 +123,7 @@ struct dm_state {
static void print_version(void) static void print_version(void)
{ {
fprintf(stderr, "rtl_433 " VERSION " inputs file rtl_tcp" fprintf(stderr, "%s\n", version_string());
#ifdef RTLSDR
" RTL-SDR"
#endif
#ifdef SOAPYSDR
" SoapySDR"
#endif
"\n");
} }
static void usage(r_device *devices, unsigned num_devices, int exit_code) static void usage(r_device *devices, unsigned num_devices, int exit_code)

View file

@ -85,8 +85,8 @@ int main(int argc, char *argv[])
long n_read; long n_read;
unsigned long n_samples; unsigned long n_samples;
int max_block_size = 4096000; int max_block_size = 4096000;
FilterState state; filter_state_t state;
DemodFM_State fm_state; demodfm_state_t fm_state;
if (argc <= 1) { if (argc <= 1) {
return 1; return 1;