1 /*
2  * Copyright (c) 2024 Open Pixel Systems
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include <zephyr/sys/printk.h>
9 #include <zephyr/drivers/i2c.h>
10 #include <zephyr/drivers/i2c/target/eeprom.h>
11 
12 static const struct device *eeprom = DEVICE_DT_GET(DT_NODELABEL(eeprom0));
13 
main(void)14 int main(void)
15 {
16 	printk("i2c target sample\n");
17 
18 	if (!device_is_ready(eeprom)) {
19 		printk("eeprom device not ready\n");
20 		return 0;
21 	}
22 
23 	if (i2c_target_driver_register(eeprom) < 0) {
24 		printk("Failed to register i2c target driver\n");
25 		return 0;
26 	}
27 
28 	printk("i2c target driver registered\n");
29 
30 	k_msleep(1000);
31 
32 	if (i2c_target_driver_unregister(eeprom) < 0) {
33 		printk("Failed to unregister i2c target driver\n");
34 		return 0;
35 	}
36 
37 	printk("i2c target driver unregistered\n");
38 
39 	return 0;
40 }
41