Improved data carrier detection
This commit is contained in:
parent
145b1154f9
commit
01c629a6fd
2
device.h
2
device.h
|
@ -9,7 +9,7 @@
|
||||||
#define FREQUENCY_CORRECTION 0
|
#define FREQUENCY_CORRECTION 0
|
||||||
|
|
||||||
// ADC settings
|
// ADC settings
|
||||||
#define OPEN_SQUELCH false
|
#define OPEN_SQUELCH true
|
||||||
#define ADC_REFERENCE REF_3V3
|
#define ADC_REFERENCE REF_3V3
|
||||||
// OR
|
// OR
|
||||||
//#define ADC_REFERENCE REF_5V
|
//#define ADC_REFERENCE REF_5V
|
||||||
|
|
|
@ -205,6 +205,14 @@ static bool hdlcParse(Hdlc *hdlc, bool bit, FIFOBuffer *fifo) {
|
||||||
// on the RX LED.
|
// on the RX LED.
|
||||||
fifo_push(fifo, HDLC_FLAG);
|
fifo_push(fifo, HDLC_FLAG);
|
||||||
hdlc->receiving = true;
|
hdlc->receiving = true;
|
||||||
|
|
||||||
|
if (hdlc->dcd_count < DCD_MIN_COUNT) {
|
||||||
|
hdlc->dcd = false;
|
||||||
|
hdlc->dcd_count++;
|
||||||
|
} else {
|
||||||
|
hdlc->dcd = true;
|
||||||
|
}
|
||||||
|
|
||||||
#if OPEN_SQUELCH == false
|
#if OPEN_SQUELCH == false
|
||||||
LED_RX_ON();
|
LED_RX_ON();
|
||||||
#endif
|
#endif
|
||||||
|
@ -215,7 +223,8 @@ static bool hdlcParse(Hdlc *hdlc, bool bit, FIFOBuffer *fifo) {
|
||||||
|
|
||||||
ret = false;
|
ret = false;
|
||||||
hdlc->receiving = false;
|
hdlc->receiving = false;
|
||||||
LED_RX_OFF();
|
hdlc->dcd = false;
|
||||||
|
hdlc->dcd_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everytime we receive a HDLC_FLAG, we reset the
|
// Everytime we receive a HDLC_FLAG, we reset the
|
||||||
|
@ -239,10 +248,18 @@ static bool hdlcParse(Hdlc *hdlc, bool bit, FIFOBuffer *fifo) {
|
||||||
// If we have, something probably went wrong at the
|
// If we have, something probably went wrong at the
|
||||||
// transmitting end, and we abort the reception.
|
// transmitting end, and we abort the reception.
|
||||||
hdlc->receiving = false;
|
hdlc->receiving = false;
|
||||||
LED_RX_OFF();
|
hdlc->dcd = false;
|
||||||
|
hdlc->dcd_count = 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check the DCD status and set RX LED appropriately
|
||||||
|
if (hdlc->dcd) {
|
||||||
|
LED_RX_ON();
|
||||||
|
} else {
|
||||||
|
LED_RX_OFF();
|
||||||
|
}
|
||||||
|
|
||||||
// If we have not yet seen a HDLC_FLAG indicating that
|
// If we have not yet seen a HDLC_FLAG indicating that
|
||||||
// a transmission is actually taking place, don't bother
|
// a transmission is actually taking place, don't bother
|
||||||
// with anything.
|
// with anything.
|
||||||
|
|
|
@ -51,6 +51,8 @@ inline static uint8_t sinSample(uint16_t i) {
|
||||||
|
|
||||||
#define SAMPLESPERBIT (SAMPLERATE / BITRATE)
|
#define SAMPLESPERBIT (SAMPLERATE / BITRATE)
|
||||||
#define PHASE_INC 1 // Nudge by an eigth of a sample each adjustment
|
#define PHASE_INC 1 // Nudge by an eigth of a sample each adjustment
|
||||||
|
|
||||||
|
#define DCD_MIN_COUNT 6
|
||||||
|
|
||||||
#if BITRATE == 960
|
#if BITRATE == 960
|
||||||
#define FILTER_CUTOFF 600
|
#define FILTER_CUTOFF 600
|
||||||
|
@ -80,6 +82,8 @@ typedef struct Hdlc
|
||||||
uint8_t bitIndex;
|
uint8_t bitIndex;
|
||||||
uint8_t currentByte;
|
uint8_t currentByte;
|
||||||
bool receiving;
|
bool receiving;
|
||||||
|
bool dcd;
|
||||||
|
uint8_t dcd_count;
|
||||||
} Hdlc;
|
} Hdlc;
|
||||||
|
|
||||||
typedef struct Afsk
|
typedef struct Afsk
|
||||||
|
|
|
@ -49,7 +49,7 @@ void kiss_csma(AX25Ctx *ctx, uint8_t *buf, size_t len) {
|
||||||
bool sent = false;
|
bool sent = false;
|
||||||
while (!sent) {
|
while (!sent) {
|
||||||
//puts("Waiting in CSMA");
|
//puts("Waiting in CSMA");
|
||||||
if(!channel->hdlc.receiving) {
|
if(!channel->hdlc.dcd) {
|
||||||
uint8_t tp = rand() & 0xFF;
|
uint8_t tp = rand() & 0xFF;
|
||||||
if (tp < p) {
|
if (tp < p) {
|
||||||
ax25_sendRaw(ctx, buf, len);
|
ax25_sendRaw(ctx, buf, len);
|
||||||
|
|
Loading…
Reference in New Issue