experimental kiss double buffering

pull/32/head
Piotr Wilkon 2023-09-11 10:25:08 +02:00
rodzic eb00ad619d
commit dfb13fa356
4 zmienionych plików z 47 dodań i 21 usunięć

Wyświetl plik

@ -32,11 +32,6 @@ enum ModemType
MODEM_1200_V23,
MODEM_300,
MODEM_9600,
#ifdef ENABLE_PSK
MODEM_BPSK_1200,
MODEM_QPSK_1200,
#endif
};
enum ModemTxTestMode
@ -65,8 +60,6 @@ enum ModemPrefilter
PREFILTER_FLAT,
};
void pushSample(float s);
/**
* @brief Get measured signal level
* @param modem Modem number
@ -151,9 +144,4 @@ void ModemTransmitStop(void);
*/
void ModemInit(void);
#if (MODEM_DEMODULATOR_COUNT > 8)
#error There may be at most 8 parallel demodulators/decoders
#endif
#endif

Wyświetl plik

@ -57,6 +57,9 @@ typedef struct
volatile uint16_t lastRxBufferHead; //for special characters handling
volatile uint8_t kissBuffer[AX25_FRAME_MAX_SIZE + 1];
volatile uint16_t kissBufferHead;
volatile uint8_t kissProcessingOngoing;
volatile uint8_t kissTempBuffer[10];
volatile uint16_t kissTempBufferHead;
} Uart;
extern Uart Uart1, Uart2, UartUsb;

Wyświetl plik

@ -49,8 +49,27 @@ void KissSend(Uart *port, uint8_t *buf, uint16_t size)
void KissParse(Uart *port, uint8_t data)
{
volatile uint8_t *buf = NULL;
volatile uint16_t *index = NULL;
if(!port->kissProcessingOngoing)
{
buf = port->kissBuffer;
index = &port->kissBufferHead;
}
else
{
buf = port->kissTempBuffer;
index = &port->kissTempBufferHead;
}
if(data == 0xC0) //frame end marker
{
if(port->kissProcessingOngoing)
{
*index = 0;
return;
}
if(port->kissBufferHead < 16) //command+source+destination+Control=16
{
port->kissBufferHead = 0;
@ -75,24 +94,40 @@ void KissParse(Uart *port, uint8_t data)
}
}
__disable_irq();
port->kissProcessingOngoing = 1;
__enable_irq();
Ax25WriteTxFrame((uint8_t*)&port->kissBuffer[1], port->kissBufferHead - 1);
DigiStoreDeDupe((uint8_t*)&port->kissBuffer[1], port->kissBufferHead - 1);
port->kissBufferHead = 0;
__disable_irq();
port->kissProcessingOngoing = 0;
if(port->kissTempBufferHead > 0)
{
memcpy((uint8_t*)port->kissBuffer, (uint8_t*)port->kissTempBuffer, port->kissTempBufferHead);
port->kissBufferHead = port->kissTempBufferHead;
port->kissTempBufferHead = 0;
}
__enable_irq();
return;
}
else if(port->kissBufferHead > 0)
else if(*index > 0)
{
if((data == 0xDC) && (port->kissBuffer[port->kissBufferHead - 1] == 0xDB)) //escape character with transposed frame end
if((data == 0xDC) && (buf[*index - 1] == 0xDB)) //escape character with transposed frame end
{
port->kissBuffer[port->kissBufferHead - 1] = 0xC0;
buf[*index - 1] = 0xC0;
return;
}
else if((data == 0xDD) && (port->kissBuffer[port->kissBufferHead - 1] == 0xDB)) //escape character with transposed escape character
else if((data == 0xDD) && (buf[*index - 1] == 0xDB)) //escape character with transposed escape character
{
port->kissBuffer[port->kissBufferHead - 1] = 0xDB;
buf[*index - 1] = 0xDB;
return;
}
}
port->kissBuffer[port->kissBufferHead++] = data;
port->kissBufferHead %= sizeof(port->kissBuffer);
buf[(*index)++] = data;
if(!port->kissProcessingOngoing)
port->kissBufferHead %= sizeof(port->kissBuffer);
else
port->kissTempBufferHead %= sizeof(port->kissTempBuffer);
}

Wyświetl plik

@ -199,7 +199,7 @@ int main(void)
MX_GPIO_Init();
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 2 */
//WdogInit(); //initialize watchdog
WdogInit(); //initialize watchdog
memset(&beacon, 0, sizeof(beacon));
memset(&Ax25Config, 0, sizeof(Ax25Config));
@ -246,7 +246,7 @@ int main(void)
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
//WdogReset();
WdogReset();
if(Ax25GetReceivedFrameBitmap())
handleFrame();