Skip to content

Commit e43f505

Browse files
projects: adp1055: Add project for ADP1055
Signed-off-by: ivangilmercano <[email protected]>
1 parent 31ab9ad commit e43f505

File tree

12 files changed

+562
-0
lines changed

12 files changed

+562
-0
lines changed

projects/adp1055/Makefile

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

projects/adp1055/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_max32690": {
4+
"flags" : "EXAMPLE=basic"
5+
},
6+
"iio_example_max32690": {
7+
"flags" : "EXAMPLE=iio_example"
8+
}
9+
}
10+
}

projects/adp1055/src.mk

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
INCS += $(INCLUDE)/no_os_delay.h \
2+
$(INCLUDE)/no_os_error.h \
3+
$(INCLUDE)/no_os_list.h \
4+
$(INCLUDE)/no_os_gpio.h \
5+
$(INCLUDE)/no_os_dma.h \
6+
$(INCLUDE)/no_os_print_log.h \
7+
$(INCLUDE)/no_os_i2c.h \
8+
$(INCLUDE)/no_os_irq.h \
9+
$(INCLUDE)/no_os_pwm.h \
10+
$(INCLUDE)/no_os_rtc.h \
11+
$(INCLUDE)/no_os_uart.h \
12+
$(INCLUDE)/no_os_lf256fifo.h \
13+
$(INCLUDE)/no_os_util.h \
14+
$(INCLUDE)/no_os_units.h \
15+
$(INCLUDE)/no_os_alloc.h \
16+
$(INCLUDE)/no_os_mutex.h
17+
18+
SRCS += $(NO-OS)/util/no_os_lf256fifo.c \
19+
$(DRIVERS)/api/no_os_i2c.c \
20+
$(DRIVERS)/api/no_os_dma.c \
21+
$(DRIVERS)/api/no_os_uart.c \
22+
$(DRIVERS)/api/no_os_irq.c \
23+
$(DRIVERS)/api/no_os_gpio.c \
24+
$(DRIVERS)/api/no_os_pwm.c \
25+
$(NO-OS)/util/no_os_util.c \
26+
$(NO-OS)/util/no_os_list.c \
27+
$(NO-OS)/util/no_os_alloc.c \
28+
$(NO-OS)/util/no_os_mutex.c
29+
30+
INCS += $(DRIVERS)/power/adp1055/adp1055.h
31+
SRCS += $(DRIVERS)/power/adp1055/adp1055.c
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/***************************************************************************//**
2+
* @file common_data.c
3+
* @brief Defines common data to be used by adp1055 examples.
4+
* @author Ivan Gil Mercano ([email protected])
5+
********************************************************************************
6+
* Copyright 2024(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+
#include "common_data.h"
34+
35+
struct no_os_uart_init_param adp1055_uart_ip = {
36+
.device_id = UART_DEVICE_ID,
37+
.baud_rate = UART_BAUDRATE,
38+
.size = NO_OS_UART_CS_8,
39+
.parity = NO_OS_UART_PAR_NO,
40+
.stop = NO_OS_UART_STOP_1_BIT,
41+
.platform_ops = UART_OPS,
42+
.extra = UART_EXTRA,
43+
};
44+
45+
struct no_os_i2c_init_param adp1055_i2c_ip = {
46+
.device_id = I2C_DEVICE_ID,
47+
.max_speed_hz = 100000,
48+
.platform_ops = I2C_OPS,
49+
.slave_address = ADP1055_PMBUS_DEFAULT_ADDRESS,
50+
.extra = I2C_EXTRA,
51+
};
52+
53+
struct no_os_gpio_init_param adp1055_pg_alt_ip = {
54+
.port = GPIO_PG_ALT_PORT,
55+
.number = GPIO_PG_ALT_PIN,
56+
.pull = NO_OS_PULL_NONE,
57+
.platform_ops = GPIO_OPS,
58+
.extra = GPIO_EXTRA,
59+
};
60+
61+
struct adp1055_init_param adp1055_ip = {
62+
.i2c_param = &adp1055_i2c_ip,
63+
.pg_alt_param = &adp1055_pg_alt_ip,
64+
.flgi_param = NULL,
65+
.syni_param = NULL,
66+
.on_off_config = ADP1055_ON_OFF_DEFAULT_CFG,
67+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/***************************************************************************//**
2+
* @file common_data.h
3+
* @brief Defines common data to be used by adp1055 examples.
4+
* @author Ivan Gil Mercano ([email protected])
5+
********************************************************************************
6+
* Copyright 2024(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 "parameters.h"
37+
#include "no_os_i2c.h"
38+
#include "no_os_gpio.h"
39+
#include "no_os_pwm.h"
40+
#include "adp1055.h"
41+
42+
#define ADP1055_PMBUS_DEFAULT_ADDRESS 0x4B
43+
44+
extern struct no_os_uart_init_param adp1055_uart_ip;
45+
extern struct no_os_i2c_init_param adp1055_i2c_ip;
46+
extern struct no_os_gpio_init_param adp1055_pg_alt_ip;
47+
extern struct adp1055_init_param adp1055_ip;
48+
49+
#endif /* __COMMON_DATA_H__ */
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/***************************************************************************//**
2+
* @file basic_example.c
3+
* @brief Basic example source file for adp1055 project.
4+
* @author Ivan Gil Mercano ([email protected])
5+
********************************************************************************
6+
* Copyright 2024(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+
#include "common_data.h"
34+
#include "no_os_delay.h"
35+
#include "no_os_i2c.h"
36+
#include "no_os_print_log.h"
37+
#include "no_os_util.h"
38+
#include "no_os_pwm.h"
39+
#include "adp1055.h"
40+
41+
int example_main()
42+
{
43+
int ret;
44+
45+
struct adp1055_desc *adp1055_desc;
46+
uint8_t data = 120;
47+
uint8_t data2[2];
48+
uint16_t vout;
49+
int16_t val;
50+
51+
pr_info("INIT: ");
52+
ret = adp1055_init(&adp1055_desc, &adp1055_ip);
53+
if (ret)
54+
pr_info("Fail \n");
55+
else
56+
pr_info("Pass \n");
57+
58+
pr_info("VOUT SCALE: ");
59+
ret = adp1055_vout_scale(adp1055_desc, -12, 341);
60+
if (ret)
61+
pr_info("Fail \n");
62+
else
63+
pr_info("Pass \n");
64+
65+
pr_info("VOUT VALUE: ");
66+
ret = adp1055_vout_value(adp1055_desc, 0x3000, 0x5000);
67+
if (ret)
68+
pr_info("Fail \n");
69+
else
70+
pr_info("Pass \n");
71+
72+
pr_info("PWM CONFIG: ");
73+
ret = adp1055_pwm_config(adp1055_desc, 0x00DE, 0x000E, 0, 0, ADP1055_OUTA);
74+
if (ret)
75+
pr_info("Fail \n");
76+
else
77+
pr_info("Pass \n");
78+
79+
pr_info("SET PWM: ");
80+
ret = adp1055_set_pwm(adp1055_desc, ADP1055_OUTA, -4, 782);
81+
if (ret)
82+
pr_info("Fail \n");
83+
else
84+
pr_info("Pass \n");
85+
86+
pr_info("READ VALUE: ");
87+
ret = adp1055_read_value(adp1055_desc, ADP1055_VALUE_DUTY_CYCLE, &vout, &data);
88+
if (ret)
89+
pr_info("Fail \n");
90+
else
91+
pr_info("Pass \n");
92+
93+
/* Checking statuses. */
94+
pr_info("READ STAT VOUT: ");
95+
ret = adp1055_read(adp1055_desc, ADP1055_STATUS_VOUT, &data, 1);
96+
if (ret)
97+
pr_info("Fail \n");
98+
else
99+
pr_info("Pass \n");
100+
101+
pr_info("READ STAT INPUT: ");
102+
ret = adp1055_read(adp1055_desc, ADP1055_STATUS_INPUT, &data, 1);
103+
if (ret)
104+
pr_info("Fail \n");
105+
else
106+
pr_info("Pass \n");
107+
108+
pr_info("READ STAT CML: ");
109+
ret = adp1055_read(adp1055_desc, ADP1055_STATUS_CML, &data, 1);
110+
if (ret)
111+
pr_info("Fail \n");
112+
else
113+
pr_info("Pass \n");
114+
115+
pr_info("READ STAT WORD: ");
116+
ret = adp1055_read(adp1055_desc, ADP1055_STATUS_WORD, data2, 2);
117+
if (ret)
118+
pr_info("Fail \n");
119+
else
120+
pr_info("Pass \n");
121+
122+
exit:
123+
if (ret)
124+
pr_info("Error!\n");
125+
adp1055_remove(adp1055_desc);
126+
return ret;
127+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
IIOD=y
2+
INCS += $(DRIVERS)/power/adp1055/iio_adp1055.h
3+
SRCS += $(DRIVERS)/power/adp1055/iio_adp1055.c
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/***************************************************************************//**
2+
* @file iio_example.c
3+
* @brief IIO example source file for adp1055 project.
4+
* @author Ivan Gil Mercano ([email protected])
5+
********************************************************************************
6+
* Copyright 2024(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+
#include "iio_adp1055.h"
34+
#include "common_data.h"
35+
#include "no_os_print_log.h"
36+
#include "iio_app.h"
37+
38+
int example_main()
39+
{
40+
int ret;
41+
42+
struct adp1055_iio_desc *adp1055_iio_desc;
43+
struct adp1055_iio_desc_init_param adp1055_iio_ip = {
44+
.adp1055_init_param = &adp1055_ip,
45+
.vout_scale_monitor = 0xA155,
46+
.vin_scale_monitor = 0xB033,
47+
.iin_scale_monitor = 0x01,
48+
};
49+
50+
struct iio_app_desc *app;
51+
struct iio_app_init_param app_init_param = { 0 };
52+
53+
ret = adp1055_iio_init(&adp1055_iio_desc, &adp1055_iio_ip);
54+
if (ret)
55+
goto exit;
56+
57+
struct iio_app_device iio_devices[] = {
58+
{
59+
.name = "adp1055",
60+
.dev = adp1055_iio_desc,
61+
.dev_descriptor = adp1055_iio_desc->iio_dev,
62+
}
63+
};
64+
65+
app_init_param.devices = iio_devices;
66+
app_init_param.nb_devices = NO_OS_ARRAY_SIZE(iio_devices);
67+
app_init_param.uart_init_params = adp1055_uart_ip;
68+
69+
ret = iio_app_init(&app, app_init_param);
70+
if (ret)
71+
goto remove_iio_adp1055;
72+
73+
ret = iio_app_run(app);
74+
75+
iio_app_remove(app);
76+
77+
remove_iio_adp1055:
78+
adp1055_iio_remove(adp1055_iio_desc);
79+
exit:
80+
if (ret)
81+
pr_info("Error!\n");
82+
return ret;
83+
}

0 commit comments

Comments
 (0)