From bced6f97f72e68b99b6df74dfe749bbb81804498 Mon Sep 17 00:00:00 2001 From: John Erasmus Mari Geronimo Date: Fri, 20 Dec 2024 22:53:18 +0800 Subject: [PATCH] projects: eval-ad8460: Add project for AD8460 Add initial project files for both basic and IIO examples for AD8460. Signed-off-by: John Erasmus Mari Geronimo --- projects/eval-ad8460/Makefile | 9 ++ projects/eval-ad8460/builds.json | 10 ++ projects/eval-ad8460/src.mk | 41 +++++++ projects/eval-ad8460/src/common/common_data.c | 70 ++++++++++++ projects/eval-ad8460/src/common/common_data.h | 48 ++++++++ .../src/examples/basic/basic_example.c | 103 ++++++++++++++++++ .../src/examples/basic/basic_example.h | 38 +++++++ .../eval-ad8460/src/examples/examples_src.mk | 21 ++++ .../src/examples/iio_example/iio_example.c | 81 ++++++++++++++ .../src/examples/iio_example/iio_example.h | 41 +++++++ .../eval-ad8460/src/platform/maxim/main.c | 80 ++++++++++++++ .../src/platform/maxim/parameters.c | 48 ++++++++ .../src/platform/maxim/parameters.h | 83 ++++++++++++++ .../src/platform/maxim/platform_src.mk | 14 +++ .../src/platform/platform_includes.h | 47 ++++++++ 15 files changed, 734 insertions(+) create mode 100644 projects/eval-ad8460/Makefile create mode 100644 projects/eval-ad8460/builds.json create mode 100644 projects/eval-ad8460/src.mk create mode 100644 projects/eval-ad8460/src/common/common_data.c create mode 100644 projects/eval-ad8460/src/common/common_data.h create mode 100644 projects/eval-ad8460/src/examples/basic/basic_example.c create mode 100644 projects/eval-ad8460/src/examples/basic/basic_example.h create mode 100644 projects/eval-ad8460/src/examples/examples_src.mk create mode 100644 projects/eval-ad8460/src/examples/iio_example/iio_example.c create mode 100644 projects/eval-ad8460/src/examples/iio_example/iio_example.h create mode 100644 projects/eval-ad8460/src/platform/maxim/main.c create mode 100644 projects/eval-ad8460/src/platform/maxim/parameters.c create mode 100644 projects/eval-ad8460/src/platform/maxim/parameters.h create mode 100644 projects/eval-ad8460/src/platform/maxim/platform_src.mk create mode 100644 projects/eval-ad8460/src/platform/platform_includes.h diff --git a/projects/eval-ad8460/Makefile b/projects/eval-ad8460/Makefile new file mode 100644 index 00000000000..ea22697a376 --- /dev/null +++ b/projects/eval-ad8460/Makefile @@ -0,0 +1,9 @@ +# Select the example you want to enable by choosing y for enabling and n for disabling +BASIC_EXAMPLE = n +IIO_EXAMPLE = y + +include ../../tools/scripts/generic_variables.mk + +include src.mk + +include ../../tools/scripts/generic.mk diff --git a/projects/eval-ad8460/builds.json b/projects/eval-ad8460/builds.json new file mode 100644 index 00000000000..049d74ba024 --- /dev/null +++ b/projects/eval-ad8460/builds.json @@ -0,0 +1,10 @@ +{ + "maxim": { + "basic_example_max32665": { + "flags" : "BASIC_EXAMPLE=y IIO_EXAMPLE=n TARGET=max32665" + }, + "iio_example_max32665": { + "flags" : "BASIC_EXAMPLE=n IIO_EXAMPLE=y TARGET=max32665" + } + } + } diff --git a/projects/eval-ad8460/src.mk b/projects/eval-ad8460/src.mk new file mode 100644 index 00000000000..de2665e5e73 --- /dev/null +++ b/projects/eval-ad8460/src.mk @@ -0,0 +1,41 @@ +include $(PROJECT)/src/platform/$(PLATFORM)/platform_src.mk +include $(PROJECT)/src/examples/examples_src.mk + +SRCS += $(PROJECT)/src/platform/$(PLATFORM)/main.c + +INCS += $(PROJECT)/src/common/common_data.h +SRCS += $(PROJECT)/src/common/common_data.c + +INCS += $(PROJECT)/src/platform/platform_includes.h + +INCS += $(PROJECT)/src/platform/$(PLATFORM)/parameters.h +SRCS += $(PROJECT)/src/platform/$(PLATFORM)/parameters.c + +INCS += $(INCLUDE)/no_os_delay.h \ + $(INCLUDE)/no_os_error.h \ + $(INCLUDE)/no_os_gpio.h \ + $(INCLUDE)/no_os_print_log.h \ + $(INCLUDE)/no_os_spi.h \ + $(INCLUDE)/no_os_alloc.h \ + $(INCLUDE)/no_os_irq.h \ + $(INCLUDE)/no_os_list.h \ + $(INCLUDE)/no_os_dma.h \ + $(INCLUDE)/no_os_uart.h \ + $(INCLUDE)/no_os_lf256fifo.h \ + $(INCLUDE)/no_os_util.h \ + $(INCLUDE)/no_os_units.h \ + $(INCLUDE)/no_os_mutex.h + +SRCS += $(DRIVERS)/api/no_os_gpio.c \ + $(NO-OS)/util/no_os_lf256fifo.c \ + $(DRIVERS)/api/no_os_irq.c \ + $(DRIVERS)/api/no_os_spi.c \ + $(DRIVERS)/api/no_os_uart.c \ + $(DRIVERS)/api/no_os_dma.c \ + $(NO-OS)/util/no_os_list.c \ + $(NO-OS)/util/no_os_util.c \ + $(NO-OS)/util/no_os_alloc.c \ + $(NO-OS)/util/no_os_mutex.c + +INCS += $(DRIVERS)/dac/ad8460/ad8460.h +SRCS += $(DRIVERS)/dac/ad8460/ad8460.c diff --git a/projects/eval-ad8460/src/common/common_data.c b/projects/eval-ad8460/src/common/common_data.c new file mode 100644 index 00000000000..411e9f1ab4a --- /dev/null +++ b/projects/eval-ad8460/src/common/common_data.c @@ -0,0 +1,70 @@ +/******************************************************************************* + * @file common_data.c + * @brief Defines common data to be used by ad8460 examples. + * @author John Erasmus Mari Geronimo (johnerasmusmari.geronimo@analog.com) + ******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ + +#include "common_data.h" +#include + +struct no_os_uart_init_param uip = { + .device_id = UART_DEVICE_ID, + .baud_rate = UART_BAUDRATE, + .size = NO_OS_UART_CS_8, + .parity = NO_OS_UART_PAR_NO, + .stop = NO_OS_UART_STOP_1_BIT, + .platform_ops = UART_OPS, + .extra = UART_EXTRA, +}; + +const struct no_os_spi_init_param ad8460_spi_ip = { + .device_id = SPI_DEVICE_ID, + .max_speed_hz = SPI_MAX_SPEED, + .chip_select = SPI_CS, + .mode = NO_OS_SPI_MODE_0, + .bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST, + .platform_ops = SPI_OPS, + .extra = SPI_EXTRA, + .parent = NULL, +}; + +const struct no_os_gpio_init_param ad8460_gpio_rstn = { + .port = GPIO_RSTN_PORT_NUM, + .number = GPIO_RSTN_PIN_NUM, + .platform_ops = GPIO_OPS, + .extra = GPIO_EXTRA, +}; + +struct ad8460_init_param ad8460_ip = { + .spi_init_param = ad8460_spi_ip, + .gpio_rstn = ad8460_gpio_rstn, + .refio_1p2v_mv = 1200, + .ext_resistor_ohms = 2000, +}; diff --git a/projects/eval-ad8460/src/common/common_data.h b/projects/eval-ad8460/src/common/common_data.h new file mode 100644 index 00000000000..4e63c6667ed --- /dev/null +++ b/projects/eval-ad8460/src/common/common_data.h @@ -0,0 +1,48 @@ +/******************************************************************************* + * @file common_data.h + * @brief Defines common data to be used by ad8460 examples. + * @author John Erasmus Mari Geronimo (johnerasmusmari.geronimo@analog.com) + ******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ +#ifndef __COMMON_DATA_H__ +#define __COMMON_DATA_H__ + +#include "platform_includes.h" +#include "ad8460.h" +#ifdef IIO_SUPPORT +#include "iio_ad8460.h" +#endif + +extern struct no_os_uart_init_param uip; + +extern const struct no_os_spi_init_param ad8460_spi_ip; +extern const struct no_os_gpio_init_param ad8460_gpio_rstn; +extern struct ad8460_init_param ad8460_ip; + +#endif /* __COMMON_DATA_H__ */ diff --git a/projects/eval-ad8460/src/examples/basic/basic_example.c b/projects/eval-ad8460/src/examples/basic/basic_example.c new file mode 100644 index 00000000000..e04bdf30875 --- /dev/null +++ b/projects/eval-ad8460/src/examples/basic/basic_example.c @@ -0,0 +1,103 @@ +/******************************************************************************* + * @file basic_example.c + * @brief Basic example code for ad8460 project + * @author John Erasmus Mari Geronimo (johnerasmusmari.geronimo@analog.com) + ******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ + +#include "basic_example.h" +#include "common_data.h" +#include "ad8460.h" +#include "no_os_print_log.h" + +/***************************************************************************** + * @brief Basic example main execution. + * + * @return ret - Result of the example execution. If working correctly, will + * execute continuously the while(1) loop and will not return. + *******************************************************************************/ +int basic_example_main() +{ + struct ad8460_device *dev; + int ret, i; + uint16_t val; + uint8_t flag; + + pr_info("\r\nRunning AD8460 Basic Example\r\n"); + + ret = ad8460_init(&dev, &ad8460_ip); + if (ret) + goto error; + + ret = ad8460_reset(dev); + if (ret) + goto free_dev; + + /** Switch to APG mode */ + ret = ad8460_enable_apg_mode(dev, 1); + if (ret) + goto free_dev; + + /** Switch to AWG mode */ + ret = ad8460_enable_apg_mode(dev, 0); + + for (i = 0; i < 16; i++) { + ret = ad8460_set_hvdac_word(dev, i, i); + if (ret) + goto free_dev; + + ret = ad8460_get_hvdac_word(dev, i, &val); + if (ret) + goto free_dev; + + pr_info("HVDAC[%d]: 0x%04X\r\n", i, val); + } + + ret = ad8460_read_shutdown_flag(dev, &flag); + if (ret) + goto free_dev; + + pr_info("Shutdown flag: %d\r\n", flag); + + if (flag) { + ret = ad8460_hv_reset(dev); + if (ret) + goto free_dev; + } + + pr_info("AD8460 Basic Example Done\r\n"); + + return 0; + +free_dev: + ad8460_remove(dev); +error: + pr_info("Error!\r\n"); + return ret; +} diff --git a/projects/eval-ad8460/src/examples/basic/basic_example.h b/projects/eval-ad8460/src/examples/basic/basic_example.h new file mode 100644 index 00000000000..c36f9f9e4c2 --- /dev/null +++ b/projects/eval-ad8460/src/examples/basic/basic_example.h @@ -0,0 +1,38 @@ +/******************************************************************************* + * @file basic_example.h + * @brief Basic example header for ad8460 project + * @author John Erasmus Mari Geronimo (johnerasmusmari.geronimo@analog.com) + ******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ +#ifndef __BASIC_EXAMPLE_H__ +#define __BASIC_EXAMPLE_H__ + +int basic_example_main(); + +#endif /* __BASIC_EXAMPLE_H__ */ diff --git a/projects/eval-ad8460/src/examples/examples_src.mk b/projects/eval-ad8460/src/examples/examples_src.mk new file mode 100644 index 00000000000..e714ac9dbf3 --- /dev/null +++ b/projects/eval-ad8460/src/examples/examples_src.mk @@ -0,0 +1,21 @@ +ifeq (y,$(strip $(IIO_EXAMPLE))) +IIOD=y +CFLAGS += -DIIO_EXAMPLE=1 +SRCS += $(PROJECT)/src/examples/iio_example/iio_example.c +INCS += $(PROJECT)/src/examples/iio_example/iio_example.h +endif + +ifeq (y,$(strip $(BASIC_EXAMPLE))) +CFLAGS += -DBASIC_EXAMPLE=1 +SRCS += $(PROJECT)/src/examples/basic/basic_example.c +INCS += $(PROJECT)/src/examples/basic/basic_example.h +endif + +ifeq (y,$(strip $(IIOD))) +SRC_DIRS += $(NO-OS)/iio/iio_app +INCS += $(DRIVERS)/dac/ad8460/iio_ad8460.h +SRCS += $(DRIVERS)/dac/ad8460/iio_ad8460.c + +INCS += $(INCLUDE)/no_os_list.h \ + $(PLATFORM_DRIVERS)/$(PLATFORM)_uart.h +endif diff --git a/projects/eval-ad8460/src/examples/iio_example/iio_example.c b/projects/eval-ad8460/src/examples/iio_example/iio_example.c new file mode 100644 index 00000000000..7c8da4f097a --- /dev/null +++ b/projects/eval-ad8460/src/examples/iio_example/iio_example.c @@ -0,0 +1,81 @@ +/******************************************************************************** + * @file iio_example.c + * @brief IIO example code for the ad8460 project + * @author John Erasmus Mari Geronimo (johnerasmusmari.geronimo@analog.com) + ******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ + +#include "iio_example.h" +#include "common_data.h" +#include "no_os_print_log.h" + +/******************************************************************************* + * @brief IIO example main execution. + * + * @return ret - Result of the example execution. If working correctly, will + * execute continuously function iio_app_run and will not return. + *******************************************************************************/ +int iio_example_main() +{ + int ret; + struct ad8460_iio_device *ad8460_iio_dev; + struct ad8460_iio_init_param ad8460_iio_ip; + struct iio_app_desc *app; + struct iio_app_init_param app_init_param = {0}; + + ad8460_iio_ip.init_param = &ad8460_ip; + ret = ad8460_iio_init(&ad8460_iio_dev, &ad8460_iio_ip); + if (ret) + return ret; + + struct iio_app_device iio_devices[] = { + { + .name = "ad8460", + .dev = ad8460_iio_dev, + .dev_descriptor = ad8460_iio_dev->iio_dev, + }, + }; + + app_init_param.devices = iio_devices; + app_init_param.nb_devices = NO_OS_ARRAY_SIZE(iio_devices); + app_init_param.uart_init_params = uip; + + ret = iio_app_init(&app, app_init_param); + if (ret) + goto error; + + ret = iio_app_run(app); + if (ret) + pr_err("Error: iio_app_run: %d\r\n", ret); + + iio_app_remove(app); +error: + ad8460_iio_remove(ad8460_iio_dev); + return ret; +} diff --git a/projects/eval-ad8460/src/examples/iio_example/iio_example.h b/projects/eval-ad8460/src/examples/iio_example/iio_example.h new file mode 100644 index 00000000000..269b724225f --- /dev/null +++ b/projects/eval-ad8460/src/examples/iio_example/iio_example.h @@ -0,0 +1,41 @@ +/******************************************************************************* + * @file iio_example.h + * @brief IIO example header for ad8460 project + * @author John Erasmus Mari Geronimo (johnerasmusmari.geronimo@analog.com) + ******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ +#ifndef __IIO_EXAMPLE_H__ +#define __IIO_EXAMPLE_H__ + +/******************************************************************************/ +/************************ Functions Declarations ******************************/ +/******************************************************************************/ +int iio_example_main(); + +#endif /* __IIO_EXAMPLE_H__ */ diff --git a/projects/eval-ad8460/src/platform/maxim/main.c b/projects/eval-ad8460/src/platform/maxim/main.c new file mode 100644 index 00000000000..2cf9af2a9cc --- /dev/null +++ b/projects/eval-ad8460/src/platform/maxim/main.c @@ -0,0 +1,80 @@ +/******************************************************************************** + * @file main.c + * @brief Main file for Maxim platform of ad8460 project. + * @author John Erasmus Mari Geronimo (johnerasmusmari.geronimo@analog.com) + ******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ + +#include "platform_includes.h" +#include "common_data.h" + +#ifdef IIO_EXAMPLE +#include "iio_example.h" +#endif + +#ifdef BASIC_EXAMPLE +#include "basic_example.h" +#endif + +/******************************************************************************* + * @brief Main function execution for AD8460 platform. + * + * @return ret - Result of the enabled examples execution. + *******************************************************************************/ +int main() +{ +#ifdef BASIC_EXAMPLE + int ret; + struct no_os_uart_desc *uart; + + ret = no_os_uart_init(&uart, &uip); + if (ret) + goto error; + + no_os_uart_stdio(uart); + ret = basic_example_main(); + if (ret) + goto error; +#endif + +#ifdef IIO_EXAMPLE + return iio_example_main(); +#endif + +#if (IIO_EXAMPLE + BASIC_EXAMPLE != 1) +#error Selected example projects cannot be enabled at the same time. \ +Please enable only one example and re - build the project. +#endif + +#ifdef BASIC_EXAMPLE +error: + no_os_uart_remove(uart); +#endif + return 0; +} diff --git a/projects/eval-ad8460/src/platform/maxim/parameters.c b/projects/eval-ad8460/src/platform/maxim/parameters.c new file mode 100644 index 00000000000..4204a380654 --- /dev/null +++ b/projects/eval-ad8460/src/platform/maxim/parameters.c @@ -0,0 +1,48 @@ +/******************************************************************************** + * @file parameters.c + * @brief Definition of maxim platform data used by ad8460 project. + * @author John Erasmus Mari Geronimo (johnerasmusmari.geronimo@analog.com) + ******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ +#include "parameters.h" + +struct max_uart_init_param max_uart_extra = { + .flow = UART_FLOW_DIS, + .vssel = MXC_GPIO_VSSEL_VDDIOH +}; + +struct max_spi_init_param max_spi_extra = { + .num_slaves = 1, + .polarity = SPI_SS_POL_LOW, + .vssel = MXC_GPIO_VSSEL_VDDIOH +}; + +struct max_gpio_init_param max_gpio_extra = { + .vssel = MXC_GPIO_VSSEL_VDDIOH +}; diff --git a/projects/eval-ad8460/src/platform/maxim/parameters.h b/projects/eval-ad8460/src/platform/maxim/parameters.h new file mode 100644 index 00000000000..86ad0c73cf2 --- /dev/null +++ b/projects/eval-ad8460/src/platform/maxim/parameters.h @@ -0,0 +1,83 @@ +/******************************************************************************** + * @brief Definitions specific to Maxim platform used by ad8460 project. + * @author John Erasmus Mari Geronimo (johnerasmusmari.geronimo@analog.com) + ******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ +#ifndef __PARAMETERS_H__ +#define __PARAMETERS_H__ + +#include "maxim_gpio.h" +#include "maxim_spi.h" +#include "maxim_uart.h" +#include "maxim_uart_stdio.h" + +#ifdef IIO_SUPPORT +#define INTC_DEVICE_ID 0 +#endif + +#if (TARGET_NUM == 32690) +#define UART_IRQ_ID UART0_IRQn +#define UART_DEVICE_ID 0 +#elif (TARGET_NUM == 32665) +#define UART_IRQ_ID UART1_IRQn +#define UART_DEVICE_ID 1 +#endif + +#define UART_BAUDRATE 115200 +#define UART_OPS &max_uart_ops +#define UART_EXTRA &max_uart_extra + +#if (TARGET_NUM == 32650) +#define SPI_DEVICE_ID 1 +#define SPI_CS 0 +#elif (TARGET_NUM == 32660) || (TARGET_NUM == 32655) +#define SPI_DEVICE_ID 0 +#define SPI_CS 0 +#elif (TARGET_NUM == 32665) +#define SPI_DEVICE_ID 1 +#define SPI_CS 0 +#elif (TARGET_NUM == 78000) +#define SPI_DEVICE_ID 1 +#define SPI_CS 1 +#endif + +#define SPI_MAX_SPEED 1000000 +#define SPI_OPS &max_spi_ops +#define SPI_EXTRA &max_spi_extra + +#define GPIO_RSTN_PORT_NUM 0 +#define GPIO_RSTN_PIN_NUM 27 +#define GPIO_OPS &max_gpio_ops +#define GPIO_EXTRA &max_gpio_extra + +extern struct max_uart_init_param max_uart_extra; +extern struct max_spi_init_param max_spi_extra; +extern struct max_gpio_init_param max_gpio_extra; + +#endif /* __PARAMETERS_H__ */ diff --git a/projects/eval-ad8460/src/platform/maxim/platform_src.mk b/projects/eval-ad8460/src/platform/maxim/platform_src.mk new file mode 100644 index 00000000000..784dcf675ca --- /dev/null +++ b/projects/eval-ad8460/src/platform/maxim/platform_src.mk @@ -0,0 +1,14 @@ +INCS += $(PLATFORM_DRIVERS)/maxim_gpio.h \ + $(PLATFORM_DRIVERS)/maxim_spi.h \ + $(PLATFORM_DRIVERS)/../common/maxim_dma.h \ + $(PLATFORM_DRIVERS)/maxim_irq.h \ + $(PLATFORM_DRIVERS)/maxim_uart.h \ + $(PLATFORM_DRIVERS)/maxim_uart_stdio.h + +SRCS += $(PLATFORM_DRIVERS)/maxim_delay.c \ + $(PLATFORM_DRIVERS)/maxim_gpio.c \ + $(PLATFORM_DRIVERS)/maxim_spi.c \ + $(PLATFORM_DRIVERS)/../common/maxim_dma.c \ + $(PLATFORM_DRIVERS)/maxim_irq.c \ + $(PLATFORM_DRIVERS)/maxim_uart.c \ + $(PLATFORM_DRIVERS)/maxim_uart_stdio.c diff --git a/projects/eval-ad8460/src/platform/platform_includes.h b/projects/eval-ad8460/src/platform/platform_includes.h new file mode 100644 index 00000000000..74e64de5b10 --- /dev/null +++ b/projects/eval-ad8460/src/platform/platform_includes.h @@ -0,0 +1,47 @@ +/******************************************************************************** + * @file platform_includes.h + * @brief Includes for used platforms used by the ad8460 project. + * @author John Erasmus Mari Geronimo (johnerasmusmari.geronimo@analog.com) + ******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ +#ifndef __PLATFORM_INCLUDES_H__ +#define __PLATFORM_INCLUDES_H__ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ +#ifdef MAXIM_PLATFORM +#include "maxim/parameters.h" +#endif + +#ifdef IIO_SUPPORT +#include "iio_app.h" +#endif + +#endif /* __PLATFORM_INCLUDES_H__ */