mirror of
https://github.com/markqvist/OpenModem.git
synced 2024-12-27 16:39:45 -05:00
300 baud demodulator implemented
This commit is contained in:
parent
7f5fe36cc2
commit
00dcf5a300
@ -46,10 +46,10 @@ inline static uint8_t sinSample(uint16_t i) {
|
|||||||
#define CONFIG_AFSK_TRAILER_LEN 25UL
|
#define CONFIG_AFSK_TRAILER_LEN 25UL
|
||||||
#define BIT_STUFF_LEN 5
|
#define BIT_STUFF_LEN 5
|
||||||
|
|
||||||
#define BITRATE 300
|
#define BITRATE 1200
|
||||||
|
|
||||||
#if BITRATE == 300
|
#if BITRATE == 300
|
||||||
#define CONFIG_ADC_SAMPLERATE 4800UL
|
#define CONFIG_ADC_SAMPLERATE 9600UL
|
||||||
#define CONFIG_DAC_SAMPLERATE 19200UL
|
#define CONFIG_DAC_SAMPLERATE 19200UL
|
||||||
#elif BITRATE == 1200
|
#elif BITRATE == 1200
|
||||||
#define CONFIG_ADC_SAMPLERATE 9600UL
|
#define CONFIG_ADC_SAMPLERATE 9600UL
|
||||||
@ -78,8 +78,14 @@ inline static uint8_t sinSample(uint16_t i) {
|
|||||||
#define SIGNAL_TRANSITIONED(bits) DUAL_XOR((bits), (bits) >> 2)
|
#define SIGNAL_TRANSITIONED(bits) DUAL_XOR((bits), (bits) >> 2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: Calculate based on sample rate [Done?]
|
#if BITRATE == 300
|
||||||
#define PHASE_BITS 8 // Sub-sample phase counter resolution
|
// TODO: Real-world tests on which resolution is best
|
||||||
|
//#define PHASE_BITS 8
|
||||||
|
#define PHASE_BITS 4
|
||||||
|
#else
|
||||||
|
#define PHASE_BITS 8 // Sub-sample phase counter resolution
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PHASE_INC 1 // Nudge by above resolution for each adjustment
|
#define PHASE_INC 1 // Nudge by above resolution for each adjustment
|
||||||
|
|
||||||
#define PHASE_MAX (ADC_SAMPLESPERBIT * PHASE_BITS) // Size of our phase counter
|
#define PHASE_MAX (ADC_SAMPLESPERBIT * PHASE_BITS) // Size of our phase counter
|
||||||
@ -98,9 +104,16 @@ inline static uint8_t sinSample(uint16_t i) {
|
|||||||
#define PHASE_THRESHOLD (PHASE_MAX / 2) // Target transition point of our phase window
|
#define PHASE_THRESHOLD (PHASE_MAX / 2) // Target transition point of our phase window
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if BITRATE == 300
|
||||||
#define DCD_TIMEOUT_SAMPLES CONFIG_ADC_SAMPLERATE/100
|
#define DCD_TIMEOUT_SAMPLES 520
|
||||||
#define DCD_MIN_COUNT CONFIG_ADC_SAMPLERATE/1600
|
#define DCD_MIN_COUNT 2
|
||||||
|
#elif BITRATE == 1200
|
||||||
|
#define DCD_TIMEOUT_SAMPLES CONFIG_ADC_SAMPLERATE/100
|
||||||
|
#define DCD_MIN_COUNT CONFIG_ADC_SAMPLERATE/1600
|
||||||
|
#elif BITRATE == 2400
|
||||||
|
#define DCD_TIMEOUT_SAMPLES CONFIG_ADC_SAMPLERATE/100
|
||||||
|
#define DCD_MIN_COUNT CONFIG_ADC_SAMPLERATE/1600
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: Revamp filtering
|
// TODO: Revamp filtering
|
||||||
#if BITRATE == 1200
|
#if BITRATE == 1200
|
||||||
@ -116,7 +129,7 @@ inline static uint8_t sinSample(uint16_t i) {
|
|||||||
//#define MARK_FREQ 2200
|
//#define MARK_FREQ 2200
|
||||||
//#define SPACE_FREQ 4000
|
//#define SPACE_FREQ 4000
|
||||||
#elif BITRATE == 300
|
#elif BITRATE == 300
|
||||||
#define FILTER_CUTOFF 600
|
#define FILTER_CUTOFF 500
|
||||||
#define MARK_FREQ 1600
|
#define MARK_FREQ 1600
|
||||||
#define SPACE_FREQ 1800
|
#define SPACE_FREQ 1800
|
||||||
#else
|
#else
|
||||||
@ -154,7 +167,7 @@ typedef struct Afsk
|
|||||||
uint16_t phaseAcc; // Phase accumulator
|
uint16_t phaseAcc; // Phase accumulator
|
||||||
uint16_t phaseInc; // Phase increment per sample
|
uint16_t phaseInc; // Phase increment per sample
|
||||||
|
|
||||||
uint8_t silentSamples; // How many samples were completely silent
|
uint16_t silentSamples; // How many samples were completely silent
|
||||||
|
|
||||||
FIFOBuffer txFifo; // FIFO for transmit data
|
FIFOBuffer txFifo; // FIFO for transmit data
|
||||||
uint8_t txBuf[CONFIG_AFSK_TX_BUFLEN]; // Actual data storage for said FIFO
|
uint8_t txBuf[CONFIG_AFSK_TX_BUFLEN]; // Actual data storage for said FIFO
|
||||||
@ -169,7 +182,7 @@ typedef struct Afsk
|
|||||||
#elif BITRATE == 2400
|
#elif BITRATE == 2400
|
||||||
int8_t delayBuf[7 + 1];
|
int8_t delayBuf[7 + 1];
|
||||||
#elif BITRATE == 300
|
#elif BITRATE == 300
|
||||||
int8_t delayBuf[ADC_SAMPLESPERBIT / 2 + 1];
|
int8_t delayBuf[16 + 1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FIFOBuffer rxFifo; // FIFO for received data
|
FIFOBuffer rxFifo; // FIFO for received data
|
||||||
@ -180,6 +193,8 @@ typedef struct Afsk
|
|||||||
|
|
||||||
#if ADC_SAMPLESPERBIT < 17
|
#if ADC_SAMPLESPERBIT < 17
|
||||||
uint16_t sampledBits; // Bits sampled by the demodulator (at ADC speed)
|
uint16_t sampledBits; // Bits sampled by the demodulator (at ADC speed)
|
||||||
|
#elif ADC_SAMPLESPERBIT < 33
|
||||||
|
uint32_t sampledBits;
|
||||||
#else
|
#else
|
||||||
#error Not enough space in sampledBits variable!
|
#error Not enough space in sampledBits variable!
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,10 +28,10 @@ void kiss_init(AX25Ctx *ax25, Afsk *afsk, Serial *ser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove debug functions
|
// TODO: Remove debug functions
|
||||||
// size_t decodes = 0;
|
//size_t decodes = 0;
|
||||||
void kiss_messageCallback(AX25Ctx *ctx) {
|
void kiss_messageCallback(AX25Ctx *ctx) {
|
||||||
// decodes++;
|
//decodes++;
|
||||||
// printf("%d\r\n", decodes);
|
//printf("%d\r\n", decodes);
|
||||||
|
|
||||||
fputc(FEND, &serial->uart0);
|
fputc(FEND, &serial->uart0);
|
||||||
fputc(0x00, &serial->uart0);
|
fputc(0x00, &serial->uart0);
|
||||||
@ -48,6 +48,7 @@ void kiss_messageCallback(AX25Ctx *ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fputc(FEND, &serial->uart0);
|
fputc(FEND, &serial->uart0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void kiss_csma(AX25Ctx *ctx, uint8_t *buf, size_t len) {
|
void kiss_csma(AX25Ctx *ctx, uint8_t *buf, size_t len) {
|
||||||
|
Loading…
Reference in New Issue
Block a user