Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more syslink debug probes #73

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions interface/syslink.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ void syslinkReset();
*/
void syslinkDeactivateUntilPacketReceived();

/**
* @brief Get the number of times checksum 1 has failed for packets on syslink from the STM
*
* @return uint8_t Number of failures
*/
uint8_t syslinkGetRxCheckSum1ErrorCnt();

/**
* @brief Get the number of times checksum 2 has failed for packets on syslink from the STM
*
* @return uint8_t Number of failures
*/
uint8_t syslinkGetRxCheckSum2ErrorCnt();


// Defined packet types
#define SYSLINK_RADIO_RAW 0x00
#define SYSLINK_RADIO_CHANNEL 0x01
Expand Down
2 changes: 2 additions & 0 deletions interface/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ bool uartIsDataReceived();
char uartGetc();

int uartDropped();
uint8_t uartGetError();
uint8_t uartGetErrorCount();

#endif //__UART_H__
6 changes: 5 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,12 @@ static void handleSyslinkEvents(bool slReceived)
slTxPacket.data[1] = debugProbeReceivedChan;
slTxPacket.data[2] = debugProbeReceivedRate;
slTxPacket.data[3] = (uint8_t)uartDropped();
slTxPacket.data[4] = uartGetError();
slTxPacket.data[5] = uartGetErrorCount();
slTxPacket.data[6] = syslinkGetRxCheckSum1ErrorCnt();
slTxPacket.data[7] = syslinkGetRxCheckSum2ErrorCnt();

slTxPacket.length = 4;
slTxPacket.length = 8;
syslinkSend(&slTxPacket);
}
break;
Expand Down
14 changes: 14 additions & 0 deletions src/syslink.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ static enum {state_first_start, state_second_start, state_length, state_type, st

static bool isSyslinkActive = false;

static uint8_t syslinkRxCheckSum1ErrorCnt;
static uint8_t syslinkRxCheckSum2ErrorCnt;

void syslinkReset() {
state = state_first_start;
}
Expand Down Expand Up @@ -119,6 +122,7 @@ bool syslinkReceive(struct syslinkPacket *packet)
}
else
{ // Wrong checksum
syslinkRxCheckSum1ErrorCnt++;
state = state_first_start;
#ifdef SYSLINK_CKSUM_MON
if (NRF_GPIO->OUT & (1<<LED_PIN))
Expand All @@ -137,6 +141,7 @@ bool syslinkReceive(struct syslinkPacket *packet)
}
else
{ // Wrong checksum
syslinkRxCheckSum2ErrorCnt++;
state = state_first_start;
step = 0;
#ifdef SYSLINK_CKSUM_MON
Expand Down Expand Up @@ -196,3 +201,12 @@ void syslinkDeactivateUntilPacketReceived()
{
isSyslinkActive = false;
}


uint8_t syslinkGetRxCheckSum1ErrorCnt() {
return syslinkRxCheckSum1ErrorCnt;
}

uint8_t syslinkGetRxCheckSum2ErrorCnt() {
return syslinkRxCheckSum2ErrorCnt;
}
22 changes: 16 additions & 6 deletions src/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@ static int tail = 0;
static int dropped = 0;
static char dummy;

int error = 0;
static uint8_t uartError = 0;
static uint8_t uartErrorCount = 0;

void UART0_IRQHandler()
{
int nhead = head+1;

//if (NRF_UART0->ERRORSRC) {
// error = NRF_UART0->ERRORSRC;
// NRF_UART0->ERRORSRC = 0xFF;
// __BKPT(0);
// }
if (NRF_UART0->ERRORSRC) {
uartError = NRF_UART0->ERRORSRC;
NRF_UART0->ERRORSRC = 0xFF;

uartErrorCount++;
}

NRF_UART0->EVENTS_RXDRDY = 0;

Expand Down Expand Up @@ -181,3 +183,11 @@ char uartGetc()
int uartDropped() {
return dropped;
}

uint8_t uartGetError() {
return uartError;
}

uint8_t uartGetErrorCount() {
return uartErrorCount;
}