kopia lustrzana https://github.com/sq8vps/vp-digi
new experimental KISS handling
rodzic
dfb13fa356
commit
040ce42764
|
@ -38,4 +38,6 @@ void KissSend(Uart *port, uint8_t *buf, uint16_t size);
|
|||
*/
|
||||
void KissParse(Uart *port, uint8_t data);
|
||||
|
||||
void KissProcess(Uart *port);
|
||||
|
||||
#endif /* KISS_H_ */
|
||||
|
|
|
@ -37,6 +37,7 @@ enum UartDataType
|
|||
{
|
||||
DATA_NOTHING = 0,
|
||||
DATA_TERM,
|
||||
DATA_KISS,
|
||||
DATA_USB,
|
||||
};
|
||||
|
||||
|
|
|
@ -96,19 +96,9 @@ 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();
|
||||
port->rxType = DATA_KISS;
|
||||
return;
|
||||
}
|
||||
else if(*index > 0)
|
||||
|
@ -131,3 +121,23 @@ void KissParse(Uart *port, uint8_t data)
|
|||
else
|
||||
port->kissTempBufferHead %= sizeof(port->kissTempBuffer);
|
||||
}
|
||||
|
||||
void KissProcess(Uart *port)
|
||||
{
|
||||
if(port->rxType == DATA_KISS)
|
||||
{
|
||||
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();
|
||||
port->rxType = DATA_NOTHING;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "config.h"
|
||||
#include "uart.h"
|
||||
#include "drivers/usb.h"
|
||||
#include "kiss.h"
|
||||
#ifdef ENABLE_FX25
|
||||
#include "fx25.h"
|
||||
#endif
|
||||
|
@ -260,23 +261,42 @@ int main(void)
|
|||
if(UartUsb.rxType != DATA_NOTHING)
|
||||
{
|
||||
TermHandleSpecial(&UartUsb);
|
||||
if(UartUsb.rxType != DATA_USB)
|
||||
if(UartUsb.rxType == DATA_KISS)
|
||||
{
|
||||
KissProcess(&UartUsb);
|
||||
}
|
||||
else if(UartUsb.rxType != DATA_USB)
|
||||
{
|
||||
|
||||
TermParse(&UartUsb);
|
||||
UartClearRx(&UartUsb);
|
||||
}
|
||||
UartUsb.rxType = DATA_NOTHING;
|
||||
}
|
||||
if(Uart1.rxType != DATA_NOTHING)
|
||||
{
|
||||
if(Uart1.rxType == DATA_KISS)
|
||||
{
|
||||
KissProcess(&Uart1);
|
||||
}
|
||||
else
|
||||
{
|
||||
TermParse(&Uart1);
|
||||
UartClearRx(&Uart1);
|
||||
}
|
||||
}
|
||||
if(Uart2.rxType != DATA_NOTHING)
|
||||
{
|
||||
if(Uart2.rxType == DATA_KISS)
|
||||
{
|
||||
KissProcess(&Uart2);
|
||||
}
|
||||
else
|
||||
{
|
||||
TermParse(&Uart2);
|
||||
UartClearRx(&Uart2);
|
||||
}
|
||||
}
|
||||
|
||||
BeaconCheck(); //check beacons
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
|
|||
KissParse(&UartUsb, Buf[i]);
|
||||
UartUsb.rxBufferHead %= UART_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
if(UartUsb.rxType != DATA_KISS)
|
||||
UartUsb.rxType = DATA_USB;
|
||||
handleUsbInterrupt(&UartUsb);
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue