1 /*
2  * Copyright (c) 2021 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include <zephyr/device.h>
9 #include <hal/nrf_ipc.h>
10 #include <zephyr/sys/printk.h>
11 #include <zephyr/logging/log.h>
12 LOG_MODULE_REGISTER(main);
13 
timeout_handler(struct k_timer * timer)14 static void timeout_handler(struct k_timer *timer)
15 {
16 	nrf_ipc_task_t task = offsetof(NRF_IPC_Type, TASKS_SEND[2]);
17 	uint32_t now = sys_clock_tick_get_32();
18 	uint32_t shared_cell = 0x20070000;
19 
20 	*(volatile uint32_t *)shared_cell = now;
21 	nrf_ipc_task_trigger(NRF_IPC, task);
22 
23 	LOG_INF("IPC send at %d ticks", now);
24 
25 	/* Do it only for the first second. */
26 	if (now > sys_clock_hw_cycles_per_sec()) {
27 		k_timer_stop(timer);
28 	}
29 }
30 
31 K_TIMER_DEFINE(timer, timeout_handler, NULL);
32 
main(void)33 int main(void)
34 {
35 	LOG_INF("Synchronization using %s driver", IS_ENABLED(CONFIG_MBOX) ? "mbox" : "ipm");
36 	k_timer_start(&timer, K_MSEC(50), K_MSEC(50));
37 	return 0;
38 }
39