Skip to content

Commit

Permalink
projects: ltc4296: add initial example
Browse files Browse the repository at this point in the history
Add ltc4296 project example.

Signed-off-by: Antoniu Miclaus <[email protected]>
  • Loading branch information
amiclaus authored and buha committed May 13, 2024
1 parent 9753736 commit 453107b
Show file tree
Hide file tree
Showing 13 changed files with 567 additions and 0 deletions.
8 changes: 8 additions & 0 deletions projects/ltc4296/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Select the example you want to enable by choosing y for enabling and n for disabling
BASIC_EXAMPLE = y

include ../../tools/scripts/generic_variables.mk

include src.mk

include ../../tools/scripts/generic.mk
7 changes: 7 additions & 0 deletions projects/ltc4296/builds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"maxim": {
"basic_example_max32690": {
"flags" : "BASIC_EXAMPLE=y TARGET=max32690"
}
}
}
44 changes: 44 additions & 0 deletions projects/ltc4296/src.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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 \
$(INCLUDE)/no_os_gpio.h \
$(INCLUDE)/no_os_dma.h \
$(INCLUDE)/no_os_print_log.h \
$(INCLUDE)/no_os_spi.h \
$(INCLUDE)/no_os_irq.h \
$(INCLUDE)/no_os_pwm.h \
$(INCLUDE)/no_os_rtc.h \
$(INCLUDE)/no_os_uart.h \
$(INCLUDE)/no_os_lf256fifo.h \
$(INCLUDE)/no_os_util.h \
$(INCLUDE)/no_os_units.h \
$(INCLUDE)/no_os_alloc.h \
$(INCLUDE)/no_os_mutex.h

SRCS += $(NO-OS)/util/no_os_lf256fifo.c \
$(DRIVERS)/api/no_os_spi.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

INCS += $(DRIVERS)/power/ltc4296/ltc4296.h
SRCS += $(DRIVERS)/power/ltc4296/ltc4296.c
63 changes: 63 additions & 0 deletions projects/ltc4296/src/common/common_data.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/***************************************************************************//**
* @file common_data.c
* @brief Defines common data to be used by ltc4296 examples.
* @author Antoniu Miclaus ([email protected])
********************************************************************************
* Copyright 2024(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 "common_data.h"

struct no_os_uart_init_param ltc4296_uart_ip = {
.device_id = UART_DEVICE_ID,
.baud_rate = UART_BAUDRATE,
.size = NO_OS_UART_CS_8,
.parity = NO_OS_UART_PAR_NO,
.stop = NO_OS_UART_STOP_1_BIT,
.platform_ops = UART_OPS,
.extra = UART_EXTRA,
};

struct no_os_spi_init_param ltc4296_spi_ip = {
.device_id = SPI_DEVICE_ID,
.max_speed_hz = SPI_BAUDRATE,
.bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST,
.mode = NO_OS_SPI_MODE_0,
.platform_ops = SPI_OPS,
.chip_select = SPI_CS,
.extra = SPI_EXTRA,
};

struct ltc4296_init_param ltc4296_ip = {
.spi_init = &ltc4296_spi_ip,
};
52 changes: 52 additions & 0 deletions projects/ltc4296/src/common/common_data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/***************************************************************************//**
* @file common_data.h
* @brief Defines common data to be used by ltc4296 examples.
* @author Antoniu Miclaus ([email protected])
********************************************************************************
* Copyright 2024(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 __COMMON_DATA_H__
#define __COMMON_DATA_H__

#include "platform_includes.h"
#include "no_os_spi.h"
#include "no_os_gpio.h"
#include "no_os_pwm.h"
#include "ltc4296.h"

extern struct no_os_uart_init_param ltc4296_uart_ip;
extern struct no_os_spi_init_param ltc4296_spi_ip;
extern struct ltc4296_init_param ltc4296_ip;

#endif /* __COMMON_DATA_H__ */
106 changes: 106 additions & 0 deletions projects/ltc4296/src/examples/basic/basic_example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/***************************************************************************//**
* @file basic_example.c
* @brief Basic example source file for ltc4296 project.
* @author Antoniu Miclaus ([email protected])
********************************************************************************
* Copyright 2024(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 "common_data.h"
#include "basic_example.h"
#include "no_os_delay.h"
#include "no_os_spi.h"
#include "no_os_print_log.h"
#include "no_os_util.h"
#include "no_os_pwm.h"
#include "ltc4296.h"

int basic_example_main()
{
int ret;

struct ltc4296_dev *ltc4296_desc;

ret = ltc4296_init(&ltc4296_desc, &ltc4296_ip);
if (ret) {
pr_info("Initialization error!\n");
return ret;
}

ret = ltc4296_port_prebias(ltc4296_desc, LTC_PORT0, LTC_CFG_APL_MODE);
if (ret)
goto err;

ret = ltc4296_port_en(ltc4296_desc, LTC_PORT0);
if (ret)
goto err;

no_os_mdelay(100);

ltc4296_port_prebias(ltc4296_desc, LTC_PORT1, LTC_CFG_APL_MODE);
if (ret)
goto err;

ltc4296_port_en(ltc4296_desc, LTC_PORT1);
if (ret)
goto err;

no_os_mdelay(100);

ret = ltc4296_port_prebias(ltc4296_desc, LTC_PORT2, LTC_CFG_APL_MODE);
if (ret)
goto err;

ret = ltc4296_port_en(ltc4296_desc, LTC_PORT2);
if (ret)
goto err;

no_os_mdelay(100);

ret = ltc4296_port_prebias(ltc4296_desc, LTC_PORT3, LTC_CFG_APL_MODE);
if (ret)
goto err;

ret = ltc4296_port_en(ltc4296_desc, LTC_PORT3);
if (ret)
goto err;

no_os_mdelay(100);

return 0;

err:
ltc4296_remove(ltc4296_desc);

return ret;
}
44 changes: 44 additions & 0 deletions projects/ltc4296/src/examples/basic/basic_example.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/***************************************************************************//**
* @file basic_example.h
* @brief Basic example header file for ltc4296 project.
* @author Antoniu Miclaus ([email protected])
********************************************************************************
* Copyright 2024(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 __BASIC_EXAMPLE_H__
#define __BASIC_EXAMPLE_H__

int basic_example_main();

#endif /* __BASIC_EXAMPLE_H__ */
5 changes: 5 additions & 0 deletions projects/ltc4296/src/examples/examples_src.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ifeq (y,$(strip $(BASIC_EXAMPLE)))
CFLAGS += -DBASIC_EXAMPLE=1
SRCS += $(PROJECT)/src/examples/basic/basic_example.c
INCS += $(PROJECT)/src/examples/basic/basic_example.h
endif
Loading

0 comments on commit 453107b

Please sign in to comment.