From b9039339018e68f901c8d1277fe3aa8f6442a7c5 Mon Sep 17 00:00:00 2001 From: Marvin Neil Cabuenas Date: Tue, 28 Jan 2025 09:45:38 +0800 Subject: [PATCH] projects: ltc7841: Add project for LTC7841 Add initial project files for both basic and IIO examples for LTC7841. Signed-off-by: Marvin Neil Cabuenas --- projects/ltc7841/Makefile | 8 ++ projects/ltc7841/builds.json | 10 ++ projects/ltc7841/src.mk | 19 +++ projects/ltc7841/src/common/common_data.c | 56 ++++++++ projects/ltc7841/src/common/common_data.h | 46 +++++++ .../src/examples/basic/basic_example.c | 125 ++++++++++++++++++ .../src/examples/iio_example/iio_example.c | 80 +++++++++++ .../src/examples/iio_example/iio_example.mk | 4 + projects/ltc7841/src/platform/maxim/main.c | 42 ++++++ .../ltc7841/src/platform/maxim/parameters.c | 48 +++++++ .../ltc7841/src/platform/maxim/parameters.h | 55 ++++++++ .../src/platform/maxim/platform_src.mk | 12 ++ 12 files changed, 505 insertions(+) create mode 100644 projects/ltc7841/Makefile create mode 100644 projects/ltc7841/builds.json create mode 100644 projects/ltc7841/src.mk create mode 100644 projects/ltc7841/src/common/common_data.c create mode 100644 projects/ltc7841/src/common/common_data.h create mode 100644 projects/ltc7841/src/examples/basic/basic_example.c create mode 100644 projects/ltc7841/src/examples/iio_example/iio_example.c create mode 100644 projects/ltc7841/src/examples/iio_example/iio_example.mk create mode 100644 projects/ltc7841/src/platform/maxim/main.c create mode 100644 projects/ltc7841/src/platform/maxim/parameters.c create mode 100644 projects/ltc7841/src/platform/maxim/parameters.h create mode 100644 projects/ltc7841/src/platform/maxim/platform_src.mk diff --git a/projects/ltc7841/Makefile b/projects/ltc7841/Makefile new file mode 100644 index 00000000000..e6050cb3ef6 --- /dev/null +++ b/projects/ltc7841/Makefile @@ -0,0 +1,8 @@ +include ../../tools/scripts/generic_variables.mk + +EXAMPLE := iio_example +include ../../tools/scripts/examples.mk + +include src.mk + +include ../../tools/scripts/generic.mk diff --git a/projects/ltc7841/builds.json b/projects/ltc7841/builds.json new file mode 100644 index 00000000000..45c834757d6 --- /dev/null +++ b/projects/ltc7841/builds.json @@ -0,0 +1,10 @@ +{ + "maxim": { + "basic_example_max32690": { + "flags" : "EXAMPLE=basic TARGET=max32690" + }, + "iio_example_max32690": { + "flags" : "EXAMPLE=iio_example TARGET=max32690" + } + } +} diff --git a/projects/ltc7841/src.mk b/projects/ltc7841/src.mk new file mode 100644 index 00000000000..642a35f150d --- /dev/null +++ b/projects/ltc7841/src.mk @@ -0,0 +1,19 @@ +NO_OS_INC_DIRS += \ + $(INCLUDE) \ + $(PROJECT)/src/ \ + $(DRIVERS)/power/ltc7841 \ + +SRCS += $(NO-OS)/util/no_os_lf256fifo.c \ + $(DRIVERS)/api/no_os_i2c.c \ + $(DRIVERS)/api/no_os_dma.c \ + $(DRIVERS)/api/no_os_uart.c \ + $(DRIVERS)/api/no_os_irq.c \ + $(DRIVERS)/api/no_os_gpio.c \ + $(DRIVERS)/api/no_os_pwm.c \ + $(NO-OS)/util/no_os_util.c \ + $(NO-OS)/util/no_os_list.c \ + $(NO-OS)/util/no_os_alloc.c \ + $(NO-OS)/util/no_os_mutex.c \ + $(NO-OS)/util/no_os_crc8.c + +SRCS += $(DRIVERS)/power/ltc7841/ltc7841.c diff --git a/projects/ltc7841/src/common/common_data.c b/projects/ltc7841/src/common/common_data.c new file mode 100644 index 00000000000..d85ce3da339 --- /dev/null +++ b/projects/ltc7841/src/common/common_data.c @@ -0,0 +1,56 @@ +/***************************************************************************//** + * @file common_data.c + * @brief Defines common data to be used by ltc7841 examples. + * @author Marvin Cabuenas (marvinneil.cabuenas@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. +*******************************************************************************/ +#include "common_data.h" + +struct no_os_uart_init_param uart_ip = { + .device_id = 2, + .asynchronous_rx = false, + .baud_rate = 115200, + .size = NO_OS_UART_CS_8, + .parity = NO_OS_UART_PAR_NO, + .stop = NO_OS_UART_STOP_1_BIT, + .extra = &uart_extra_ip, + .platform_ops = UART_OPS, +}; + +struct no_os_i2c_init_param ltc7841_i2c_ip = { + .device_id = LTC7841_I2C_DEVICE_ID, + .max_speed_hz = LTC7841_I2C_CLK_SPEED, + .slave_address = LTC7841_I2C_ADDR, + .platform_ops = I2C_OPS, + .extra = <c7841_i2c_extra, +}; + +struct ltc7841_init_param ltc7841_ip = { + .comm_param = <c7841_i2c_ip, +}; diff --git a/projects/ltc7841/src/common/common_data.h b/projects/ltc7841/src/common/common_data.h new file mode 100644 index 00000000000..5f9afca2f01 --- /dev/null +++ b/projects/ltc7841/src/common/common_data.h @@ -0,0 +1,46 @@ +/***************************************************************************//** + * @file common_data.h + * @brief Defines common data to be used by ltc7841 examples. + * @author Marvin Cabuenas (marvinneil.cabuenas@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 __COMMON_DATA_H__ +#define __COMMON_DATA_H__ + +#include "no_os_uart.h" +#include "no_os_util.h" +#include "no_os_delay.h" +#include "ltc7841.h" +#include "parameters.h" + +extern struct no_os_uart_init_param uart_ip; + +extern struct ltc7841_init_param ltc7841_ip; + +#endif /* __COMMON_DATA_H__ */ diff --git a/projects/ltc7841/src/examples/basic/basic_example.c b/projects/ltc7841/src/examples/basic/basic_example.c new file mode 100644 index 00000000000..bc4e00802f4 --- /dev/null +++ b/projects/ltc7841/src/examples/basic/basic_example.c @@ -0,0 +1,125 @@ +/***************************************************************************//** + * @file basic_example.c + * @brief Basic example source file for ltp8800 project. + * @author Marvin Neil Cabuenas (marvinneil.cabuenas@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. +*******************************************************************************/ +#include "common_data.h" +#include "no_os_delay.h" +#include "no_os_print_log.h" +#include "ltc7841.h" + +int example_main(void) +{ + uint8_t value[2]; + int error; + struct ltc7841_desc *ltc7841_desc; + struct no_os_uart_desc *uart_desc; + int ret = -EINVAL; + + ret = no_os_uart_init(&uart_desc, &uart_ip); + if (ret) + return ret; + + no_os_uart_stdio(uart_desc); + + error = ltc7841_init(<c7841_desc, NULL); + if (error != E_NO_ERROR) { + return error; + } + while (1) { + error = ltc7841_mfr_clear_peaks(ltc7841_desc); + if (error) + return error; + error = ltc7841_clear_status_word_bits(ltc7841_desc); + if (error) + return error; + /* read every readable register for checking*/ + error = ltc7841_reg_read(ltc7841_desc, LTC7841_OPERATION, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_VOUT_MODE, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_STATUS_WORD, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_READ_VIN, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_READ_IIN, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_READ_VOUT, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_READ_IOUT, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_READ_TEMPERATURE_1, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_PMBUS_REVISION, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_MFR_IOUT_PEAK, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_MFR_VOUT_PEAK, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_MFR_VIN_PEAK, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_MFR_TEMEPRATURE1_PEAK, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_MFR_IIN_PEAK, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_MFR_VOUT_MARGIN_HIGH, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_MFR_SPECIAL_ID, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_MFR_VOUT_COMMAND, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_MFR_CONFIG, value); + if (error) + return error; + error = ltc7841_reg_read(ltc7841_desc, LTC7841_MFR_VOUT_MARGIN_LOW, value); + if (error) + return error; + no_os_mdelay(500); + } + + return E_NO_ERROR; +} diff --git a/projects/ltc7841/src/examples/iio_example/iio_example.c b/projects/ltc7841/src/examples/iio_example/iio_example.c new file mode 100644 index 00000000000..4c9c116653e --- /dev/null +++ b/projects/ltc7841/src/examples/iio_example/iio_example.c @@ -0,0 +1,80 @@ +/***************************************************************************//** + * @file iio_example.c + * @brief IIO example source file for ltc7841 project. + * @author Marvin Cabuenas (marvinneil.cabuenas@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. +*******************************************************************************/ +#include "iio_app.h" +#include "iio_ltc7841.h" +#include "common_data.h" +#include "no_os_print_log.h" + +int example_main(void) +{ + int ret; + struct ltc7841_iio_desc *ltc7841_iio_desc; + struct ltc7841_iio_desc_init_param ltc7841_iio_ip = { + .ltc7841_init_param = <c7841_ip, + .LTC7841_rsense_value = RSENSE_VALUE_DC2798A + }; + struct iio_app_desc *app; + struct iio_app_init_param app_init_param = { 0 }; + + ret = ltc7841_iio_init(<c7841_iio_desc, <c7841_iio_ip); + if (ret) + goto exit; + + struct iio_app_device iio_devices[] = { + { + .name = "ltc7841", + .dev = ltc7841_iio_desc, + .dev_descriptor = ltc7841_iio_desc->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 = uart_ip; + + ret = iio_app_init(&app, app_init_param); + if (ret) + goto remove_iio_ltc7841; + + ret = iio_app_run(app); + + iio_app_remove(app); + +remove_iio_ltc7841: + ltc7841_iio_remove(ltc7841_iio_desc); +exit: + if (ret) + pr_err("Error!\n"); + + return ret; +} + diff --git a/projects/ltc7841/src/examples/iio_example/iio_example.mk b/projects/ltc7841/src/examples/iio_example/iio_example.mk new file mode 100644 index 00000000000..0f1b6aa5602 --- /dev/null +++ b/projects/ltc7841/src/examples/iio_example/iio_example.mk @@ -0,0 +1,4 @@ +IIOD=y + +INCS += $(DRIVERS)/power/ltc7841/iio_ltc7841.h +SRCS += $(DRIVERS)/power/ltc7841/iio_ltc7841.c \ No newline at end of file diff --git a/projects/ltc7841/src/platform/maxim/main.c b/projects/ltc7841/src/platform/maxim/main.c new file mode 100644 index 00000000000..90f71bdf936 --- /dev/null +++ b/projects/ltc7841/src/platform/maxim/main.c @@ -0,0 +1,42 @@ +/***************************************************************************//** + * @file main.c + * @brief Main file for Maxim platform of ltc7841 project. + * @author Marvin Cabuenas (marvinneil.cabuenas@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. +*******************************************************************************/ +#include "parameters.h" +#include "common_data.h" +#include "no_os_error.h" + +extern int example_main(); + +int main() +{ + return example_main(); +} diff --git a/projects/ltc7841/src/platform/maxim/parameters.c b/projects/ltc7841/src/platform/maxim/parameters.c new file mode 100644 index 00000000000..6a1b61ae943 --- /dev/null +++ b/projects/ltc7841/src/platform/maxim/parameters.c @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file parameters.c + * @brief Definition of Maxim platform data used by ltc7841 project. + * @author Marvin Cabuenas (marvinneil.cabuenas@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. +*******************************************************************************/ +#include "parameters.h" +#include "maxim_gpio.h" +#include "maxim_i2c.h" +#include "maxim_uart.h" + +struct max_uart_init_param uart_extra_ip = { + .flow = UART_FLOW_DIS +}; + +const struct max_i2c_init_param ltc7841_i2c_extra = { + .vssel = MXC_GPIO_VSSEL_VDDIOH +}; + +const struct max_gpio_init_param ltc7841_gpio_extra = { + .vssel = MXC_GPIO_VSSEL_VDDIOH +}; diff --git a/projects/ltc7841/src/platform/maxim/parameters.h b/projects/ltc7841/src/platform/maxim/parameters.h new file mode 100644 index 00000000000..ee0627f8df5 --- /dev/null +++ b/projects/ltc7841/src/platform/maxim/parameters.h @@ -0,0 +1,55 @@ +/***************************************************************************//** + * @file parameters.h + * @brief Definitions used by the LTC7841 project. + * @author Marvin Cabuenas (marvinneil.cabuenas@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 __PARAMETERS_H__ +#define __PARAMETERS_H__ + +#include "maxim_gpio.h" +#include "maxim_i2c.h" +#include "maxim_uart.h" + +#define INTC_DEVICE_ID 0 +#define I2C_OPS &max_i2c_ops +#define UART_OPS &max_uart_ops + +/* LTC7841 parameters */ +#define LTC7841_I2C_DEVICE_ID 0 +#define LTC7841_I2C_CLK_SPEED 400000 +#define LTC7841_I2C_ADDR 0x20 +/* Unit in MilliOhms*/ +#define RSENSE_VALUE_DC2798A 2 + +extern struct max_uart_init_param uart_extra_ip; +extern const struct max_i2c_init_param ltc7841_i2c_extra; +extern const struct max_gpio_init_param ltc7841_gpio_extra; + +#endif /* __PARAMETERS_H__ */ diff --git a/projects/ltc7841/src/platform/maxim/platform_src.mk b/projects/ltc7841/src/platform/maxim/platform_src.mk new file mode 100644 index 00000000000..e4449b89ab5 --- /dev/null +++ b/projects/ltc7841/src/platform/maxim/platform_src.mk @@ -0,0 +1,12 @@ +NO_OS_INC_DIRS += \ + $(PLATFORM_DRIVERS) \ + $(PLATFORM_DRIVERS)/../common/ + +SRCS += $(PLATFORM_DRIVERS)/maxim_delay.c \ + $(PLATFORM_DRIVERS)/maxim_gpio.c \ + $(PLATFORM_DRIVERS)/maxim_gpio_irq.c \ + $(PLATFORM_DRIVERS)/maxim_irq.c \ + $(PLATFORM_DRIVERS)/../common/maxim_dma.c \ + $(PLATFORM_DRIVERS)/maxim_i2c.c \ + $(PLATFORM_DRIVERS)/maxim_uart.c \ + $(PLATFORM_DRIVERS)/maxim_uart_stdio.c