Skip to content

Commit 48a9c78

Browse files
committed
projects: ltc2378: Add project for LTC2378
Add initial project files for both basic and IIO examples for LTC2378. Signed-off-by: Cherrence Sarip <cherrence.sarip@analog.com>
1 parent 8edb7aa commit 48a9c78

File tree

15 files changed

+724
-0
lines changed

15 files changed

+724
-0
lines changed

projects/ltc2378/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Select the example you want to enable by choosing y for enabling and n for disabling
2+
BASIC_EXAMPLE = n
3+
IIO_EXAMPLE = y
4+
5+
include ../../tools/scripts/generic_variables.mk
6+
7+
include src.mk
8+
9+
include ../../tools/scripts/generic.mk

projects/ltc2378/builds.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"maxim": {
3+
"basic_example_max32665": {
4+
"flags": "BASIC_EXAMPLE=y IIO_EXAMPLE=n TARGET=max32665"
5+
},
6+
"iio_example_max32665": {
7+
"flags": "BASIC_EXAMPLE=n IIO_EXAMPLE=y TARGET=max32665"
8+
}
9+
}
10+
}

projects/ltc2378/src.mk

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
include $(PROJECT)/src/platform/$(PLATFORM)/platform_src.mk
2+
include $(PROJECT)/src/examples/examples_src.mk
3+
4+
SRCS += $(PROJECT)/src/platform/$(PLATFORM)/main.c
5+
6+
INCS += $(PROJECT)/src/common/common_data.h
7+
SRCS += $(PROJECT)/src/common/common_data.c
8+
9+
INCS += $(PROJECT)/src/platform/platform_includes.h
10+
11+
INCS += $(PROJECT)/src/platform/$(PLATFORM)/parameters.h
12+
SRCS += $(PROJECT)/src/platform/$(PLATFORM)/parameters.c
13+
14+
INCS += $(INCLUDE)/no_os_delay.h \
15+
$(INCLUDE)/no_os_error.h \
16+
$(INCLUDE)/no_os_gpio.h \
17+
$(INCLUDE)/no_os_print_log.h \
18+
$(INCLUDE)/no_os_spi.h \
19+
$(INCLUDE)/no_os_alloc.h \
20+
$(INCLUDE)/no_os_irq.h \
21+
$(INCLUDE)/no_os_list.h \
22+
$(INCLUDE)/no_os_dma.h \
23+
$(INCLUDE)/no_os_uart.h \
24+
$(INCLUDE)/no_os_lf256fifo.h \
25+
$(INCLUDE)/no_os_util.h \
26+
$(INCLUDE)/no_os_units.h \
27+
$(INCLUDE)/no_os_mutex.h
28+
29+
SRCS += $(DRIVERS)/api/no_os_gpio.c \
30+
$(NO-OS)/util/no_os_lf256fifo.c \
31+
$(DRIVERS)/api/no_os_irq.c \
32+
$(DRIVERS)/api/no_os_spi.c \
33+
$(DRIVERS)/api/no_os_uart.c \
34+
$(DRIVERS)/api/no_os_dma.c \
35+
$(NO-OS)/util/no_os_list.c \
36+
$(NO-OS)/util/no_os_util.c \
37+
$(NO-OS)/util/no_os_alloc.c \
38+
$(NO-OS)/util/no_os_mutex.c
39+
40+
INCS += $(DRIVERS)/adc/ltc2378/ltc2378.h
41+
SRCS += $(DRIVERS)/adc/ltc2378/ltc2378.c
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*******************************************************************************
2+
* @file common_data.c
3+
* @brief Defines common data to be used by ltc2378 examples.
4+
* @author Cherrence Sarip (cherrence.sarip@analog.com)
5+
********************************************************************************
6+
* Copyright 2025(c) Analog Devices, Inc.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* 3. Neither the name of Analog Devices, Inc. nor the names of its
19+
* contributors may be used to endorse or promote products derived from this
20+
* software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25+
* EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*******************************************************************************/
33+
34+
#include "common_data.h"
35+
#include <stdbool.h>
36+
37+
struct no_os_uart_init_param uip = {
38+
.device_id = UART_DEVICE_ID,
39+
.irq_id = UART_IRQ_ID,
40+
.asynchronous_rx = true,
41+
.baud_rate = UART_BAUDRATE,
42+
.size = NO_OS_UART_CS_8,
43+
.parity = NO_OS_UART_PAR_NO,
44+
.stop = NO_OS_UART_STOP_1_BIT,
45+
.platform_ops = UART_OPS,
46+
.extra = UART_EXTRA,
47+
};
48+
49+
const struct no_os_spi_init_param ltc2378_spi_ip = {
50+
.device_id = SPI_DEVICE_ID,
51+
.max_speed_hz = SPI_MAX_SPEED,
52+
.chip_select = SPI_CS,
53+
.mode = NO_OS_SPI_MODE_0,
54+
.bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST,
55+
.platform_ops = SPI_OPS,
56+
.extra = SPI_EXTRA,
57+
.parent = NULL,
58+
};
59+
60+
const struct no_os_gpio_init_param ltc2378_gpio_cnv = {
61+
.port = GPIO_CNV_PORT_NUM,
62+
.number = GPIO_CNV_PIN_NUM,
63+
.platform_ops = GPIO_OPS,
64+
.extra = GPIO_EXTRA
65+
};
66+
67+
const struct no_os_gpio_init_param ltc2378_gpio_busy = {
68+
.port = GPIO_BUSY_PORT_NUM,
69+
.number = GPIO_BUSY_PIN_NUM,
70+
.platform_ops = GPIO_OPS,
71+
.extra = GPIO_EXTRA
72+
};
73+
74+
struct ltc2378_init_param ltc2378_ip = {
75+
.spi_init = &ltc2378_spi_ip,
76+
.gpio_cnv_init = &ltc2378_gpio_cnv,
77+
.gpio_busy_init = &ltc2378_gpio_busy,
78+
.vref_uv = 2500000,
79+
.input_mode = LTC2378_UNIPOLAR
80+
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*******************************************************************************
2+
* @file common_data.h
3+
* @brief Defines common data to be used by ltc2378 examples.
4+
* @author Cherrence Sarip (cherrence.sarip@analog.com)
5+
********************************************************************************
6+
* Copyright 2025(c) Analog Devices, Inc.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* 3. Neither the name of Analog Devices, Inc. nor the names of its
19+
* contributors may be used to endorse or promote products derived from this
20+
* software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25+
* EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*******************************************************************************/
33+
#ifndef __COMMON_DATA_H__
34+
#define __COMMON_DATA_H__
35+
36+
#include "platform_includes.h"
37+
#include "ltc2378.h"
38+
#include "no_os_spi.h"
39+
#include "iio_ltc2378.h"
40+
41+
extern struct no_os_uart_init_param uip;
42+
43+
extern const struct no_os_spi_init_param ltc2378_spi_ip;
44+
extern const struct no_os_gpio_init_param ltc2378_gpio_cnv;
45+
extern const struct no_os_gpio_init_param ltc2378_gpio_busy;
46+
extern struct ltc2378_init_param ltc2378_ip;
47+
48+
#endif /* __COMMON_DATA_H__ */
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*******************************************************************************
2+
* @file basic_example.c
3+
* @brief Basic example code for ltc2378 project
4+
* @author Cherrence Sarip (cherrence.sarip@analog.com)
5+
********************************************************************************
6+
* Copyright 2025(c) Analog Devices, Inc.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* 3. Neither the name of Analog Devices, Inc. nor the names of its
19+
* contributors may be used to endorse or promote products derived from this
20+
* software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25+
* EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*******************************************************************************/
33+
34+
#include "basic_example.h"
35+
#include "no_os_delay.h"
36+
#include "no_os_print_log.h"
37+
#include "no_os_spi.h"
38+
#include "no_os_util.h"
39+
#include "no_os_error.h"
40+
#include "common_data.h"
41+
#include "ltc2378.h"
42+
#include <stdlib.h>
43+
#include "no_os_gpio.h"
44+
#include "maxim_gpio.h"
45+
46+
/*****************************************************************************
47+
* @brief Basic example main execution.
48+
*
49+
* @return ret - Result of the example execution. If working correctly, will
50+
* execute continuously the while(1) loop and will not return.
51+
*******************************************************************************/
52+
53+
int basic_example_main()
54+
{
55+
struct ltc2378_dev *dev;
56+
int ret;
57+
58+
pr_info("LTC2378 Basic Test\n");
59+
60+
ret = ltc2378_init(&dev, &ltc2378_ip);
61+
if (ret) {
62+
pr_info("Init failed: %d\n", ret);
63+
return ret;
64+
}
65+
66+
pr_info("VREF: %lu uV, Mode: %s\n",
67+
dev->vref_uv,
68+
(dev->input_mode == LTC2378_UNIPOLAR) ? "Unipolar" : "Bipolar");
69+
70+
while (1) {
71+
uint32_t raw;
72+
int32_t voltage_uv;
73+
74+
ret = ltc2378_read_raw(dev, &raw);
75+
if (ret) {
76+
pr_info("Read failed: %d\n", ret);
77+
continue;
78+
}
79+
80+
ret = ltc2378_raw_to_uv(dev, raw, &voltage_uv);
81+
if (ret) {
82+
pr_info("Convert failed: %d\n", ret);
83+
continue;
84+
}
85+
86+
pr_info("Raw: %lu, Voltage: %ld uV\n", raw, voltage_uv);
87+
88+
no_os_mdelay(500);
89+
}
90+
91+
return 0;
92+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*******************************************************************************
2+
* @file basic_example.h
3+
* @brief Basic example header for ltc2378 project
4+
* @author Cherrence Sarip (cherrence.sarip@analog.com)
5+
********************************************************************************
6+
* Copyright 2025(c) Analog Devices, Inc.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* 3. Neither the name of Analog Devices, Inc. nor the names of its
19+
* contributors may be used to endorse or promote products derived from this
20+
* software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25+
* EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*******************************************************************************/
33+
#ifndef __BASIC_EXAMPLE_H__
34+
#define __BASIC_EXAMPLE_H__
35+
36+
int basic_example_main();
37+
38+
#endif /* __BASIC_EXAMPLE_H__ */
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ifeq (y,$(strip $(IIO_EXAMPLE)))
2+
IIOD=y
3+
CFLAGS += -DIIO_EXAMPLE=1
4+
SRCS += $(PROJECT)/src/examples/iio_example/iio_example.c
5+
INCS += $(PROJECT)/src/examples/iio_example/iio_example.h
6+
endif
7+
8+
ifeq (y,$(strip $(BASIC_EXAMPLE)))
9+
CFLAGS += -DBASIC_EXAMPLE=1
10+
SRCS += $(PROJECT)/src/examples/basic/basic_example.c
11+
INCS += $(PROJECT)/src/examples/basic/basic_example.h
12+
endif
13+
14+
ifeq (y,$(strip $(IIOD)))
15+
SRC_DIRS += $(NO-OS)/iio/iio_app
16+
INCS += $(DRIVERS)/adc/ltc2378/iio_ltc2378.h
17+
SRCS += $(DRIVERS)/adc/ltc2378/iio_ltc2378.c
18+
19+
INCS += $(INCLUDE)/no_os_list.h \
20+
$(PLATFORM_DRIVERS)/$(PLATFORM)_uart.h
21+
endif

0 commit comments

Comments
 (0)