1 /*
2  * Copyright (c) 2018, NXP
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include <zephyr/sys/printk.h>
9 #include <zephyr/device.h>
10 #include <zephyr/drivers/ipm.h>
11 
ipm_callback(const struct device * dev,void * context,uint32_t id,volatile void * data)12 static void ipm_callback(const struct device *dev, void *context,
13 			 uint32_t id, volatile void *data)
14 {
15 	int i;
16 	int status;
17 	uint32_t *data32 = (uint32_t *)data;
18 
19 	printk("%s: id = %u, data = 0x", __func__, id);
20 	for (i = 0; i < (CONFIG_IPM_IMX_MAX_DATA_SIZE / 4); i++) {
21 		printk("%08x", data32[i]);
22 	}
23 	printk("\n");
24 
25 	status = ipm_send(dev, 1, id, (const void *)data,
26 			  CONFIG_IPM_IMX_MAX_DATA_SIZE);
27 	if (status) {
28 		printk("ipm_send() failed: %d\n", status);
29 	}
30 }
31 
main(void)32 int main(void)
33 {
34 	const struct device *ipm;
35 
36 	ipm = DEVICE_DT_GET(DT_NODELABEL(mub));
37 	if (!device_is_ready(ipm)) {
38 		while (1) {
39 		}
40 	}
41 	ipm_register_callback(ipm, ipm_callback, NULL);
42 	ipm_set_enabled(ipm, 1);
43 	printk("IPM initialized, data size = %d\n",
44 		CONFIG_IPM_IMX_MAX_DATA_SIZE);
45 
46 	while (1) {
47 	}
48 	return 0;
49 }
50