Skip to content

Commit

Permalink
Use new style library
Browse files Browse the repository at this point in the history
  • Loading branch information
srsampson committed Feb 22, 2019
1 parent 072eb54 commit 8d590ac
Show file tree
Hide file tree
Showing 38 changed files with 794 additions and 1,050 deletions.
Empty file modified 2fsk.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified 2fsk.raw
100755 → 100644
Empty file.
Empty file modified 4fsk.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified 4fsk.raw
100755 → 100644
Empty file.
Empty file modified LICENSE
100755 → 100644
Empty file.
Empty file modified README.md
100755 → 100644
Empty file.
Empty file modified bin-test.c
100755 → 100644
Empty file.
Empty file modified crc-scrambler-interleaver-test.c
100755 → 100644
Empty file.
Binary file modified export-mfsk.zip
100755 → 100644
Binary file not shown.
33 changes: 3 additions & 30 deletions header/demodulator.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,9 @@ extern "C" {

#include <stdint.h>
#include <complex.h>

#ifndef M_PI
#define M_PI 3.14159265358979f
#endif

#define TAU (2.0f * M_PI)

#define MODE_2FSK 2
#define MODE_4FSK 4
#define MAX_TONES 4
#define FFT_SIZE 1024
#define FSK_SCALE 16383

int fsk_create(int, int, int, int);
int fsk_create_hbr(int, int, int, int, int, int);
void fsk_destroy(void);
void fsk_demod(uint8_t [], complex float []);
void fsk_demod_sd(float [], complex float []);

/* Getters/Setters */

int fsk_get_nin(void);
int fsk_get_N(void);
int fsk_get_Nmem(void);
int fsk_get_Nbits(void);
int fsk_get_Ts(void);
float fsk_get_f_est(int);
void fsk_set_nsym(int);
void fsk_set_est_limits(int, int);
void fsk_set_estimators(void);

void fsk_demod(struct FSK *, uint8_t [], complex float []);
void fsk_demod_sd(struct FSK *, float [], complex float []);

#ifdef __cplusplus
}
Expand Down
Empty file modified header/fft.h
100755 → 100644
Empty file.
92 changes: 92 additions & 0 deletions header/fsk.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (C) January 2016 David Rowe, Brady O'Brien
*
* All rights reserved.
*
* Modified by Steve Sampson for C99 complex math
*
* Licensed under GNU LGPL V2.1
* See LICENSE file for information
*/

#ifndef FSK_H
#define FSK_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stdbool.h>
#include <complex.h>

#include "fft.h"
#include "statistics.h"

#define MODE_2FSK 2
#define MODE_4FSK 4
#define MAX_TONES 4
#define FFT_SIZE 1024
#define FSK_SCALE 16383

#define OVERSAMPLE_RATE 8
#define MIN_FREQUENCY 300
#define MAX_FREQUENCY 2200
#define MIN_SPACING 100

#define cmplx(value) (cosf(value) + sinf(value) * I)
#define cmplxconj(value) (cosf(value) + sinf(value) * -I)

struct FSK {
struct STATS *stats;
complex float phase[MAX_TONES];
float f_est[MAX_TONES];
float norm_rx_timing;
float EbNodB;
float ppm;
int Ndft;
int Fs;
int N;
int Rs;
int Ts;
int Nmem;
int P;
int Nsym;
int Nbits;
int f1;
int shift;
int mode;
int est_min;
int est_max;
int est_space;
int nstash;
int nin;
bool burst_mode;
fft_cfg fftcfg;
float *hann_table;
float *fft_est;
complex float *samp_old;
};

struct FSK *fsk_create(int, int, int, int);
struct FSK *fsk_create_hbr(int, int, int, int, int, int);
void fsk_destroy(struct FSK *);

/* Getters/Setters */

int fsk_get_nin(struct FSK *);
int fsk_get_N(struct FSK *);
int fsk_get_Nmem(struct FSK *);
int fsk_get_Nbits(struct FSK *);
int fsk_get_Ts(struct FSK *);
float fsk_get_f_est(struct FSK *, int);
void fsk_set_nsym(struct FSK *, int);
void fsk_set_est_limits(struct FSK *, int, int);
void fsk_set_estimators(struct FSK *);

