diff --git a/projects/adp1050/Makefile b/projects/adp1050/Makefile index ea22697a376..b5686d677dd 100644 --- a/projects/adp1050/Makefile +++ b/projects/adp1050/Makefile @@ -1,9 +1,9 @@ -# Select the example you want to enable by choosing y for enabling and n for disabling -BASIC_EXAMPLE = n -IIO_EXAMPLE = y +EXAMPLE ?= basic include ../../tools/scripts/generic_variables.mk +include ../../tools/scripts/examples.mk + include src.mk include ../../tools/scripts/generic.mk diff --git a/projects/adp1050/README.rst b/projects/adp1050/README.rst index dc98850bcc8..4d13945a214 100644 --- a/projects/adp1050/README.rst +++ b/projects/adp1050/README.rst @@ -158,9 +158,9 @@ In order to build the IIO project make sure you have the following configuration .. code-block:: bash - # Select the example you want to enable by choosing y for enabling and n for disabling - BASIC_EXAMPLE = n - IIO__EXAMPLE = y + # Select the example you want to build by passing one of the following to make + EXAMPLE = basic + EXAMPLE = iio_example No-OS Supported Platforms ------------------------- @@ -222,6 +222,6 @@ J2: # to delete current build make reset # to build the project - make PLATFORM=maxim TARGET=max32690 + make PLATFORM=maxim TARGET=max32690 EXAMPLE=basic # to flash the code make run diff --git a/projects/adp1050/builds.json b/projects/adp1050/builds.json index 09b5bc3f856..45c834757d6 100644 --- a/projects/adp1050/builds.json +++ b/projects/adp1050/builds.json @@ -1,10 +1,10 @@ { "maxim": { "basic_example_max32690": { - "flags" : "BASIC_EXAMPLE=y IIO_EXAMPLE=n TARGET=max32690" + "flags" : "EXAMPLE=basic TARGET=max32690" }, "iio_example_max32690": { - "flags" : "BASIC_EXAMPLE=n IIO_EXAMPLE=y TARGET=max32690" + "flags" : "EXAMPLE=iio_example TARGET=max32690" } } } diff --git a/projects/adp1050/src.mk b/projects/adp1050/src.mk index 401177d40e8..2747d75f2fc 100644 --- a/projects/adp1050/src.mk +++ b/projects/adp1050/src.mk @@ -1,16 +1,3 @@ -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_list.h \ diff --git a/projects/adp1050/src/examples/basic/basic_example.c b/projects/adp1050/src/examples/basic/basic_example.c index 18a938a5d64..6b6da6a1c3c 100644 --- a/projects/adp1050/src/examples/basic/basic_example.c +++ b/projects/adp1050/src/examples/basic/basic_example.c @@ -31,7 +31,6 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include "common_data.h" -#include "basic_example.h" #include "no_os_delay.h" #include "no_os_i2c.h" #include "no_os_print_log.h" @@ -39,7 +38,7 @@ #include "no_os_pwm.h" #include "adp1050.h" -int basic_example_main() +int example_main() { int ret; @@ -48,6 +47,14 @@ int basic_example_main() uint8_t data2[2]; uint16_t vout; + struct no_os_uart_desc *uart_desc; + + ret = no_os_uart_init(&uart_desc, &adp1050_uart_ip); + if (ret) + return ret; + + no_os_uart_stdio(uart_desc); + ret = adp1050_init(&adp1050_desc, &adp1050_ip); if (ret) goto exit; diff --git a/projects/adp1050/src/examples/basic/basic_example.h b/projects/adp1050/src/examples/basic/basic_example.h deleted file mode 100644 index 4264b72c5a0..00000000000 --- a/projects/adp1050/src/examples/basic/basic_example.h +++ /dev/null @@ -1,38 +0,0 @@ -/***************************************************************************//** - * @file basic_example.h - * @brief Basic example header file for adp1050 project. - * @author Radu Sabau (radu.sabau@analog.com) -******************************************************************************** - * Copyright 2024(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/adp1050/src/examples/examples_src.mk b/projects/adp1050/src/examples/examples_src.mk deleted file mode 100644 index cd3bef49b0a..00000000000 --- a/projects/adp1050/src/examples/examples_src.mk +++ /dev/null @@ -1,28 +0,0 @@ -ifeq (y,$(strip $(IIO_EXAMPLE))) -IIOD=y -CFLAGS += -DIIO_EXAMPLE -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 -SRCS += $(PROJECT)/src/examples/basic/basic_example.c -INCS += $(PROJECT)/src/examples/basic/basic_example.h -endif - -ifeq (y, $(strip $(IIOD))) -LIBRARIES += iio -SRCS += $(NO-OS)/iio/iio_app/iio_app.c \ - $(DRIVERS)/power/adp1050/iio_adp1050.c \ - $(NO-OS)/iio/iio.c \ - $(NO-OS)/iio/iiod.c \ - $(NO-OS)/util/no_os_fifo.c - -INCS += $(NO-OS)/iio/iio_app/iio_app.h \ - $(DRIVERS)/power/adp1050/iio_adp1050.h \ - $(NO-OS)/iio/iio.h \ - $(NO-OS)/iio/iiod.h \ - $(NO-OS)/iio/iio_types.h \ - $(NO-OS)/include/no_os_fifo.h -endif diff --git a/projects/adp1050/src/examples/iio_example/iio_example.c b/projects/adp1050/src/examples/iio_example/iio_example.c index 044ed5a9302..6c5cba3c1a6 100644 --- a/projects/adp1050/src/examples/iio_example/iio_example.c +++ b/projects/adp1050/src/examples/iio_example/iio_example.c @@ -30,13 +30,12 @@ * 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 "iio_adp1050.h" #include "common_data.h" #include "no_os_print_log.h" #include "iio_app.h" -int iio_example_main() +int example_main() { int ret; diff --git a/projects/adp1050/src/examples/iio_example/iio_example.h b/projects/adp1050/src/examples/iio_example/iio_example.h deleted file mode 100644 index 2a78314f495..00000000000 --- a/projects/adp1050/src/examples/iio_example/iio_example.h +++ /dev/null @@ -1,38 +0,0 @@ -/***************************************************************************//** - * @file iio_example.h - * @brief IIO example header file for adp1050 project. - * @author Radu Sabau (radu.sabau@analog.com) -******************************************************************************** - * Copyright 2024(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__ - -int iio_example_main(); - -#endif /* __IIO_EXAMPLE_H__ */ diff --git a/projects/adp1050/src/examples/iio_example/iio_example.mk b/projects/adp1050/src/examples/iio_example/iio_example.mk new file mode 100644 index 00000000000..ecc4310a1a8 --- /dev/null +++ b/projects/adp1050/src/examples/iio_example/iio_example.mk @@ -0,0 +1,3 @@ +IIOD = y +SRCS += $(DRIVERS)/power/adp1050/iio_adp1050.c +INCS += $(DRIVERS)/power/adp1050/iio_adp1050.h \ No newline at end of file diff --git a/projects/adp1050/src/platform/maxim/main.c b/projects/adp1050/src/platform/maxim/main.c index 98a193918df..81cd1b3ed22 100644 --- a/projects/adp1050/src/platform/maxim/main.c +++ b/projects/adp1050/src/platform/maxim/main.c @@ -34,39 +34,9 @@ #include "common_data.h" #include "no_os_error.h" -#ifdef BASIC_EXAMPLE -#include "basic_example.h" -#endif - -#ifdef IIO_EXAMPLE -#include "iio_example.h" -#endif +extern int example_main(); int main() { - int ret = -EINVAL; - -#ifdef BASIC_EXAMPLE - struct no_os_uart_desc *uart_desc; - - ret = no_os_uart_init(&uart_desc, &adp1050_uart_ip); - if (ret) - return ret; - - no_os_uart_stdio(uart_desc); - ret = basic_example_main(); -#endif - -#ifdef IIO_EXAMPLE - ret = iio_example_main(); -#endif - -#if (BASIC_EXAMPLE + IIO_EXAMPLE == 0) -#error At least one example has to be selected using y value in Makefile. -#elif (BASIC_EXAMPLE + IIO_EXAMPLE > 1) -#error Selected example projects cannot be enabled at the same time. \ -Please enable only one example and rebuild the project. -#endif - - return ret; + return example_main(); } diff --git a/projects/adp1050/src/platform/maxim/parameters.h b/projects/adp1050/src/platform/maxim/parameters.h index d6c0363ffa7..976f2d18e32 100644 --- a/projects/adp1050/src/platform/maxim/parameters.h +++ b/projects/adp1050/src/platform/maxim/parameters.h @@ -39,9 +39,7 @@ #include "maxim_uart.h" #include "maxim_uart_stdio.h" -#ifdef IIO_SUPPORT #define INTC_DEVICE_ID 0 -#endif #define UART_DEVICE_ID 0 #define UART_BAUDRATE 57600 diff --git a/projects/adp1050/src/platform/platform_includes.h b/projects/adp1050/src/platform/platform_includes.h deleted file mode 100644 index d989f4e7bda..00000000000 --- a/projects/adp1050/src/platform/platform_includes.h +++ /dev/null @@ -1,40 +0,0 @@ -/***************************************************************************//** - * @file platform_includes.h - * @brief Includes for used platforms used by adp1050 project. - * @author Radu Sabau (radu.sabau@analog.com) -******************************************************************************** - * Copyright 2024(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__ - -#ifdef MAXIM_PLATFORM -#include "maxim/parameters.h" -#endif - -#endif /* __PLATFORM_INCLUDES_H__ */