Skip to content

Commit e86a306

Browse files
jaz1-nordiccarlescufi
authored andcommitted
applications: sdp: mspi: add timer kicking
Added support to reset a timer used as an SDP application watchdog timer. Signed-off-by: Jakub Zymelka <[email protected]>
1 parent dd9bbd4 commit e86a306

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

applications/sdp/mspi/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,11 @@ config SDP_MSPI_IPC_NO_COPY
1111
this requires both cores to be able to access each others memory spaces.
1212
If n Data is passed through IPC by copy.
1313

14+
config SDP_MSPI_FAULT_TIMER
15+
bool "SDP application fault timer"
16+
help
17+
Enable SDP application fault timer.
18+
Timer is used to detect application faults. If the timer expires,
19+
the application is considered to be in a fault state.
20+
1421
source "Kconfig.zephyr"

applications/sdp/mspi/src/main.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <hal/nrf_vpr_csr.h>
1414
#include <hal/nrf_vpr_csr_vio.h>
1515
#include <hal/nrf_vpr_csr_vtim.h>
16+
#include <hal/nrf_timer.h>
1617
#include <haly/nrfy_gpio.h>
1718

1819
#include <drivers/mspi/nrfe_mspi.h>
@@ -76,6 +77,9 @@ static volatile uint8_t response_buffer[CONFIG_SDP_MSPI_MAX_RESPONSE_SIZE];
7677

7778
static struct ipc_ept ep;
7879
static atomic_t ipc_atomic_sem = ATOMIC_INIT(0);
80+
#if defined(CONFIG_SDP_MSPI_FAULT_TIMER)
81+
static NRF_TIMER_Type *fault_timer;
82+
#endif
7983

8084
static void adjust_tail(volatile hrt_xfer_data_t *xfer_data, uint16_t frame_width,
8185
uint32_t data_length)
@@ -367,10 +371,23 @@ static void ep_recv(const void *data, size_t len, void *priv)
367371
nrfe_mspi_flpr_response_msg_t response;
368372
uint8_t opcode = *(uint8_t *)data;
369373
uint32_t num_bytes = 0;
370-
374+
#if defined(CONFIG_SDP_MSPI_FAULT_TIMER)
375+
if (fault_timer != NULL) {
376+
nrf_timer_task_trigger(fault_timer, NRF_TIMER_TASK_START);
377+
}
378+
#endif
371379
response.opcode = opcode;
372380

373381
switch (opcode) {
382+
#if defined(CONFIG_SDP_MSPI_FAULT_TIMER)
383+
case NRFE_MSPI_CONFIG_TIMER_PTR: {
384+
const nrfe_mspi_flpr_timer_msg_t *timer_data =
385+
(const nrfe_mspi_flpr_timer_msg_t *)data;
386+
387+
fault_timer = timer_data->timer_ptr;
388+
break;
389+
}
390+
#endif
374391
case NRFE_MSPI_CONFIG_PINS: {
375392
nrfe_mspi_pinctrl_soc_pin_msg_t *pins_cfg = (nrfe_mspi_pinctrl_soc_pin_msg_t *)data;
376393

@@ -442,6 +459,12 @@ static void ep_recv(const void *data, size_t len, void *priv)
442459

443460
response_buffer[0] = opcode;
444461
ipc_service_send(&ep, (const void *)response_buffer, sizeof(opcode) + num_bytes);
462+
#if defined(CONFIG_SDP_MSPI_FAULT_TIMER)
463+
if (fault_timer != NULL) {
464+
nrf_timer_task_trigger(fault_timer, NRF_TIMER_TASK_CLEAR);
465+
nrf_timer_task_trigger(fault_timer, NRF_TIMER_TASK_STOP);
466+
}
467+
#endif
445468
}
446469

447470
static const struct ipc_ept_cfg ep_cfg = {

0 commit comments

Comments
 (0)