#ifdef __cplusplus
}
#endif

#endif /* FSK_H */

23 changes: 18 additions & 5 deletions header/modulator.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@ extern "C" {
#endif

#include <complex.h>

int mod_create(int, int, int, int, int);
void mod_destroy(void);
void modulate(complex float [], int);
void manchester_modulate(complex float [], int);

#include "fsk.h"

struct MODULATE {
complex float oscillator[MAX_TONES];
complex float phase;
float fs;
float rs;
float f1;
float shift;
int mode;
int cycles;
};

struct MODULATE *mod_create(int, int, int, int, int);
void mod_destroy(struct MODULATE *);
void modulate(struct MODULATE *, complex float [], int);
void manchester_modulate(struct MODULATE *, complex float [], int);

#ifdef __cplusplus
}
Expand Down
45 changes: 26 additions & 19 deletions header/statistics.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,37 @@ extern "C" {

#include <complex.h>

#include "modulator.h"
#include "demodulator.h"
#include "fsk.h"
#include "fft.h"

#define STATS_FFTSIZE 1024
#define ASCALE ((STATS_FFTSIZE / 2) * 1000)

int stats_open(void);
void stats_close(void);
void stats_spectrum(float [], complex float [], int);

float stats_get_snr_est(void);
float stats_get_foff(void);
float stats_get_rx_timing(void);
float stats_get_clock_offset(void);
float stats_get_f_est(int);

float *stats_get_fft_buf_ptr(void);

void stats_set_snr_est(float);
void stats_set_foff(float);
void stats_set_rx_timing(float);
void stats_set_clock_offset(float);
void stats_set_f_est(int, float);
struct STATS {
fft_cfg fftcfg;
float snr_est; /* estimated SNR of rx signal in dB (3 kHz noise BW) */
float foff; /* estimated freq offset in Hz */
float rx_timing; /* estimated optimum timing offset in samples */
float clock_offset; /* Estimated tx/rx sample clock offset in ppm */
float scale_dB;
float fftbuffer[STATS_FFTSIZE];
};

struct STATS *stats_open(void);
void stats_close(struct STATS *);
void stats_spectrum(struct STATS *, float [], complex float [], int);

float stats_get_snr_est(struct STATS *);
float stats_get_foff(struct STATS *);
float stats_get_rx_timing(struct STATS *);
float stats_get_clock_offset(struct STATS *);

float *stats_get_fft_buf_ptr(struct STATS *);

void stats_set_snr_est(struct STATS *, float);
void stats_set_foff(struct STATS *, float);
void stats_set_rx_timing(struct STATS *, float);
void stats_set_clock_offset(struct STATS *, float);

#ifdef __cplusplus
}
Expand Down
Binary file modified horus/api/export-horus_api.zip
100755 → 100644
Binary file not shown.
57 changes: 0 additions & 57 deletions horus/api/header/demodulator.h

This file was deleted.

Empty file modified horus/api/header/golay23.h
100755 → 100644
Empty file.
Empty file modified horus/api/header/golaydectable.h
100755 → 100644
Empty file.
Empty file modified horus/api/header/golayenctable.h
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion horus/api/header/horus_api.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int horus_get_max_packet_len(void);
/**
* In-Place Algebraic Golden Prime Interleaver
*
* inout - The data to be operated on
* inout - The byte data to be operated on
* nbytes - The number of data bytes in the input/output
* dir - Direction is 0 to Interleave and 1 to De-Interleave
*/
Expand Down
28 changes: 0 additions & 28 deletions horus/api/header/modulator.h

This file was deleted.

46 changes: 0 additions & 46 deletions horus/api/header/statistics.h

This file was deleted.

Binary file modified horus/api/libhorus_api.so
100755 → 100644
Binary file not shown.
Empty file modified horus/api/src/golay23.c
100755 → 100644
Empty file.
Loading

0 comments on commit 8d590ac

Please sign in to comment.