Implemented selectable data rates
This commit is contained in:
parent
8d9da446a4
commit
b3fb6cc35e
|
@ -340,8 +340,16 @@ void AFSK_adc_isr(Afsk *afsk, int8_t currentSample) {
|
|||
afsk->iirX[1] = ((int8_t)fifo_pop(&afsk->delayFifo) * currentSample) >> 2;
|
||||
// The above is a simplification of:
|
||||
// afsk->iirX[1] = ((int8_t)fifo_pop(&afsk->delayFifo) * currentSample) / 2.899043379;
|
||||
#elif FILTER_CUTOFF == 1200
|
||||
afsk->iirX[1] = ((int8_t)fifo_pop(&afsk->delayFifo) * currentSample) >> 1;
|
||||
// The above is a simplification of:
|
||||
// afsk->iirX[1] = ((int8_t)fifo_pop(&afsk->delayFifo) * currentSample) / 2.228465666;
|
||||
#elif FILTER_CUTOFF == 1600
|
||||
afsk->iirX[1] = ((int8_t)fifo_pop(&afsk->delayFifo) * currentSample) >> 1;
|
||||
// The above is a simplification of:
|
||||
// afsk->iirX[1] = ((int8_t)fifo_pop(&afsk->delayFifo) * currentSample) / 1.881349100;
|
||||
#else
|
||||
#error Unsupported bitrate!
|
||||
#error Unsupported filter cutoff!
|
||||
#endif
|
||||
|
||||
afsk->iirY[0] = afsk->iirY[1];
|
||||
|
@ -354,8 +362,16 @@ void AFSK_adc_isr(Afsk *afsk, int8_t currentSample) {
|
|||
afsk->iirY[1] = afsk->iirX[0] + afsk->iirX[1] + (afsk->iirY[0] / 3);
|
||||
// The above is a simplification of a first-order 800Hz chebyshev filter:
|
||||
// afsk->iirY[1] = afsk->iirX[0] + afsk->iirX[1] + (afsk->iirY[0] * 0.3101172565);
|
||||
#elif FILTER_CUTOFF == 1200
|
||||
afsk->iirY[1] = afsk->iirX[0] + afsk->iirX[1] + (afsk->iirY[0] / 10);
|
||||
// The above is a simplification of a first-order 800Hz chebyshev filter:
|
||||
// afsk->iirY[1] = afsk->iirX[0] + afsk->iirX[1] + (afsk->iirY[0] * 0.1025215106);
|
||||
#elif FILTER_CUTOFF == 1600
|
||||
afsk->iirY[1] = afsk->iirX[0] + afsk->iirX[1] + -1*(afsk->iirY[0] / 17);
|
||||
// The above is a simplification of a first-order 800Hz chebyshev filter:
|
||||
// afsk->iirY[1] = afsk->iirX[0] + afsk->iirX[1] + (afsk->iirY[0] * -0.0630669239);
|
||||
#else
|
||||
#error Unsupported bitrate!
|
||||
#error Unsupported filter cutoff!
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -44,15 +44,20 @@ inline static uint8_t sinSample(uint16_t i) {
|
|||
#define CONFIG_AFSK_RXTIMEOUT 0
|
||||
#define CONFIG_AFSK_PREAMBLE_LEN 150UL
|
||||
#define CONFIG_AFSK_TRAILER_LEN 50UL
|
||||
#define BIT_STUFF_LEN 5
|
||||
|
||||
#define SAMPLERATE 9600
|
||||
#define BITRATE 1600
|
||||
#define BITRATE 1200
|
||||
|
||||
#define SAMPLESPERBIT (SAMPLERATE / BITRATE)
|
||||
#define PHASE_INC 1 // Nudge by an eigth of a sample each adjustment
|
||||
|
||||
#if BITRATE == 960
|
||||
#define FILTER_CUTOFF 600
|
||||
#define MARK_FREQ 1300
|
||||
#define SPACE_FREQ 2100
|
||||
#define PHASE_BITS 8 // How much to increment phase counter each sample
|
||||
#if BITRATE == 1200
|
||||
#define MARK_FREQ 960
|
||||
#define SPACE_FREQ 1600
|
||||
#define PHASE_BITS 10 // How much to increment phase counter each sample
|
||||
#elif BITRATE == 1200
|
||||
#define FILTER_CUTOFF 600
|
||||
#define MARK_FREQ 1200
|
||||
#define SPACE_FREQ 2200
|
||||
|
@ -60,15 +65,17 @@ inline static uint8_t sinSample(uint16_t i) {
|
|||
#elif BITRATE == 1600
|
||||
#define FILTER_CUTOFF 800
|
||||
#define MARK_FREQ 1600
|
||||
#define SPACE_FREQ 2800
|
||||
#define PHASE_BITS 6
|
||||
#define SPACE_FREQ 2600
|
||||
#define PHASE_BITS 8
|
||||
#elif BITRATE == 2400
|
||||
#define FILTER_CUTOFF 1600
|
||||
#define MARK_FREQ 2400
|
||||
#define SPACE_FREQ 4200
|
||||
#define PHASE_BITS 4
|
||||
#else
|
||||
#error Unsupported bitrate!
|
||||
#endif
|
||||
|
||||
#define SAMPLESPERBIT (SAMPLERATE / BITRATE)
|
||||
#define BIT_STUFF_LEN 5
|
||||
#define PHASE_INC 1 // Nudge by an eigth of a sample each adjustment
|
||||
#define PHASE_MAX (SAMPLESPERBIT * PHASE_BITS) // Resolution of our phase counter = 64
|
||||
#define PHASE_THRESHOLD (PHASE_MAX / 2) // Target transition point of our phase window
|
||||
|
||||
|
|
Loading…
Reference in New Issue