1 /*
2  * Copyright (c) 2021 Antmicro <www.antmicro.com>
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include <zephyr/shell/shell.h>
9 #include <zephyr/device.h>
10 #include <zephyr/sys/printk.h>
11 #include <zephyr/drivers/fpga.h>
12 #include "redled.h"
13 #include "greenled.h"
14 #include <eoss3_dev.h>
15 
16 const struct device *const fpga = DEVICE_DT_GET(DT_NODELABEL(fpga0));
17 
main(void)18 int main(void)
19 {
20 	IO_MUX->PAD_21_CTRL = (PAD_E_4MA | PAD_P_PULLDOWN | PAD_OEN_NORMAL |
21 			       PAD_SMT_DISABLE | PAD_REN_DISABLE | PAD_SR_SLOW |
22 			       PAD_CTRL_SEL_AO_REG); /* Enable red led */
23 	IO_MUX->PAD_22_CTRL = (PAD_E_4MA | PAD_P_PULLDOWN | PAD_OEN_NORMAL |
24 			       PAD_SMT_DISABLE | PAD_REN_DISABLE | PAD_SR_SLOW |
25 			       PAD_CTRL_SEL_AO_REG); /* Enable green led */
26 
27 #if CONFIG_SHELL
28 	printk("Address of the bitstream (red): %p\n", &axFPGABitStream_red);
29 	printk("Address of the bitstream (green): %p\n", &axFPGABitStream_green);
30 	printk("Size of the bitstream (red): %d\n", sizeof(axFPGABitStream_red));
31 	printk("Size of the bitstream (green): %d\n", sizeof(axFPGABitStream_green));
32 #else
33 
34 	if (!device_is_ready(fpga)) {
35 		printk("fpga device is not ready\n");
36 	}
37 
38 	while (1) {
39 		fpga_load(fpga, axFPGABitStream_red,
40 			  sizeof(axFPGABitStream_red));
41 		k_msleep(2000);
42 		fpga_reset(fpga);
43 		fpga_load(fpga, axFPGABitStream_green,
44 			  sizeof(axFPGABitStream_green));
45 		k_msleep(2000);
46 		fpga_reset(fpga);
47 	}
48 #endif
49 	return 0;
50 }
51