Skip to content

Commit

Permalink
#270 Added rate logging of SPI access from the LPS deck
Browse files Browse the repository at this point in the history
  • Loading branch information
krichardsson committed Sep 15, 2020
1 parent f072166 commit 652fb72
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/deck/drivers/src/locodeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "param.h"
#include "nvicconf.h"
#include "estimator.h"
#include "statsCnt.h"

#include "locodeck.h"

Expand Down Expand Up @@ -131,6 +132,9 @@ static QueueHandle_t lppShortQueue;

static uint32_t timeout;

static STATS_CNT_RATE_DEFINE(spiWriteCount, 1000);
static STATS_CNT_RATE_DEFINE(spiReadCount, 1000);

static void txCallback(dwDevice_t *dev)
{
timeout = algorithm->onEvent(dev, eventPacketSent);
Expand Down Expand Up @@ -322,6 +326,7 @@ static void spiWrite(dwDevice_t* dev, const void *header, size_t headerLength,
spiExchange(headerLength+dataLength, spiTxBuffer, spiRxBuffer);
digitalWrite(CS_PIN, HIGH);
spiEndTransaction();
STATS_CNT_RATE_EVENT(&spiWriteCount);
}

static void spiRead(dwDevice_t* dev, const void *header, size_t headerLength,
Expand All @@ -335,6 +340,7 @@ static void spiRead(dwDevice_t* dev, const void *header, size_t headerLength,
memcpy(data, spiRxBuffer+headerLength, dataLength);
digitalWrite(CS_PIN, HIGH);
spiEndTransaction();
STATS_CNT_RATE_EVENT(&spiReadCount);
}

#if LOCODECK_USE_ALT_PINS
Expand Down Expand Up @@ -513,6 +519,8 @@ LOG_GROUP_STOP(ranging)

LOG_GROUP_START(loco)
LOG_ADD(LOG_UINT8, mode, &algoOptions.currentRangingMode)
STATS_CNT_RATE_LOG_ADD(spiWr, &spiWriteCount)
STATS_CNT_RATE_LOG_ADD(spiRe, &spiReadCount)
LOG_GROUP_STOP(loco)

PARAM_GROUP_START(loco)
Expand Down

0 comments on commit 652fb72

Please sign in to comment.