Reworked buffering system

This commit is contained in:
Mark Qvist 2020-06-01 15:25:29 +02:00
parent 3e43786dd1
commit e43cb2f543
4 changed files with 30 additions and 32 deletions

View file

@ -106,13 +106,13 @@ void AFSK_init(Afsk *afsk) {
afsk->silentSamples = 0;
// Initialise FIFO buffers
fifo_init(&afsk->delayFifo, (uint8_t *)afsk->delayBuf, sizeof(afsk->delayBuf));
fifo_init(&afsk->rxFifo, afsk->rxBuf, sizeof(afsk->rxBuf));
fifo_init(&afsk->txFifo, afsk->txBuf, sizeof(afsk->txBuf));
fifo_init(&afsk->delayFifo, (uint8_t *)afsk->delayBuf, sizeof(afsk->delayBuf)-1);
fifo_init(&afsk->rxFifo, afsk->rxBuf, CONFIG_AFSK_RX_BUFLEN);
fifo_init(&afsk->txFifo, afsk->txBuf, CONFIG_AFSK_TX_BUFLEN);
// Fill delay FIFO with zeroes
for (int i = 0; i<ADC_SAMPLESPERBIT / 2; i++) {
fifo_push(&afsk->delayFifo, 0);
while (fifo_isfull(&afsk->delayFifo)) {
fifo_push_locked(&afsk->delayFifo, 0);
}
AFSK_hw_init();

View file

@ -182,18 +182,18 @@ typedef struct Afsk
// Demodulation values
FIFOBuffer delayFifo; // Delayed FIFO for frequency discrimination
#if BITRATE == 1200
int8_t delayBuf[ADC_SAMPLESPERBIT / 2 + 1]; // Actual data storage for said FIFO
int8_t delayBuf[(ADC_SAMPLESPERBIT / 2 - 1) + 1]; // Actual data storage for said FIFO
#elif BITRATE == 2400
int8_t delayBuf[7 + 1];
int8_t delayBuf[(7) + 1];
#elif BITRATE == 300
int8_t delayBuf[9 + 1];
int8_t delayBuf[(9) + 1];
#endif
FIFOBuffer rxFifo; // FIFO for received data
uint8_t rxBuf[CONFIG_AFSK_RX_BUFLEN]; // Actual data storage for said FIFO
uint8_t rxBuf[CONFIG_AFSK_RX_BUFLEN+1]; // Actual data storage for said FIFO
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+1]; // Actual data storage for said FIFO
int16_t iirX[2]; // IIR Filter X cells
int16_t iirY[2]; // IIR Filter Y cells

View file

@ -84,7 +84,7 @@ ISR(USART0_RX_vect) {
char c = uart0_getchar_nowait();
fifo_push(&uart0FIFO, c);
} else {
uart0_getchar_nowait();
//uart0_getchar_nowait();
}
}
}
@ -95,7 +95,7 @@ ISR(USART1_RX_vect) {
char c = uart1_getchar_nowait();
fifo_push(&uart1FIFO, c);
} else {
uart1_getchar_nowait();
//uart1_getchar_nowait();
}
}
}