-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
projects: adp1055: Add project for ADP1055
Signed-off-by: ivangilmercano <[email protected]>
- Loading branch information
1 parent
f3bdaea
commit bd634d9
Showing
12 changed files
with
562 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Select the example you want to enable by choosing y for enabling and n for disabling | ||
EXAMPLE ?= iio_example | ||
|
||
include ../../tools/scripts/generic_variables.mk | ||
|
||
include ../../tools/scripts/examples.mk | ||
|
||
include src.mk | ||
|
||
include ../../tools/scripts/generic.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"maxim": { | ||
"basic_example_max32690": { | ||
"flags" : "EXAMPLE=basic" | ||
}, | ||
"iio_example_max32690": { | ||
"flags" : "EXAMPLE=iio_example" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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_i2c.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_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 | ||
|
||
INCS += $(DRIVERS)/power/adp1055/adp1055.h | ||
SRCS += $(DRIVERS)/power/adp1055/adp1055.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/***************************************************************************//** | ||
* @file common_data.c | ||
* @brief Defines common data to be used by adp1055 examples. | ||
* @author Ivan Gil Mercano ([email protected]) | ||
******************************************************************************** | ||
* Copyright 2025(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 adp1055_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_i2c_init_param adp1055_i2c_ip = { | ||
.device_id = I2C_DEVICE_ID, | ||
.max_speed_hz = 100000, | ||
.platform_ops = I2C_OPS, | ||
.slave_address = ADP1055_PMBUS_DEFAULT_ADDRESS, | ||
.extra = I2C_EXTRA, | ||
}; | ||
|
||
struct no_os_gpio_init_param adp1055_pg_alt_ip = { | ||
.port = GPIO_PG_ALT_PORT, | ||
.number = GPIO_PG_ALT_PIN, | ||
.pull = NO_OS_PULL_NONE, | ||
.platform_ops = GPIO_OPS, | ||
.extra = GPIO_EXTRA, | ||
}; | ||
|
||
struct adp1055_init_param adp1055_ip = { | ||
.i2c_param = &adp1055_i2c_ip, | ||
.pg_alt_param = &adp1055_pg_alt_ip, | ||
.flgi_param = NULL, | ||
.syni_param = NULL, | ||
.on_off_config = ADP1055_ON_OFF_DEFAULT_CFG, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/***************************************************************************//** | ||
* @file common_data.h | ||
* @brief Defines common data to be used by adp1055 examples. | ||
* @author Ivan Gil Mercano ([email protected]) | ||
******************************************************************************** | ||
* Copyright 2025(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 "parameters.h" | ||
#include "no_os_i2c.h" | ||
#include "no_os_gpio.h" | ||
#include "no_os_pwm.h" | ||
#include "adp1055.h" | ||
|
||
#define ADP1055_PMBUS_DEFAULT_ADDRESS 0x4B | ||
|
||
extern struct no_os_uart_init_param adp1055_uart_ip; | ||
extern struct no_os_i2c_init_param adp1055_i2c_ip; | ||
extern struct no_os_gpio_init_param adp1055_pg_alt_ip; | ||
extern struct adp1055_init_param adp1055_ip; | ||
|
||
#endif /* __COMMON_DATA_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/***************************************************************************//** | ||
* @file basic_example.c | ||
* @brief Basic example source file for adp1055 project. | ||
* @author Ivan Gil Mercano ([email protected]) | ||
******************************************************************************** | ||
* Copyright 2025(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_i2c.h" | ||
#include "no_os_print_log.h" | ||
#include "no_os_util.h" | ||
#include "no_os_pwm.h" | ||
#include "adp1055.h" | ||
|
||
int example_main() | ||
{ | ||
int ret; | ||
|
||
struct adp1055_desc *adp1055_desc; | ||
uint8_t data = 120; | ||
uint8_t data2[2]; | ||
uint16_t vout; | ||
int16_t val; | ||
|
||
pr_info("INIT: "); | ||
ret = adp1055_init(&adp1055_desc, &adp1055_ip); | ||
if (ret) | ||
pr_info("Fail \n"); | ||
else | ||
pr_info("Pass \n"); | ||
|
||
pr_info("VOUT SCALE: "); | ||
ret = adp1055_vout_scale(adp1055_desc, -12, 341); | ||
if (ret) | ||
pr_info("Fail \n"); | ||
else | ||
pr_info("Pass \n"); | ||
|
||
pr_info("VOUT VALUE: "); | ||
ret = adp1055_vout_value(adp1055_desc, 0x3000, 0x5000); | ||
if (ret) | ||
pr_info("Fail \n"); | ||
else | ||
pr_info("Pass \n"); | ||
|
||
pr_info("PWM CONFIG: "); | ||
ret = adp1055_pwm_config(adp1055_desc, 0x00DE, 0x000E, 0, 0, ADP1055_OUTA); | ||
if (ret) | ||
pr_info("Fail \n"); | ||
else | ||
pr_info("Pass \n"); | ||
|
||
pr_info("SET PWM: "); | ||
ret = adp1055_set_pwm(adp1055_desc, ADP1055_OUTA, -4, 782); | ||
if (ret) | ||
pr_info("Fail \n"); | ||
else | ||
pr_info("Pass \n"); | ||
|
||
pr_info("READ VALUE: "); | ||
ret = adp1055_read_value(adp1055_desc, ADP1055_VALUE_DUTY_CYCLE, &vout, &data); | ||
if (ret) | ||
pr_info("Fail \n"); | ||
else | ||
pr_info("Pass \n"); | ||
|
||
/* Checking statuses. */ | ||
pr_info("READ STAT VOUT: "); | ||
ret = adp1055_read(adp1055_desc, ADP1055_STATUS_VOUT, &data, 1); | ||
if (ret) | ||
pr_info("Fail \n"); | ||
else | ||
pr_info("Pass \n"); | ||
|
||
pr_info("READ STAT INPUT: "); | ||
ret = adp1055_read(adp1055_desc, ADP1055_STATUS_INPUT, &data, 1); | ||
if (ret) | ||
pr_info("Fail \n"); | ||
else | ||
pr_info("Pass \n"); | ||
|
||
pr_info("READ STAT CML: "); | ||
ret = adp1055_read(adp1055_desc, ADP1055_STATUS_CML, &data, 1); | ||
if (ret) | ||
pr_info("Fail \n"); | ||
else | ||
pr_info("Pass \n"); | ||
|
||
pr_info("READ STAT WORD: "); | ||
ret = adp1055_read(adp1055_desc, ADP1055_STATUS_WORD, data2, 2); | ||
if (ret) | ||
pr_info("Fail \n"); | ||
else | ||
pr_info("Pass \n"); | ||
|
||
exit: | ||
if (ret) | ||
pr_info("Error!\n"); | ||
adp1055_remove(adp1055_desc); | ||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
IIOD=y | ||
INCS += $(DRIVERS)/power/adp1055/iio_adp1055.h | ||
SRCS += $(DRIVERS)/power/adp1055/iio_adp1055.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/***************************************************************************//** | ||
* @file iio_example.c | ||
* @brief IIO example source file for adp1055 project. | ||
* @author Ivan Gil Mercano ([email protected]) | ||
******************************************************************************** | ||
* Copyright 2025(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_adp1055.h" | ||
#include "common_data.h" | ||
#include "no_os_print_log.h" | ||
#include "iio_app.h" | ||
|
||
int example_main() | ||
{ | ||
int ret; | ||
|
||
struct adp1055_iio_desc *adp1055_iio_desc; | ||
struct adp1055_iio_desc_init_param adp1055_iio_ip = { | ||
.adp1055_init_param = &adp1055_ip, | ||
.vout_scale_monitor = 0xA155, | ||
.vin_scale_monitor = 0xB033, | ||
.iin_scale_monitor = 0x01, | ||
}; | ||
|
||
struct iio_app_desc *app; | ||
struct iio_app_init_param app_init_param = { 0 }; | ||
|
||
ret = adp1055_iio_init(&adp1055_iio_desc, &adp1055_iio_ip); | ||
if (ret) | ||
goto exit; | ||
|
||
struct iio_app_device iio_devices[] = { | ||
{ | ||
.name = "adp1055", | ||
.dev = adp1055_iio_desc, | ||
.dev_descriptor = adp1055_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 = adp1055_uart_ip; | ||
|
||
ret = iio_app_init(&app, app_init_param); | ||
if (ret) | ||
goto remove_iio_adp1055; | ||
|
||
ret = iio_app_run(app); | ||
|
||
iio_app_remove(app); | ||
|
||
remove_iio_adp1055: | ||
adp1055_iio_remove(adp1055_iio_desc); | ||
exit: | ||
if (ret) | ||
pr_info("Error!\n"); | ||
return ret; | ||
} |
Oops, something went wrong.