Skip to content

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
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,489 changes: 2,489 additions & 0 deletions drivers/magnetometer/admt4000/admt4000.c

Large diffs are not rendered by default.

957 changes: 957 additions & 0 deletions drivers/magnetometer/admt4000/admt4000.h

Large diffs are not rendered by default.

1,257 changes: 1,257 additions & 0 deletions drivers/magnetometer/admt4000/iio_admt4000.c

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions drivers/magnetometer/admt4000/iio_admt4000.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/***************************************************************************//**
* @file iio_admt4000.h
* @brief Header file of IIO ADMT4000 driver.
* @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.
*******************************************************************************/

#ifndef IIO_ADMT4000_H
#define IIO_ADMT4000_H

#include "iio.h"

struct admt4000_iio_dev {
struct admt4000_dev *admt4000_desc;
struct iio_device *iio_dev;
uint32_t active_channels;
uint8_t no_of_active_channels;
};

struct admt4000_iio_dev_init_param {
struct admt4000_init_param *admt4000_dev_init;
};

int admt4000_iio_init(struct admt4000_iio_dev **,
struct admt4000_iio_dev_init_param *);
int admt4000_iio_remove(struct admt4000_iio_dev *);

#endif
18 changes: 18 additions & 0 deletions projects/admt4000/Makefile
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
41 changes: 41 additions & 0 deletions projects/admt4000/src.mk
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
40 changes: 40 additions & 0 deletions projects/admt4000/src/app_src.mk
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
3 changes: 3 additions & 0 deletions projects/admt4000/src/examples/iio_example/example.mk
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
90 changes: 90 additions & 0 deletions projects/admt4000/src/examples/iio_example/iio_example.c
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;
}
39 changes: 39 additions & 0 deletions projects/admt4000/src/examples/iio_example/iio_example.h
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__ */
Loading