diff --git a/drivers/net/adin1110/adin1110.c b/drivers/net/adin1110/adin1110.c index 3f0bf133886..c298b37deb8 100644 --- a/drivers/net/adin1110/adin1110.c +++ b/drivers/net/adin1110/adin1110.c @@ -918,25 +918,6 @@ int adin1110_init(struct adin1110_desc **desc, if (ret) goto free_spi; - ret = adin1110_mdio_write_c45(descriptor, 0x1, 0x1E, 0x8C56, 0x00F0); - if (ret) - return ret; - - ret = adin1110_mdio_read_c45(descriptor, 0x1, 0x1E, 0x8C82, &led_ctrl); - if (ret) - return ret; - - led_ctrl &= ~NO_OS_GENMASK(12, 8); - led_ctrl |= no_os_field_prep(NO_OS_GENMASK(12, 8), 0x3); - - ret = adin1110_mdio_write_c45(descriptor, 0x1, 0x1E, 0x8C82, led_ctrl); - if (ret) - return ret; - - ret = adin1110_mdio_read_c45(descriptor, 0x1, 0x1E, 0x8C82, &led_ctrl); - if (ret) - return ret; - *desc = descriptor; return 0; @@ -974,4 +955,4 @@ int adin1110_remove(struct adin1110_desc *desc) free(desc); return 0; -} \ No newline at end of file +} diff --git a/projects/swiot/Makefile b/projects/swiot/Makefile index 053b0381ece..ef47e767674 100644 --- a/projects/swiot/Makefile +++ b/projects/swiot/Makefile @@ -5,7 +5,6 @@ IIO_TRIGGER_EXAMPLE = n PLATFORM = maxim TARGET = max32650 -LIBRARIES += maxq1065_lib LIBRARIES += lwip include ../../tools/scripts/generic_variables.mk @@ -18,7 +17,6 @@ CFLAGS += -DMXQ_ON_NO_OS # CFLAGS += -DNO_OS_NETWORKING CFLAGS += -DNO_OS_LWIP_NETWORKING CFLAGS += -DEXT_FLASH_MX25 -CFLAGS += -DNO_OS_STATIC_IP +# CFLAGS += -DNO_OS_STATIC_IP CFLAGS += -DIIO_IGNORE_BUFF_OVERRUN_ERR -# CFLAGS += -l$(NO-OS)/projects/ad74413r/libmaxq1065_api.a diff --git a/projects/swiot/src/common/swiot.c b/projects/swiot/src/common/swiot.c index f267a05f4b6..33d4cfef3ef 100644 --- a/projects/swiot/src/common/swiot.c +++ b/projects/swiot/src/common/swiot.c @@ -10,7 +10,6 @@ #include "no_os_delay.h" #include "iio_ad74413r.h" #include "iio_max14906.h" -#include "adc.h" #include "flc.h" #include "mxc_sys.h" @@ -340,23 +339,6 @@ static int swiot_read_id(void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv) { - // volatile uint32_t *access_ctrl = (uint32_t *)0x40029040; - // size_t length = 0; - // uint32_t usn; - - // MXC_FLC_UnlockInfoBlock(MXC_INFO_MEM_BASE); - - // usn = no_os_field_get(NO_OS_GENMASK(31, 15), *(uint32_t *)0x10800000); - // length += sprintf(buf, "%x-", usn); - // usn = no_os_field_get(NO_OS_GENMASK(30, 0), *(uint32_t *)0x10800004); - // length += sprintf(buf + length, "%x-", usn); - // usn = no_os_field_get(NO_OS_GENMASK(31, 15), *(uint32_t *)0x10800008); - // length += sprintf(buf + length, "%x-", usn); - // usn = no_os_field_get(NO_OS_GENMASK(30, 0), *(uint32_t *)0x1080000C); - // length += sprintf(buf + length, "%x-", usn); - // usn = no_os_field_get(NO_OS_GENMASK(22, 15), *(uint32_t *)0x10800010); - // length += sprintf(buf + length, "%x", usn); - size_t length = 0; uint8_t usn[13]; int ret; @@ -373,58 +355,6 @@ static int swiot_read_id(void *dev, char *buf, uint32_t len, return length; } -static int swiot_adc_read_raw(void *dev, char *buf, uint32_t len, - const struct iio_ch_info *channel, - intptr_t priv) -{ - mxc_adc_conversion_req_t req = { - .scale = MXC_ADC_SCALE_1, - }; - - uint16_t adc_val; - int32_t val; - int ret; - - switch (priv) - { - case 0: - req.channel = MXC_ADC_CH_VCORE; - break; - case 1: - req.channel = MXC_ADC_CH_VDDIOH_DIV4; - break; - default: - return -EINVAL; - } - - ret = MXC_ADC_Convert(&req); - if (ret) - return ret; - - return iio_format_value(buf, len, IIO_VAL_INT, 1, (int32_t *)&req.rawADCValue); -} - -static int swiot_adc_read_scale(void *dev, char *buf, uint32_t len, - const struct iio_ch_info *channel, - intptr_t priv) -{ - int32_t val; - - switch (priv) { - case 0: - val = 0; - break; - case 1: - val = 4; - break; - default: - return -EINVAL; - } - - return iio_format_value(buf, len, IIO_VAL_INT, 1, &val); -} - - static struct iio_attribute swiot_attrs[] = { { .name = "reset", @@ -566,56 +496,7 @@ static struct iio_attribute swiot_attrs[] = { END_ATTRIBUTES_ARRAY }; -static struct iio_attribute swiot_vcore_attrs[] = { - { - .name = "raw", - .show = swiot_adc_read_raw, - .priv = 0, - }, - { - .name = "scale", - .show = swiot_adc_read_scale, - .priv = 0, - }, - END_ATTRIBUTES_ARRAY -}; - -static struct iio_attribute swiot_vddioh_attrs[] = { - { - .name = "raw", - .show = swiot_adc_read_raw, - .priv = 1, - }, - { - .name = "scale", - .show = swiot_adc_read_scale, - .priv = 1, - }, - END_ATTRIBUTES_ARRAY -}; - -static const struct iio_channel swiot_chan[2] = { - { - .name = "v_core", - .ch_type = IIO_VOLTAGE, - .channel = 0, - .ch_out = false, - .indexed = 1, - .attributes = swiot_vcore_attrs, - }, - { - .name = "vddioh", - .ch_type = IIO_VOLTAGE, - .channel = 1, - .ch_out = false, - .indexed = 1, - .attributes = swiot_vddioh_attrs, - }, -}; - static const struct iio_device swiot_iio_dev = { - // .channels = swiot_chan, - // .num_ch = 2, .attributes = swiot_attrs, }; diff --git a/projects/swiot/src/examples/dummy/dummy_example.c b/projects/swiot/src/examples/dummy/dummy_example.c deleted file mode 100644 index 6e4fdf08384..00000000000 --- a/projects/swiot/src/examples/dummy/dummy_example.c +++ /dev/null @@ -1,262 +0,0 @@ -/***************************************************************************//** - * @file dummy_example.c - * @brief DUMMY example header for ad74413r project - * @author Ciprian Regus (ciprian.regus@analog.com) -******************************************************************************** - * Copyright 2022(c) Analog Devices, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - 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. - * - 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. - * - The use of this software may or may not infringe the patent rights - * of one or more patent holders. This license does not release you - * from the requirement that you obtain separate licenses from these - * patent holders to use this software. - * - Use of the software either in source or binary form, must be run - * on or directly connected to an Analog Devices Inc. component. - * - * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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 Files **********************************/ -/******************************************************************************/ -#include "dummy_example.h" -#include "common_data.h" -#include "ad74413r.h" -#include "no_os_delay.h" -#include "no_os_print_log.h" - -#include "adin1110.h" -#include "no_os_gpio.h" - -uint8_t eth_frame[] = { - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, - 0x11, 0x11, -}; - -uint8_t eth_rx_buff[ADIN1110_BUFF_LEN]; - -/******************************************************************************/ -/************************ Functions Declarations ******************************/ -/******************************************************************************/ -/***************************************************************************//** - * @brief Dummy 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 dummy_example_main() -{ - uint32_t ucast_frame_rx_cnt; - uint32_t bcast_frame_rx_cnt; - uint32_t mcast_frame_rx_cnt; - uint32_t ucast_frame_tx_cnt; - uint32_t bcast_frame_tx_cnt; - uint32_t mcast_frame_tx_cnt; - size_t i; - int ret; - - struct max_gpio_init_param reset_gpio_extra = { - .vssel = MXC_GPIO_VSSEL_VDDIOH, - }; - struct no_os_gpio_init_param reset_gpio_ip = { - .port = 0, - .number = 19, - .pull = NO_OS_PULL_UP, - .platform_ops = &max_gpio_ops, - .extra = &reset_gpio_extra, - }; - struct adin1110_init_param adin1110_ip = { - .chip_type = ADIN1110, - .comm_param = adin1110_spi_ip, - .reset_param = reset_gpio_ip, - .mac_address = {0xCA, 0x2F, 0xB7, 0x10, 0x23, 0x63}, - .append_crc = false, - }; - struct adin1110_desc *adin1110; - struct adin1110_eth_buff eth_tx_buff = { - .mac_dest = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,}, - .mac_source = {0xCA, 0x2F, 0xB7, 0x10, 0x23, 0x63}, - .ethertype = 0x0800, - .payload_len = NO_OS_ARRAY_SIZE(eth_frame), - .payload = eth_frame - }; - - struct adin1110_eth_buff eth_rx = { - .payload = eth_rx_buff - }; - - ret = adin1110_init(&adin1110, &adin1110_ip); - if (ret) - return ret; - - ret = adin1110_set_promisc(adin1110, 0, true); - if (ret) - return ret; - - while (1) { - /* Clear the screen */ - printf("%c",27); - printf("%c",'['); - printf("%c",'2'); - printf("%c",'J'); - - ret = adin1110_reg_read(adin1110, ADIN1110_TX_UCAST_CNT_REG, - &ucast_frame_tx_cnt); - if (ret) - goto error; - - ret = adin1110_reg_read(adin1110, ADIN1110_TX_BCAST_CNT_REG, - &bcast_frame_tx_cnt); - if (ret) - goto error; - - ret = adin1110_reg_read(adin1110, ADIN1110_TX_MCAST_CNT_REG, - &mcast_frame_tx_cnt); - if (ret) - goto error; - - ret = adin1110_reg_read(adin1110, ADIN1110_RX_UCAST_CNT_REG, - &ucast_frame_rx_cnt); - if (ret) - goto error; - - ret = adin1110_reg_read(adin1110, ADIN1110_RX_BCAST_CNT_REG, - &bcast_frame_rx_cnt); - if (ret) - goto error; - - ret = adin1110_reg_read(adin1110, ADIN1110_RX_MCAST_CNT_REG, - &mcast_frame_rx_cnt); - if (ret) - goto error; - - printf("TX unicast frames: %d\n", ucast_frame_tx_cnt); - printf("TX boardcast frames: %d\n", bcast_frame_tx_cnt); - printf("TX multicast frames: %d\n", mcast_frame_tx_cnt); - printf("RX unicast frames: %d\n", ucast_frame_rx_cnt); - printf("RX boardcast frames: %d\n", bcast_frame_rx_cnt); - printf("RX multicast frames: %d\n\n", mcast_frame_rx_cnt); - - ret = adin1110_write_fifo(adin1110, 0, ð_tx_buff); - if (ret) - return ret; - - ret = adin1110_read_fifo(adin1110, 0, ð_rx); - if (ret) - return ret; - - if (eth_rx.payload_len) { - printf("Received the frame:\n"); - printf("\nDestination MAC: %02X:%02X:%02X:%02X:%02X:%02X", - eth_rx.mac_dest[0], eth_rx.mac_dest[1], eth_rx.mac_dest[2], - eth_rx.mac_dest[3], eth_rx.mac_dest[4], eth_rx.mac_dest[5]); - printf("\nSource MAC: %02X:%02X:%02X:%02X:%02X:%02X", - eth_rx.mac_source[0], eth_rx.mac_source[1], eth_rx.mac_source[2], - eth_rx.mac_source[3], eth_rx.mac_source[4], eth_rx.mac_source[5]); - printf("\nEthertype: 0x%02X", eth_rx.ethertype); - printf("\n\nPayload: \n"); - for (i = 0; i < eth_rx.payload_len; i++) { - printf("0x%02X ", eth_rx.payload[i]); - if ((i + 1) % 20 == 0) - printf("\n"); - } - } - - no_os_mdelay(5000); - } - -error: - printf("Error!\n"); - adin1110_remove(adin1110); - - return 0; -} diff --git a/projects/swiot/src/examples/dummy/dummy_example.h b/projects/swiot/src/examples/dummy/dummy_example.h deleted file mode 100644 index fe913c2569e..00000000000 --- a/projects/swiot/src/examples/dummy/dummy_example.h +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************//** - * @file dummy_example.h - * @brief DUMMY example header for ad74413r project - * @author Ciprian Regus (ciprian.regus@analog.com) -******************************************************************************** - * Copyright 2022(c) Analog Devices, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - 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. - * - 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. - * - The use of this software may or may not infringe the patent rights - * of one or more patent holders. This license does not release you - * from the requirement that you obtain separate licenses from these - * patent holders to use this software. - * - Use of the software either in source or binary form, must be run - * on or directly connected to an Analog Devices Inc. component. - * - * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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 __DUMMY_EXAMPLE_H__ -#define __DUMMY_EXAMPLE_H__ - -/******************************************************************************/ -/***************************** Include Files **********************************/ -/******************************************************************************/ - -/******************************************************************************/ -/************************ Functions Declarations ******************************/ -/******************************************************************************/ -int dummy_example_main(); - -#endif /* __DUMMY_EXAMPLE_H__ */ diff --git a/projects/swiot/src/examples/examples_src.mk b/projects/swiot/src/examples/examples_src.mk index dca213d04a4..1510a9d8bc5 100644 --- a/projects/swiot/src/examples/examples_src.mk +++ b/projects/swiot/src/examples/examples_src.mk @@ -1,24 +1,7 @@ -ifeq (y,$(strip $(DUMMY_EXAMPLE))) -CFLAGS += -DDUMMY_EXAMPLE=1 -SRCS += $(PROJECT)/src/examples/dummy/dummy_example.c -INCS += $(PROJECT)/src/examples/dummy/dummy_example.h -endif - -ifeq (y,$(strip $(IIO_EXAMPLE))) -TINYIIOD=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 $(IIO_TRIGGER_EXAMPLE))) TINYIIOD=y -CFLAGS += -DIIO_TRIGGER_EXAMPLE=1 -SRCS += $(PROJECT)/src/examples/iio_trigger_example/iio_trigger_example.c -INCS += $(PROJECT)/src/examples/iio_trigger_example/iio_trigger_example.h -endif +SRCS += $(PROJECT)/src/examples/swiot_fw/swiot_fw.c +INCS += $(PROJECT)/src/examples/swiot_fw/swiot_fw.h -ifeq (y,$(strip $(TINYIIOD))) SRC_DIRS += $(NO-OS)/iio/iio_app INCS += $(DRIVERS)/adc-dac/ad74413r/iio_ad74413r.h @@ -36,4 +19,3 @@ SRCS += $(DRIVERS)/adc-dac/ad74413r/iio_ad74413r_trig.c INCS += $(INCLUDE)/no_os_list.h \ $(PLATFORM_DRIVERS)/$(PLATFORM)_uart.h -endif diff --git a/projects/swiot/src/examples/iio_trigger_example/iio_trigger_example.c b/projects/swiot/src/examples/iio_trigger_example/iio_trigger_example.c deleted file mode 100644 index 5fad111cd66..00000000000 --- a/projects/swiot/src/examples/iio_trigger_example/iio_trigger_example.c +++ /dev/null @@ -1,156 +0,0 @@ -/***************************************************************************//** - * @file iio_trigger_example.c - * @brief Implementation of IIO trigger example for AD74413R project. - * @author Ciprian Regus (ciprian.regus@analog.com) -******************************************************************************** - * Copyright 2022(c) Analog Devices, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - 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. - * - 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. - * - The use of this software may or may not infringe the patent rights - * of one or more patent holders. This license does not release you - * from the requirement that you obtain separate licenses from these - * patent holders to use this software. - * - Use of the software either in source or binary form, must be run - * on or directly connected to an Analog Devices Inc. component. - * - * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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 Files **********************************/ -/******************************************************************************/ -#include "common_data.h" -#include "iio_trigger_example.h" -#include "iio_ad74413r.h" -#include "no_os_util.h" - -/******************************************************************************/ -/********************** Macros and Constants Definitions **********************/ -/******************************************************************************/ -#define DATA_BUFFER_SIZE 400 - -/******************************************************************************/ -/************************ Variable Declarations *******************************/ -/******************************************************************************/ -uint8_t iio_data_buffer[DATA_BUFFER_SIZE * 8 * sizeof(uint32_t)]; - -/******************************************************************************/ -/************************ Functions Definitions *******************************/ -/******************************************************************************/ -/****************************************************************************** - * @brief IIO trigger example main execution. - * - * @return ret - Result of the example execution. If working correctly, will - * execute continuously function iio_app_run_with_trigs and will - * not return. -*******************************************************************************/ -int iio_trigger_example_main() -{ - int ret; - struct iio_hw_trig *ad74413r_trig_desc; - struct no_os_irq_ctrl_desc *ad74413r_irq_desc; - struct iio_app_desc *app; - struct iio_app_init_param app_init_param = { 0 }; - - struct ad74413r_iio_desc *ad74413r_iio_desc; - struct ad74413r_iio_desc_init_param ad74413r_iio_ip; - struct iio_data_buffer buff = { - .buff = (void *)iio_data_buffer, - .size = DATA_BUFFER_SIZE * sizeof(uint32_t) * 8 - }; - struct ad74413r_init_param ad74413r_ip = { - .chip_id = AD74412R, - .comm_param = ad74413r_spi_ip - }; - - ad74413r_iio_ip.ad74413r_init_param = &ad74413r_ip; - ad74413r_iio_ip.channel_configs[0] = (struct ad74413r_channel_config) { - .enabled = true, - .function = AD74413R_DIGITAL_INPUT - }; - ad74413r_iio_ip.channel_configs[1] = (struct ad74413r_channel_config) { - .enabled = true, - .function = AD74413R_VOLTAGE_IN - }; - ad74413r_iio_ip.channel_configs[2] = (struct ad74413r_channel_config) { - .enabled = true, - .function = AD74413R_VOLTAGE_OUT - }; - ad74413r_iio_ip.channel_configs[3] = (struct ad74413r_channel_config) { - .enabled = true, - .function = AD74413R_CURRENT_IN_EXT - }; - - ret = ad74413r_iio_init(&ad74413r_iio_desc, &ad74413r_iio_ip); - if (ret) - return ret; - - /* Initialize interrupt controller */ - ret = no_os_irq_ctrl_init(&ad74413r_irq_desc, &ad74413r_gpio_irq_ip); - if (ret) - return ret; - - ret = no_os_irq_set_priority(ad74413r_irq_desc, ad74413r_gpio_trig_ip.irq_id, - 1); - if (ret) - return ret; - - ad74413r_gpio_trig_ip.irq_ctrl = ad74413r_irq_desc; - - /* Initialize hardware trigger */ - ret = iio_hw_trig_init(&ad74413r_trig_desc, &ad74413r_gpio_trig_ip); - if (ret) - return ret; - - struct iio_app_device iio_devices[] = { - { - .name = "ad74413r", - .dev = ad74413r_iio_desc, - .dev_descriptor = ad74413r_iio_desc->iio_dev, - .read_buff = &buff, - } - }; - - struct iio_trigger_init trigs[] = { - IIO_APP_TRIGGER(AD74413R_GPIO_TRIG_NAME, ad74413r_trig_desc, - &ad74413r_iio_trig_desc) - }; - - app_init_param.devices = iio_devices; - app_init_param.nb_devices = NO_OS_ARRAY_SIZE(iio_devices); - app_init_param.uart_init_params = ad74413r_uart_ip; - app_init_param.trigs = trigs; - app_init_param.nb_trigs = NO_OS_ARRAY_SIZE(trigs); - app_init_param.irq_desc = ad74413r_irq_desc; - - ret = iio_app_init(&app, app_init_param); - if (ret) - return ret; - - // update the reference to iio_desc - ad74413r_trig_desc->iio_desc = app->iio_desc; - - return iio_app_run(app); - -} diff --git a/projects/swiot/src/examples/iio_trigger_example/iio_trigger_example.h b/projects/swiot/src/examples/iio_trigger_example/iio_trigger_example.h deleted file mode 100644 index 3dd7d00730d..00000000000 --- a/projects/swiot/src/examples/iio_trigger_example/iio_trigger_example.h +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************//** - * @file iio_trigger_example.h - * @brief IIO trigger example header for AD74413R project - * @author Ciprian Regus (ciprian.regus@analog.com) -******************************************************************************** - * Copyright 2022(c) Analog Devices, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - 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. - * - 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. - * - The use of this software may or may not infringe the patent rights - * of one or more patent holders. This license does not release you - * from the requirement that you obtain separate licenses from these - * patent holders to use this software. - * - Use of the software either in source or binary form, must be run - * on or directly connected to an Analog Devices Inc. component. - * - * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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_TRIGGER_EXAMPLE_H__ -#define __IIO_TRIGGER_EXAMPLE_H__ - -/******************************************************************************/ -/***************************** Include Files **********************************/ -/******************************************************************************/ - -/******************************************************************************/ -/************************ Functions Declarations ******************************/ -/******************************************************************************/ -int iio_trigger_example_main(); - -#endif /* __IIO_EXAMPLE_H__ */ diff --git a/projects/swiot/src/examples/iio_example/iio_example.c b/projects/swiot/src/examples/swiot_fw/swiot_fw.c similarity index 63% rename from projects/swiot/src/examples/iio_example/iio_example.c rename to projects/swiot/src/examples/swiot_fw/swiot_fw.c index 83c09c1f845..968a2834d2f 100644 --- a/projects/swiot/src/examples/iio_example/iio_example.c +++ b/projects/swiot/src/examples/swiot_fw/swiot_fw.c @@ -45,11 +45,10 @@ #include #include -#include "iio_example.h" +#include "swiot_fw.h" #include "iio_ad74413r.h" #include "iio_max14906.h" #include "iio_adt75.h" -#include "maxq1065.h" #include "swiot.h" #include "common_data.h" #include "no_os_util.h" @@ -69,19 +68,11 @@ #include "lwip_socket.h" #include "lwip_adin1110.h" -#include "lwip/apps/lwiperf.h" - -#include "hpb.h" -#include "Ext_Flash.h" -#include "spixf.h" -#include "adc.h" - /******************************************************************************/ /********************** Macros and Constants Definitions **********************/ /******************************************************************************/ #define DATA_BUFFER_SIZE 1000 #define IIO_IGNORE_BUFF_OVERRUN_ERR -#define EXT_FLASH_BAUD 1000000 /******************************************************************************/ /************************ Variable Declarations ******************************/ @@ -92,33 +83,6 @@ uint8_t iio_data_buffer2[100 * sizeof(uint32_t) * 8]; uint8_t iio_data_buffer3[100 * sizeof(uint32_t) * 8]; uint8_t iio_data_buffer4[100 * sizeof(uint32_t) * 8]; -static bool flash_test = false; -static bool ram1_test = false; -static bool ram2_test = false; - -extern int ad74413r_apply; -extern int max14906_apply; -extern int ad74413r_back; -extern int max14906_back; - -extern unsigned int __HeapBase; -extern unsigned int __HeapLimit; - -extern uint8_t __load_start_hpb_cs0; -extern uint8_t __load_length_hpb_cs0; -extern uint8_t __load_start_hpb_cs1; -extern uint8_t __load_length_hpb_cs1; -extern uint8_t __hpb_cs0_start; -extern uint8_t __hpb_cs1_start; -extern uint8_t __load_start_xip; -extern uint8_t __load_length_xip; - -const mxc_spixf_cfg_t mx25_spixc_cfg = { - .mode = 0, - .ssel_pol = 0, - .hz = EXT_FLASH_BAUD, -}; - /******************************************************************************/ /************************ Functions Definitions *******************************/ /******************************************************************************/ @@ -147,111 +111,19 @@ int step_callback(void *arg) return 0; } -void spixf_cfg_setup() -{ - // Disable the SPIXFC before setting the SPIXF - MXC_SPIXF_Disable(); - MXC_SPIXF_SetSPIFrequency(EXT_FLASH_BAUD); - MXC_SPIXF_SetMode(MXC_SPIXF_MODE_0); - MXC_SPIXF_SetSSPolActiveLow(); - MXC_SPIXF_SetSSActiveTime(MXC_SPIXF_SYS_CLOCKS_2); - MXC_SPIXF_SetSSActiveTime(MXC_SPIXF_SYS_CLOCKS_3); - - MXC_SPIXF_SetCmdValue(EXT_FLASH_CMD_QREAD); - MXC_SPIXF_SetCmdWidth(MXC_SPIXF_SINGLE_SDIO); - MXC_SPIXF_SetAddrWidth(MXC_SPIXF_QUAD_SDIO); - MXC_SPIXF_SetDataWidth(MXC_SPIXF_WIDTH_4); - MXC_SPIXF_SetModeClk(EXT_FLASH_QREAD_DUMMY); - - MXC_SPIXF_Set3ByteAddr(); - MXC_SPIXF_SCKFeedbackEnable(); - MXC_SPIXF_SetSCKNonInverted(); -} - -static int ext_flash_board_init(void) -{ - return MXC_SPIXF_Init(0, EXT_FLASH_BAUD); -} - -// static int pmod_test() -// { -// struct no_os_gpio_desc *pmod_sclk_gpio; -// struct no_os_gpio_desc *pmod_mosi_gpio; -// struct no_os_gpio_desc *pmod_miso_gpio; -// struct no_os_gpio_desc *pmod_cs_gpio; -// int ret; - -// no_os_gpio_get(&pmod_sclk_gpio, pmod_sclk_ip); -// no_os_gpio_get(&pmod_mosi_gpio, &pmod_mosi_ip); -// no_os_gpio_get(&pmod_miso_gpio, &pmod_miso_ip); -// no_os_gpio_get(&pmod_cs_gpio, &pmod_cs_ip); - - -// } - -/******************************************************************************/ -static int ext_flash_board_read(uint8_t* read, unsigned len, unsigned deassert, - Ext_Flash_DataLine_t width) -{ - mxc_spixf_req_t req = {deassert, 0, NULL, read, (mxc_spixf_width_t)width, len, 0, 0, NULL}; - - if (MXC_SPIXF_Transaction(&req) != len) { - return E_COMM_ERR; - } - return E_NO_ERROR; -} - -/******************************************************************************/ -static int ext_flash_board_write(const uint8_t* write, unsigned len, - unsigned deassert, - Ext_Flash_DataLine_t width) -{ - mxc_spixf_req_t req = {deassert, 0, write, NULL, (mxc_spixf_width_t)width, len, 0, 0, NULL}; - - if (MXC_SPIXF_Transaction(&req) != len) { - return E_COMM_ERR; - } - return E_NO_ERROR; -} - -/******************************************************************************/ -static int ext_flash_clock(unsigned len, unsigned deassert) -{ - return MXC_SPIXF_Clocks(len, deassert); -} - -__attribute__((section(".hpb_cs0_section"))) void test_func1(void) -{ - ram1_test = true; -} - -__attribute__((section(".hpb_cs1_section"))) void test_func2(void) -{ - ram2_test = true; -} - -__attribute__((section(".xip_section"))) void flash_test_func(void) -{ - flash_test = true; -} - /***************************************************************************//** * @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 swiot_firmware() { struct tcp_pcb *pcb; uint32_t client_id; uint8_t adin1110_mac_address[6] = {0x00, 0x18, 0x80, 0x03, 0x25, 0x60}; - mxc_hpb_mem_config_t mem; - mxc_hpb_mem_config_t mem2; - mxc_hpb_cfg_reg_val_t cfg_reg[1]; - int ret; uint32_t reg_val; uint32_t ndev; @@ -287,6 +159,7 @@ int iio_example_main() struct no_os_gpio_desc *swiot_led2_gpio; struct maxq1065_desc *maxq1065; struct iio_app_desc *app; + struct iio_data_buffer buff = { .buff = (void *)iio_data_buffer, .size = DATA_BUFFER_SIZE * sizeof(uint32_t) * 8, @@ -342,13 +215,6 @@ int iio_example_main() .crc_en = true, }; - // struct netif *netif_desc; - // struct max_eth_desc *eth_desc; - // struct max_eth_param eth_param = { - // .name = "e7", - // .adin1110_ip = adin1110_ip, - // }; - struct no_os_irq_ctrl_desc *ad74413r_nvic; struct no_os_irq_init_param ad74413r_nvic_ip = { .irq_ctrl_id = 0, @@ -367,148 +233,6 @@ int iio_example_main() no_os_gpio_get(&swiot_led1_gpio, &swiot_led1_ip); no_os_gpio_get(&swiot_led2_gpio, &swiot_led2_ip); - printf("UART test: PASSED\n"); - - ret = maxq1065_init(&maxq1065, &maxq1065_ip); - if (ret) - return ret; - - printf("MAXQ1065 ping: PASSED\n"); - - // no_os_gpio_get(&tx_gpio, &tx_perf_gpio_ip); - // no_os_gpio_get(&rx_gpio, &rx_perf_gpio_ip); - // no_os_gpio_direction_output(tx_gpio, 0); - // no_os_gpio_direction_output(rx_gpio, 0); - - cfg_reg[0].addr = 0x01000; - cfg_reg[0].val = 0x801f; - mem.base_addr = (unsigned int)&__hpb_cs0_start; - mem.device_type = MXC_HPB_DEV_HYPER_RAM; - mem.cfg_reg_val = cfg_reg; - mem.cfg_reg_val_len = 1; - mem.read_cs_high = MXC_HPB_CS_HIGH_10_5; - mem.write_cs_high = MXC_HPB_CS_HIGH_10_5; - mem.read_cs_setup = MXC_HPB_CS_SETUP_HOLD_16; - mem.write_cs_setup = MXC_HPB_CS_SETUP_HOLD_14; - mem.read_cs_hold = MXC_HPB_CS_SETUP_HOLD_5; - mem.write_cs_hold = MXC_HPB_CS_SETUP_HOLD_12; - mem.latency_cycle = MXC_V_HPB_MTR_LATENCY_6CLK; - mem.fixed_latency = 0; - - mem2.base_addr = (unsigned int)&__hpb_cs1_start; - mem2.device_type = MXC_HPB_DEV_HYPER_RAM; - mem2.cfg_reg_val = cfg_reg; - mem2.cfg_reg_val_len = 1; - mem2.read_cs_high = MXC_HPB_CS_HIGH_10_5; - mem2.write_cs_high = MXC_HPB_CS_HIGH_10_5; - mem2.read_cs_setup = MXC_HPB_CS_SETUP_HOLD_16; - mem2.write_cs_setup = MXC_HPB_CS_SETUP_HOLD_14; - mem2.read_cs_hold = MXC_HPB_CS_SETUP_HOLD_5; - mem2.write_cs_hold = MXC_HPB_CS_SETUP_HOLD_12; - mem2.latency_cycle = MXC_V_HPB_MTR_LATENCY_6CLK; - mem2.fixed_latency = 0; - - // memset(0x68000000, 0xA9, 10000000); - // memset(0x78000000, 0xAF, 10000000); - ret = MXC_HPB_Init(&mem, &mem2); - // memset(0x68000000, 0xA8, 10000000); - // memset(0x78000000, 0xA0, 10000000); - // memset(0x98000000, 0xAF, 100); - - // volatile uint8_t *ram_addr = (volatile uint8_t *)0x68000000; - // volatile uint8_t a = *(ram_addr + 7000000); - - memcpy(&__hpb_cs0_start, &__load_start_hpb_cs0, - (uint32_t)&__load_length_hpb_cs0); - memcpy(&__hpb_cs1_start, &__load_start_hpb_cs1, - (uint32_t)&__load_length_hpb_cs1); - void (*func_ram1)(void); - void (*func_ram2)(void); - - func_ram1 = (void(*)(void))((uint32_t)&__hpb_cs0_start | 1); - func_ram2 = (void(*)(void))((uint32_t)&__hpb_cs1_start | 1); - func_ram1(); - func_ram2(); - - // *ram_addr = 0xA3; - // a = *ram_addr; - - Ext_Flash_Config_t exf_cfg = {.init = ext_flash_board_init, - .read = ext_flash_board_read, - .write = ext_flash_board_write, - .clock = ext_flash_clock - }; - - ret = Ext_Flash_Configure(&exf_cfg); - if (ret) - return ret; - - Ext_Flash_Init(); - Ext_Flash_Reset(); - uint32_t flash_id = Ext_Flash_ID(); - Ext_Flash_Erase(0x00000, Ext_Flash_Erase_64K); - ret = Ext_Flash_Quad(1); - if (ret) - return ret; - - - // uint8_t flash_val[3] = {0x12, 0x34, 0xFA}; - // uint8_t flash_readback[10] = {0x0}; - - // ret = Ext_Flash_Program_Page(0xF, flash_val, 3, Ext_Flash_DataLine_Quad); - // ret = Ext_Flash_Program_Page(0xF, flash_readback, 3, Ext_Flash_DataLine_Single); - - // ret = Ext_Flash_Read(0x0, flash_readback, 10, Ext_Flash_DataLine_Single); - ret = Ext_Flash_Program_Page(0x0, &__load_start_xip, - (uint32_t)(&__load_length_xip), Ext_Flash_DataLine_Single); - // if (ret) - // return ret; - // ret = Ext_Flash_Read(0x0, flash_readback, 10, Ext_Flash_DataLine_Single); - - spixf_cfg_setup(); - - // *((uint8_t *)0x08000000) = 0xFE; - // ret = Ext_Flash_Program_Page(0x0, flash_val, 3, Ext_Flash_DataLine_Quad); - // ret = Ext_Flash_Read(0x0, flash_readback, 3, Ext_Flash_DataLine_Single); - // flash_val[2] = 0xFE; - // ret = Ext_Flash_Program_Page(0x0, flash_val, 3, Ext_Flash_DataLine_Quad); - // ret = Ext_Flash_Read(0x0, flash_readback, 3, Ext_Flash_DataLine_Single); - // ret = Ext_Flash_Read(0x0, flash_readback, 3, Ext_Flash_DataLine_Single); - // ret = Ext_Flash_Read(0x0, flash_readback, 3, Ext_Flash_DataLine_Single); - // ret = Ext_Flash_Read(0x0, flash_readback, 3, Ext_Flash_DataLine_Single); - // ret = Ext_Flash_Read(0x0, flash_readback, 3, Ext_Flash_DataLine_Single); - - func_ram1 = (void(*)(void))((uint32_t)&__load_start_xip); - func_ram1(); - - // ret = Ext_Flash_Program_Page(0xF, flash_val, 3, Ext_Flash_DataLine_Quad); - // volatile uint8_t a = *((uint8_t *)0x08000000); - // ret = Ext_Flash_Program_Page(0x0, flash_val, 3, Ext_Flash_DataLine_Single); - // *((uint8_t *)0x08000000) = 0xFE; - // a = *((uint8_t *)0x08000000); - - // ret = Ext_Flash_Read(0xF, flash_readback, 10, Ext_Flash_DataLine_Single); - // if (ret) - // return ret; - - printf("RAM chip 1: "); - if (ram1_test) - printf("PASSED \n"); - else - printf("FAILED \n"); - - printf("RAM chip 2: "); - if (ram2_test) - printf("PASSED \n"); - else - printf("FAILED \n"); - - printf("Flash chip: "); - if (flash_test) - printf("PASSED \n"); - else - printf("FAILED \n"); - no_os_gpio_get(&max14906_d1_gpio, &max14906_d1_ip); no_os_gpio_get(&max14906_d2_gpio, &max14906_d2_ip); no_os_gpio_get(&max14906_d3_gpio, &max14906_d3_ip); @@ -545,9 +269,6 @@ int iio_example_main() memcpy(app_init_param.lwip_param.hwaddr, adin1110_mac_address, NETIF_MAX_HWADDR_LEN); - if (MXC_ADC_Init()) - return -EINVAL; - ret = no_os_irq_ctrl_init(&ad74413r_nvic, &ad74413r_nvic_ip); if (ret) return ret; @@ -638,7 +359,7 @@ int iio_example_main() sizeof(max14906_iio_ip.channel_configs)); memcpy(&ad74413r_iio_ip.channel_configs, &swiot_iio_desc->ad74413r_configs, sizeof(ad74413r_iio_ip.channel_configs)); - /* Probe the drivers in the run mode */ + ret = max14906_iio_init(&max14906_iio_desc, &max14906_iio_ip); if (!ret) { iio_devices[1].name = "max14906"; @@ -685,12 +406,10 @@ int iio_example_main() app_init_param.uart_init_params = adin1110_uart_ip; app_init_param.post_step_callback = step_callback; - no_os_gpio_set_value(swiot_led2_gpio, 1); ret = iio_app_init(&app, app_init_param); if (ret) goto error; - no_os_gpio_set_value(swiot_led2_gpio, 0); ad74413r_trig_desc->iio_desc = app->iio_desc; swiot_iio_desc->adin1110 = app->lwip_desc->mac_desc; step_p.swiot = swiot_iio_desc; diff --git a/projects/swiot/src/examples/iio_example/iio_example.h b/projects/swiot/src/examples/swiot_fw/swiot_fw.h similarity index 96% rename from projects/swiot/src/examples/iio_example/iio_example.h rename to projects/swiot/src/examples/swiot_fw/swiot_fw.h index de7fe213f69..e2ac5270c1c 100644 --- a/projects/swiot/src/examples/iio_example/iio_example.h +++ b/projects/swiot/src/examples/swiot_fw/swiot_fw.h @@ -36,8 +36,8 @@ * 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__ +#ifndef __SWIOT_FW_H__ +#define __SWIOT_FW_H__ /******************************************************************************/ /***************************** Include Files **********************************/ @@ -46,6 +46,6 @@ /******************************************************************************/ /************************ Functions Declarations ******************************/ /******************************************************************************/ -int iio_example_main(); +int swiot_firmware(); -#endif /* __IIO_EXAMPLE_H__ */ +#endif /* __SWIOT_FW_H__ */ diff --git a/projects/swiot/src/platform/maxim/main.c b/projects/swiot/src/platform/maxim/main.c index 9462b732ed4..5091baf33bc 100644 --- a/projects/swiot/src/platform/maxim/main.c +++ b/projects/swiot/src/platform/maxim/main.c @@ -45,13 +45,7 @@ #include "no_os_error.h" #include "no_os_init.h" -#ifdef DUMMY_EXAMPLE -#include "dummy_example.h" -#endif - -#ifdef IIO_EXAMPLE -#include "iio_example.h" -#endif +#include "swiot_fw.h" /***************************************************************************//** * @brief Main function execution for Maxim platform. @@ -60,43 +54,17 @@ *******************************************************************************/ int main() { - int ret = -EINVAL; - ret = no_os_init(); - if (ret) - return ret; - -#ifdef DUMMY_EXAMPLE struct no_os_uart_desc *uart_desc; + int ret; - ret = no_os_uart_init(&uart_desc, &adin1110_uart_ip); + ret = no_os_init(); if (ret) return ret; - no_os_uart_stdio(uart_desc); - ret = dummy_example_main(); -#endif - -#ifdef IIO_EXAMPLE - struct no_os_uart_desc *uart_desc; - ret = no_os_uart_init(&uart_desc, &adin1110_uart_ip); if (ret) return ret; no_os_uart_stdio(uart_desc); - ret = iio_example_main(); -#endif - -#ifdef IIO_TRIGGER_EXAMPLE - ret = iio_trigger_example_main(); -#endif - -#if (DUMMY_EXAMPLE + IIO_EXAMPLE == 0) -#error At least one example has to be selected using y value in Makefile. -#elif (DUMMY_EXAMPLE + IIO_EXAMPLE > 1) -#error Selected example projects cannot be enabled at the same time. \ -Please enable only one example and re-build the project. -#endif - - return ret; + return swiot_firmware(); } diff --git a/projects/swiot/src/platform/stm32/main.c b/projects/swiot/src/platform/stm32/main.c deleted file mode 100644 index e244f185581..00000000000 --- a/projects/swiot/src/platform/stm32/main.c +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************//** - * @file main.c - * @brief Main file for STM32 platform of ad74413r project. - * @author Ciprian Regus (ciprian.regus@analog.com) -******************************************************************************** - * Copyright 2022(c) Analog Devices, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - 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. - * - 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. - * - The use of this software may or may not infringe the patent rights - * of one or more patent holders. This license does not release you - * from the requirement that you obtain separate licenses from these - * patent holders to use this software. - * - Use of the software either in source or binary form, must be run - * on or directly connected to an Analog Devices Inc. component. - * - * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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 Files **********************************/ -/******************************************************************************/ -#include "platform_includes.h" -#include "common_data.h" -#include "no_os_error.h" -#include -#include - -#ifdef DUMMY_EXAMPLE -#include "dummy_example.h" -#endif - -#ifdef IIO_EXAMPLE -#include "iio_example.h" -#endif - -/***************************************************************************//** - * @brief Main function execution for STM32 platform. - * - * @return ret - Result of the enabled examples execution. -*******************************************************************************/ -int main() -{ - int ret = -EINVAL; - ad74413r_spi_extra_ip.get_input_clock = HAL_RCC_GetPCLK1Freq; - ad74413r_ip.comm_param = ad74413r_spi_ip; - - stm32_init(); - -#ifdef DUMMY_EXAMPLE - struct no_os_uart_desc *uart_desc; - - ret = no_os_uart_init(&uart_desc, &ad74413r_uart_ip); - if (ret) - return ret; - - no_os_uart_stdio(uart_desc); - ret = dummy_example_main(); -#endif - -#ifdef IIO_EXAMPLE - ret = iio_example_main(); -#endif - -#ifdef IIO_TRIGGER_EXAMPLE - ret = iio_trigger_example_main(); -#endif - -#if (DUMMY_EXAMPLE + IIO_EXAMPLE + IIO_TRIGGER_EXAMPLE == 0) -#error At least one example has to be selected using y value in Makefile. -#elif (DUMMY_EXAMPLE + IIO_EXAMPLE + IIO_TRIGGER_EXAMPLE > 1) -#error Selected example projects cannot be enabled at the same time. \ -Please enable only one example and re-build the project. -#endif - return ret; -} diff --git a/projects/swiot/src/platform/stm32/parameters.c b/projects/swiot/src/platform/stm32/parameters.c deleted file mode 100644 index 9b68a67539f..00000000000 --- a/projects/swiot/src/platform/stm32/parameters.c +++ /dev/null @@ -1,60 +0,0 @@ -/***************************************************************************//** - * @file parameters.c - * @brief Definition of STM32 platform data used by ad74413r project. - * @author Ciprian Regus (ciprian.regus@analog.com) -******************************************************************************** - * Copyright 2022(c) Analog Devices, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - 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. - * - 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. - * - The use of this software may or may not infringe the patent rights - * of one or more patent holders. This license does not release you - * from the requirement that you obtain separate licenses from these - * patent holders to use this software. - * - Use of the software either in source or binary form, must be run - * on or directly connected to an Analog Devices Inc. component. - * - * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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 Files **********************************/ -/******************************************************************************/ -#include "parameters.h" - -/******************************************************************************/ -/********************** Macros and Constants Definitions **********************/ -/******************************************************************************/ -struct stm32_uart_init_param ad74413r_uart_extra_ip = { - .huart = &huart3, -}; - -struct stm32_spi_init_param ad74413r_spi_extra_ip = { - .chip_select_port = SPI_CS_PORT, -}; - -#ifdef IIO_TRIGGER_EXAMPLE -struct stm32_gpio_irq_init_param ad74413r_gpio_irq_extra_ip = { - .port_nb = 6, /* Port G */ -}; -#endif diff --git a/projects/swiot/src/platform/stm32/parameters.h b/projects/swiot/src/platform/stm32/parameters.h deleted file mode 100644 index 0c8d6d75773..00000000000 --- a/projects/swiot/src/platform/stm32/parameters.h +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************//** - * @file parameters.h - * @brief Definitions specific to STM32 platform used by ad74413r - * project. - * @author Ciprian Regus (ciprian.regus@analog.com) -******************************************************************************** - * Copyright 2022(c) Analog Devices, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - 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. - * - 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. - * - The use of this software may or may not infringe the patent rights - * of one or more patent holders. This license does not release you - * from the requirement that you obtain separate licenses from these - * patent holders to use this software. - * - Use of the software either in source or binary form, must be run - * on or directly connected to an Analog Devices Inc. component. - * - * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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 Files **********************************/ -/******************************************************************************/ -#include "stm32_hal.h" -#include "stm32_irq.h" -#include "stm32_spi.h" -#include "stm32_gpio.h" -#include "stm32_uart.h" -#include "stm32_uart_stdio.h" -#include "stm32_gpio_irq.h" - -/******************************************************************************/ -/********************** Macros and Constants Definitions **********************/ -/******************************************************************************/ -extern UART_HandleTypeDef huart3; - -#ifdef IIO_SUPPORT -#define INTC_DEVICE_ID 0 -#define IIO_APP_HUART (&huart3) -#endif -#define UART_IRQ_ID USART3_IRQn - -#define UART_DEVICE_ID 3 -#define UART_BAUDRATE 115200 -#define UART_EXTRA &ad74413r_uart_extra_ip -#define UART_OPS &stm32_uart_ops - -#define SPI_DEVICE_ID 1 -#define SPI_BAUDRATE 1000000 -#define SPI_CS 14 -#define SPI_CS_PORT 3 -#define SPI_OPS &stm32_spi_ops -#define SPI_EXTRA &ad74413r_spi_extra_ip - -extern struct stm32_uart_init_param ad74413r_uart_extra_ip; -extern struct stm32_spi_init_param ad74413r_spi_extra_ip; - -#ifdef IIO_TRIGGER_EXAMPLE -extern struct stm32_gpio_irq_init_param ad74413r_gpio_irq_extra_ip; -/* Setting for PortG Pin0 used for DATA_READY. - Has to be adapted accordingly if another pin is used. - */ -#define AD74413R_GPIO_TRIG_IRQ_ID 0 /* Not used in stm32 platform */ -#define AD74413R_GPIO_CB_HANDLE NULL /* Not used in stm32 platform */ - -#define GPIO_IRQ_ID 0 /* Pin 0 */ -#define GPIO_IRQ_OPS &stm32_gpio_irq_ops -#define GPIO_IRQ_EXTRA &ad74413r_gpio_irq_extra_ip -#endif - -#endif /* __PARAMETERS_H__ */ diff --git a/projects/swiot/src/platform/stm32/platform_src.mk b/projects/swiot/src/platform/stm32/platform_src.mk deleted file mode 100644 index 58aff098920..00000000000 --- a/projects/swiot/src/platform/stm32/platform_src.mk +++ /dev/null @@ -1,16 +0,0 @@ -INCS += $(PLATFORM_DRIVERS)/stm32_delay.h \ - $(PLATFORM_DRIVERS)/stm32_gpio.h \ - $(PLATFORM_DRIVERS)/stm32_hal.h \ - $(PLATFORM_DRIVERS)/stm32_spi.h \ - $(PLATFORM_DRIVERS)/stm32_irq.h \ - $(PLATFORM_DRIVERS)/stm32_gpio_irq.h \ - $(PLATFORM_DRIVERS)/stm32_uart.h \ - $(PLATFORM_DRIVERS)/stm32_uart_stdio.h - -SRCS += $(PLATFORM_DRIVERS)/stm32_delay.c \ - $(PLATFORM_DRIVERS)/stm32_gpio.c \ - $(PLATFORM_DRIVERS)/stm32_spi.c \ - $(PLATFORM_DRIVERS)/stm32_irq.c \ - $(PLATFORM_DRIVERS)/stm32_gpio_irq.c \ - $(PLATFORM_DRIVERS)/stm32_uart.c \ - $(PLATFORM_DRIVERS)/stm32_uart_stdio.c diff --git a/tools/scripts/libraries.mk b/tools/scripts/libraries.mk index 0d7c777e6df..9288e4047ef 100644 --- a/tools/scripts/libraries.mk +++ b/tools/scripts/libraries.mk @@ -115,11 +115,6 @@ INCS += $(NO-OS)/libraries/lwip/configs/lwipcfg.h INCS += $(NO-OS)/libraries/lwip/configs/lwipopts.h endif -ifneq ($(if $(findstring maxq1065_lib, $(LIBRARIES)), 1),) -EXTRA_LIBS += /home/xvr/Downloads/no-OS/projects/swiot/maxq1065_api.a -EXTRA_LIBS_PATHS += /home/xvr/Downloads/no-OS/projects/ad74413r -endif - LIB_TARGETS += $(IIO_LIB) $(MBEDTLS_LIBS) $(FATFS_LIB) $(MQTT_LIB) $(AZURE_LIBS) EXTRA_LIBS_NAMES = $(subst lib,,$(basename $(notdir $(EXTRA_LIBS)))) LIB_FLAGS += $(addprefix -l,$(EXTRA_LIBS_NAMES))