Skip to content

Commit

Permalink
system: Add request and print of NRF fw version
Browse files Browse the repository at this point in the history
This adds use of a new SYSLINK message:

  SYSLINK_SYS_NRF_VERSION

The NRF will reply with a string, for example:

Example:
  2021.06 +1*

Which mean 1 commit from the 2021.06 tag and the * marks it as
"locally modified".
  • Loading branch information
jonasdn committed Sep 3, 2021
1 parent 91598fe commit 0b2caed
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/hal/interface/syslink.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
#define SYSLINK_OW_READ 0x22
#define SYSLINK_OW_WRITE 0x23

#define SYSLINK_SYS_GROUP 0x30
#define SYSLINK_SYS_NRF_VERSION 0x30

typedef struct _SyslinkPacket
{
uint8_t type;
Expand Down
4 changes: 4 additions & 0 deletions src/hal/src/syslink.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "pm.h"
#include "ow.h"
#include "static_mem.h"
#include "system.h"

#ifdef UART2_LINK_COMM
#include "uart2.h"
Expand Down Expand Up @@ -102,6 +103,9 @@ static void syslinkRouteIncommingPacket(SyslinkPacket *slp)
case SYSLINK_OW_GROUP:
owSyslinkRecieve(slp);
break;
case SYSLINK_SYS_GROUP:
systemSyslinkReceive(slp);
break;
default:
DEBUG_PRINT("Unknown packet:%X.\n", slp->type);
break;
Expand Down
2 changes: 2 additions & 0 deletions src/modules/interface/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ void systemSetArmed(bool val);
bool systemIsArmed();

void systemRequestShutdown();
void systemRequestNRFVersion();
void systemSyslinkReceive();

#endif //__SYSTEM_H__
27 changes: 27 additions & 0 deletions src/modules/src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ static bool armed = ARM_INIT;
static bool forceArm;
static bool isInit;

static char nrf_version[16];

STATIC_MEM_TASK_ALLOC(systemTask, SYSTEM_TASK_STACKSIZE);

/* System wide synchronisation */
Expand Down Expand Up @@ -200,6 +202,8 @@ void systemTask(void *arg)
proximityInit();
#endif

systemRequestNRFVersion();

//Test the modules
DEBUG_PRINT("About to run tests in system.c.\n");
if (systemTest() == false) {
Expand Down Expand Up @@ -339,6 +343,29 @@ void systemRequestShutdown()
syslinkSendPacket(&slp);
}

void systemRequestNRFVersion()
{
SyslinkPacket slp;

slp.type = SYSLINK_SYS_NRF_VERSION;
slp.length = 0;
syslinkSendPacket(&slp);
}

void systemSyslinkReceive(SyslinkPacket *slp)
{
if (slp->type == SYSLINK_SYS_NRF_VERSION)
{
size_t len = slp->length - 2;

if (sizeof(nrf_version) - 1 <= len) {
len = sizeof(nrf_version) - 1;
}
memcpy(&nrf_version, &slp->data[0], len);
DEBUG_PRINT("NRF51 version: %s\n", nrf_version);
}
}

void vApplicationIdleHook( void )
{
static uint32_t tickOfLatestWatchdogReset = M2T(0);
Expand Down

0 comments on commit 0b2caed

Please sign in to comment.