-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Dev/admt4000 #2462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Lcompo
wants to merge
4
commits into
analogdevicesinc:main
Choose a base branch
from
Lcompo:dev/admt4000
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Dev/admt4000 #2462
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a4074c0
drivers: magnetometer: admt4000: add driver for admt4000
Lcompo 644daa0
drivers: magnetometer: admt4000: add iio support
Lcompo 3a1c28f
projects: admt4000: add examples for ADMT4000
Lcompo 4bffbf0
projects: admt4000: Add documentation for ADMT4000 examples
Lcompo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,18 @@ | ||
# # Select the example measurement flows to include / enable | ||
# ADMT4000_BASIC = n # Basic Angles and Turns Measurement | ||
# ADMT4000_DIAG = n # Diagnostic Loop (i.e., temp, reference resistor etc.) | ||
# ADMT4000_TEST = n # Functional Configuration Test | ||
# ADMT4000_ECC = n # Demonstrate ECC computation flow | ||
ADMT4000_IIO = y # IIO compatible firmware (i.e., iio oscilloscope) | ||
|
||
PLATFORM = mbed | ||
|
||
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 hidden or 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,41 @@ | ||
############################################################################# | ||
# # | ||
# Shared variables: # | ||
# - DRIVERS # | ||
# - INCLUDE # | ||
# - PLATFORM_DRIVERS # | ||
# - NO-OS # | ||
# # | ||
############################################################################# | ||
|
||
include $(PROJECT)/src/app_src.mk | ||
|
||
INCS += $(INCLUDE)/no_os_delay.h \ | ||
$(INCLUDE)/no_os_dma.h \ | ||
$(INCLUDE)/no_os_error.h \ | ||
$(INCLUDE)/no_os_gpio.h \ | ||
$(INCLUDE)/no_os_print_log.h \ | ||
$(INCLUDE)/no_os_spi.h \ | ||
$(INCLUDE)/no_os_irq.h \ | ||
$(INCLUDE)/no_os_list.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 \ | ||
$(PROJECT)/src/platform/platform_includes.h | ||
|
||
SRCS += $(DRIVERS)/api/no_os_dma.c \ | ||
$(DRIVERS)/api/no_os_gpio.c \ | ||
$(NO-OS)/util/no_os_lf256fifo.c \ | ||
$(DRIVERS)/api/no_os_irq.c \ | ||
$(DRIVERS)/api/no_os_spi.c \ | ||
$(DRIVERS)/api/no_os_uart.c \ | ||
$(NO-OS)/util/no_os_list.c \ | ||
$(NO-OS)/util/no_os_util.c \ | ||
$(NO-OS)/util/no_os_alloc.c \ | ||
$(NO-OS)/util/no_os_mutex.c | ||
|
||
INCS += $(DRIVERS)/magnetometer/admt4000/admt4000.h | ||
SRCS += $(DRIVERS)/magnetometer/admt4000/admt4000.c |
This file contains hidden or 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,40 @@ | ||
ifeq (y,$(strip $(ADMT4000_IIO))) | ||
IIOD=y | ||
CFLAGS += -DADMT4000_IIO=1 | ||
SRCS += $(PROJECT)/src/examples/iio_example/iio_example.c | ||
INCS += $(PROJECT)/src/examples/iio_example/iio_example.h | ||
endif | ||
|
||
ifeq (y,$(strip $(IIOD))) | ||
SRC_DIRS += $(NO-OS)/iio/iio_app | ||
INCS += $(DRIVERS)/magnetometer/admt4000/iio_admt4000.h | ||
SRCS += $(DRIVERS)/magnetometer/admt4000/iio_admt4000.c | ||
|
||
INCS += $(INCLUDE)/no_os_list.h \ | ||
$(PLATFORM_DRIVERS)/$(PLATFORM)_uart.h | ||
|
||
endif | ||
|
||
ifeq (y,$(strip $(ADMT4000_TEST))) | ||
CFLAGS += -DADMT4000_TEST=1 | ||
SRCS += $(ADMT_EXAMPLES)/test/admt4000_function_test.c | ||
INCS += $(ADMT_EXAMPLES)/test/admt4000_function_test.h | ||
endif | ||
|
||
ifeq (y,$(strip $(ADMT4000_BASIC))) | ||
CFLAGS += -DADMT4000_BASIC=1 | ||
SRCS += $(ADMT_EXAMPLES)/basic_example/admt4000_basic.c | ||
INCS += $(ADMT_EXAMPLES)/basic_example/admt4000_basic.h | ||
endif | ||
|
||
ifeq (y,$(strip $(ADMT4000_DIAG))) | ||
CFLAGS += -DADMT4000_DIAG=1 | ||
SRCS += $(ADMT_EXAMPLES)/diagnostic_example/admt4000_diag_example.c | ||
INCS += $(ADMT_EXAMPLES)/diagnostic_example/admt4000_diag_example.h | ||
endif | ||
|
||
ifeq (y,$(strip $(ADMT4000_ECC))) | ||
CFLAGS += -DADMT4000_ECC=1 | ||
SRCS += $(ADMT_EXAMPLES)/ecc_example/admt4000_ecc.c | ||
INCS += $(ADMT_EXAMPLES)/ecc_example/admt4000_ecc.h | ||
endif |
This file contains hidden or 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)/magnetometer/admt4000/iio_admt4000.h | ||
SRCS += $(DRIVERS)/magnetometer/admt4000/iio_admt4000.c |
This file contains hidden or 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,90 @@ | ||
/***************************************************************************//** | ||
* @file iio_example.c | ||
* @brief Source file for iio example. | ||
* @author Jose Ramon San Buenaventura (jose.sanbuenaventura@analog.com) | ||
* @author Louijie Compo (louijie.compo@analog.com) | ||
******************************************************************************** | ||
* Copyright 2020(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_example.h" | ||
#include "iio_admt4000.h" | ||
#include "platform_includes.h" | ||
#include "no_os_print_log.h" | ||
#include "iio_app.h" | ||
#include "no_os_util.h" | ||
|
||
int iio_example_main() | ||
{ | ||
int ret; | ||
|
||
/** IIO descriptor and initialization parameter. */ | ||
struct admt4000_iio_dev *admt4000_iio_desc; | ||
|
||
struct admt4000_iio_dev_init_param admt4000_iio_ip = { | ||
.admt4000_dev_init = &admt_ip, | ||
}; | ||
|
||
/** IIO app. */ | ||
struct iio_app_desc *app; | ||
struct iio_app_init_param app_init_param = { 0 }; | ||
|
||
ret = admt4000_iio_init(&admt4000_iio_desc, &admt4000_iio_ip); | ||
if (ret) | ||
goto exit; | ||
|
||
/** Declaring iio_devices structure */ | ||
struct iio_app_device iio_devices[] = { | ||
{ | ||
.name = "admt4000", | ||
.dev = admt4000_iio_desc, | ||
.dev_descriptor = admt4000_iio_desc->iio_dev, | ||
}, | ||
}; | ||
|
||
/** Initializing IIO app init param. */ | ||
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; | ||
|
||
/** Initializing IIO app. */ | ||
ret = iio_app_init(&app, app_init_param); | ||
if (ret) | ||
goto iio_admt4000_remove; | ||
|
||
/** Running the IIO app (use iio_info or osc in terminal). */ | ||
ret = iio_app_run(app); | ||
|
||
iio_app_remove(app); | ||
|
||
iio_admt4000_remove: | ||
admt4000_iio_remove(admt4000_iio_desc); | ||
exit: | ||
if (ret) | ||
pr_info("Error!\n"); | ||
return ret; | ||
} |
This file contains hidden or 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,39 @@ | ||
/***************************************************************************//** | ||
* @file iio_example.h | ||
* @brief Header file for iio example. | ||
* @author JSanbuen(jose.sanbuenaventura@analog.com) | ||
* @author Louijie Compo (louijie.compo@analog.com) | ||
******************************************************************************** | ||
* Copyright 2020(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 __IIO_EXAMPLE_H__ | ||
#define __IIO_EXAMPLE_H__ | ||
|
||
int iio_example_main(); | ||
|
||
#endif /* __IIO_EXAMPLE_H__ */ |
This file contains hidden or 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,152 @@ | ||
/***************************************************************************//** | ||
* @file main.c | ||
* @brief Main file for Mbed platform of admt4000 project | ||
* @author Jose Ramon San Buenaventura (jose.sanbuenaventura@analog.com) | ||
* Louijie Compo (louijie.compo@analog.com) | ||
******************************************************************************** | ||
* 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 Files **********************************/ | ||
/******************************************************************************/ | ||
#include "platform_includes.h" | ||
#include "parameters.h" | ||
#include "no_os_delay.h" | ||
#include "no_os_print_log.h" | ||
#include "no_os_error.h" | ||
#include "admt4000.h" | ||
|
||
#if (ADMT4000_BASIC) | ||
#include "admt4000_basic.h" | ||
#endif | ||
|
||
#if (ADMT4000_DIAG) | ||
#include "admt4000_diag_example.h" | ||
#endif | ||
|
||
#if (ADMT4000_ECC) | ||
#include "admt4000_ecc.h" | ||
#endif | ||
|
||
#if (ADMT4000_TEST) | ||
#include "admt4000_function_test.h" | ||
#endif | ||
|
||
#if (ADMT4000_IIO) | ||
#include "iio_example.h" | ||
#include "iio_app.h" | ||
#endif | ||
|
||
/******************************************************************************/ | ||
/********************** Macros and Constants Definitions **********************/ | ||
/******************************************************************************/ | ||
|
||
/******************************************************************************/ | ||
/************************ Functions Declarations ******************************/ | ||
/******************************************************************************/ | ||
|
||
/***************************************************************************//** | ||
* @brief App main execution. | ||
* | ||
* @return ret - Result of the example execution. If working correctly, will | ||
* execute continuously the chosen example and will not return. | ||
*******************************************************************************/ | ||
int main() | ||
{ | ||
struct admt4000_dev *admt; | ||
struct no_os_uart_desc *uart_desc; | ||
struct no_os_spi_desc *spi_desc; | ||
int ret; | ||
uint8_t sw_cfg[1] = {0xff}; | ||
|
||
#if (ADMT4000_BASIC + ADMT4000_DIAG + ADMT4000_TEST + ADMT4000_ECC + ADMT4000_IIO > 1) | ||
#error Please enable only 1 example at a time. | ||
#elif (ADMT4000_BASIC + ADMT4000_DIAG + ADMT4000_TEST + ADMT4000_ECC + ADMT4000_IIO == 0) | ||
#error Please enable 1 example from the Makefile. | ||
#endif | ||
|
||
/* Initialize SPI for switch configuration */ | ||
ret = no_os_spi_init(&spi_desc, &spi_sel_b_spi_ip); | ||
if (ret) | ||
return ret; | ||
|
||
/* Configure ADG714 over SPI using SPI_SEL_B_N pin */ | ||
ret = no_os_spi_write_and_read(spi_desc, sw_cfg, 1); | ||
if (ret) | ||
return ret; | ||
|
||
#if (ADMT4000_IIO) | ||
ret = iio_example_main(); | ||
if (ret) | ||
goto error; | ||
#endif | ||
|
||
no_os_mdelay(100); | ||
|
||
/* Initialize UART */ | ||
ret = no_os_uart_init(&uart_desc, &uart_ip); | ||
if (ret) | ||
return ret; | ||
|
||
no_os_uart_stdio(uart_desc); | ||
|
||
pr_info("\n SPI switch configured\n"); | ||
|
||
/* Initialize ADMT */ | ||
ret = admt4000_init(&admt, admt_ip); | ||
if (ret) | ||
return ret; | ||
|
||
#if (ADMT4000_BASIC) | ||
ret = basic_meas(admt); | ||
|
||
#elif (ADMT4000_DIAG) | ||
ret = diag_meas(admt); | ||
|
||
#elif (ADMT4000_ECC) | ||
ret = ecc_main(admt); | ||
|
||
#elif (ADMT4000_TEST) | ||
ret = function_test(admt); | ||
#endif | ||
|
||
error: | ||
#ifndef ADMT4000_IIO | ||
no_os_uart_remove(uart_desc); | ||
#endif | ||
admt4000_remove(admt); | ||
|
||
return ret; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also can you please remove all these code comment blocks from this project commit ?