EVAL-AD7124 Mbed Example Program.
Dependencies: adi_console_menu platform_drivers
Revision 7:3e1005bd4d41, committed 2021-08-03
- Comitter:
- Kjansen
- Date:
- Tue Aug 03 12:05:42 2021 +0100
- Parent:
- 6:46c263287b2f
- Commit message:
- No-OS Adoption Changes:
* Updated the .lib files for adoption of no-OS repository as-is.
* Replaced platform_drivers.h with required header files.
* Added designated initializers for nanodac_init_params as the latest
spi_init_param in no-OS repository include a new field member platform_ops.
* Added Support Macros.
* Updated the copyright year of the nanodac_console_app.c file
Mbed OS update changes:
1) Added the mbed_app.json file with custom parameters
2) Updated the mbed-os version to 6.8.0
Updated the readme file.
Changed in this revision
diff -r 46c263287b2f -r 3e1005bd4d41 AD7124_no_OS.lib --- a/AD7124_no_OS.lib Wed Dec 02 11:23:19 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/teams/AnalogDevices/code/AD7124_no_OS/#48135b67356f
diff -r 46c263287b2f -r 3e1005bd4d41 README.txt --- a/README.txt Wed Dec 02 11:23:19 2020 +0000 +++ b/README.txt Tue Aug 03 12:05:42 2021 +0100 @@ -28,33 +28,18 @@ How to Get Started ------------------ Open Mbed online compiler. https://ide.mbed.com/compiler -Import Code into compiler from here: https://os.mbed.com/teams/AnalogDevices/code/EVAL-AD7124/ -instructions on how to import code are here: https://os.mbed.com/docs/mbed-os/v5.12/tools/importing-code.html -Compile code. Drag and drop binary into SDP-K1 controller board. Find detailed -instructions here: https://os.mbed.com/docs/mbed-os/v5.12/tools/getting-your-program-on-your-board.html -Open Tera Term (or alternative), select 115200 baud rate, and the applicable COM -port to see the list of options. +Import Code into compiler. Instructions on how to import code are here: https://os.mbed.com/docs/mbed-os/v6.8/quick-start/build-with-the-online-compiler.html +Compile code to generate binary file and then drag and drop binary into SDP-K1 controller board. Detailed instructions are here: +https://os.mbed.com/docs/mbed-os/v6.8/build-tools/getting-your-program-on-your-board.html + +Refer project wiki page to find detailed guide on how to use firmware: +https://wiki.analog.com/resources/tools-software/product-support-software/ad7124_mbed_support Notes ----- -If using Win 7, install serial drivers for Mbed. https://os.mbed.com/docs/mbed-os/v5.12/tutorials/windows-serial-driver.html +Refer this page for latest documentation on Mbed-OS: https://os.mbed.com/docs/mbed-os/v6.8/introduction/index.html A detailed user guide on SDP-K1 controller board is available here https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/SDP-K1.html. -License -------- -Copyright (c) 2019 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. - - Modified versions of the software must be conspicuously marked as such. - - This software is licensed solely and exclusively for use with processors/products manufactured by or for Analog Devices, Inc. - - This software may not be combined or merged with other code in any manner that would cause the software to become subject to terms and conditions which differ from those listed here. - - 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. - -THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL PROPERTY RIGHTS INFRINGEMENT; 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. - -2019-01-10-7CBSD SLA \ No newline at end of file +Copyright (c) 2021 Analog Devices, Inc. All rights reserved.
diff -r 46c263287b2f -r 3e1005bd4d41 adi_console_menu.lib --- a/adi_console_menu.lib Wed Dec 02 11:23:19 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/teams/AnalogDevices/code/adi_console_menu/#dcc17e5a913f
diff -r 46c263287b2f -r 3e1005bd4d41 app/.mbedignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/.mbedignore Tue Aug 03 12:05:42 2021 +0100 @@ -0,0 +1,50 @@ +mbed_platform_drivers/adc_data_capture.c +mbed_platform_drivers/uart.cpp +no-OS/ci/ +no-OS/doc/ +no-OS/legacy/ +no-OS/accel/ +no-OS/drivers/adc/adc_demo/ +no-OS/drivers/adc/ad4* +no-OS/drivers/adc/ad6* +no-OS/drivers/adc/ad70* +no-OS/drivers/adc/ad713x/ +no-OS/drivers/adc/ad7124/iio_ad7124.c +no-OS/drivers/adc/ad717x/ +no-OS/drivers/adc/ad7193/ +no-OS/drivers/adc/ad72* +no-OS/drivers/adc/ad73* +no-OS/drivers/adc/ad76* +no-OS/drivers/adc/ad77* +no-OS/drivers/adc/ad79* +no-OS/drivers/adc/ad9* +no-OS/drivers/adc/adaq* +no-OS/drivers/adc/l* +no-OS/drivers/afe/ +no-OS/drivers/amplifiers/ +no-OS/drivers/axi_core/ +no-OS/drivers/cdc/ +no-OS/drivers/dac/ +no-OS/drivers/ecg/ +no-OS/drivers/frequency/ +no-OS/drivers/gpio/ +no-OS/drivers/gyro/ +no-OS/drivers/i2c/ +no-OS/drivers/impedance-analyzer/ +no-OS/drivers/io-expander/ +no-OS/drivers/instr-amplif/ +no-OS/drivers/mux/ +no-OS/drivers/photo-electronic/ +no-OS/drivers/platform/ +no-OS/drivers/potentiometer/ +no-OS/drivers/rf-transceiver/ +no-OS/drivers/sd-card/ +no-OS/drivers/spi/ +no-OS/drivers/tdm/ +no-OS/drivers/temperature/ +no-OS/iio/ +no-OS/legacy/ +no-OS/libraries/ +no-OS/network/ +no-OS/projects/ +no-OS/tools/ \ No newline at end of file
diff -r 46c263287b2f -r 3e1005bd4d41 app/ad7124_console_app.c --- a/app/ad7124_console_app.c Wed Dec 02 11:23:19 2020 +0000 +++ b/app/ad7124_console_app.c Tue Aug 03 12:05:42 2021 +0100 @@ -8,7 +8,7 @@ The functions defined in this file performs the action based on user selected console menu. ----------------------------------------------------------------------------- - Copyright (c) 2019, 2020 Analog Devices, Inc. + Copyright (c) 2019-2021 Analog Devices, Inc. All rights reserved. This software is proprietary to Analog Devices, Inc. and its licensors. @@ -24,7 +24,9 @@ #include "app_config.h" #include "platform_support.h" -#include "platform_drivers.h" +#include "error.h" +#include "gpio.h" +#include "spi.h" #include "spi_extra.h" #include "ad7124.h" @@ -298,22 +300,23 @@ // Not a defined configID return(FAILURE); } + + // Designated SPI Initialization Structure + spi_init_param ad7124_spi_init = { + .max_speed_hz = 2500000, // Max SPI Speed + .chip_select = SPI_SS_A, // Chip Select pin + .mode = SPI_MODE_3, // CPOL = 1, CPHA =1 + .extra = &spi_init_extra_params // SPI extra configurations + }; // Used to create the ad7124 device struct ad7124_init_param sAd7124_init = { - // spi_init_param type - { - 2500000, // Max SPI Speed - SPI_SS_A, // Chip Select pin - SPI_MODE_3, // CPOL = 1, CPHA =1 - &spi_init_extra_params, // SPI extra configurations - }, + &ad7124_spi_init, // spi_init_param type ad7124_register_map, - 10000 // Retry count for polling }; - return (ad7124_setup(&pAd7124_dev, sAd7124_init)); + return (ad7124_setup(&pAd7124_dev, &sAd7124_init)); } // Private Functions
diff -r 46c263287b2f -r 3e1005bd4d41 app/ad7124_support.h --- a/app/ad7124_support.h Wed Dec 02 11:23:19 2020 +0000 +++ b/app/ad7124_support.h Tue Aug 03 12:05:42 2021 +0100 @@ -6,7 +6,7 @@ @details: ----------------------------------------------------------------------------- - Copyright (c) 2019, 2020 Analog Devices, Inc. + Copyright (c) 2019-2021 Analog Devices, Inc. All rights reserved. This software is proprietary to Analog Devices, Inc. and its licensors. @@ -18,6 +18,7 @@ #define AD7124_SUPPORT_H_ #include "ad7124.h" +#include "util.h" /* PGA Gain Value */ #define AD7124_PGA_GAIN(x) (1 << (x)) @@ -25,6 +26,37 @@ #define AD7124_REF_VOLTAGE 2.5 #define AD7124_ADC_N_BITS 24 +/* ADC_Control Register bits */ +#define AD7124_ADC_CTRL_REG_POWER_MODE_MSK GENMASK(7,6) +#define AD7124_ADC_CTRL_REG_POWER_MODE_RD(x) (((x) >> 6) & 0x3) +#define AD7124_ADC_CTRL_REG_MSK GENMASK(5,2) + +/* Channel Registers 0-15 bits */ +#define AD7124_CH_MAP_REG_CH_ENABLE_RD(x) (((x) >> 15) & 0x1) +#define AD7124_CH_MAP_REG_SETUP_MSK GENMASK(14, 12) +#define AD7124_CH_MAP_REG_SETUP_RD(x) (((x) >> 12) & 0x7) +#define AD7124_CH_MAP_REG_AINP_MSK GENMASK(9, 5) +#define AD7124_CH_MAP_REG_AINP_RD(x) (((x) >> 5) & 0x1F) +#define AD7124_CH_MAP_REG_AINM_MSK GENMASK(4, 0) +#define AD7124_CH_MAP_REG_AINM_RD(x) (((x) >> 0) & 0x1F) + +/* Configuration Registers 0-7 bits */ +#define AD7124_CFG_REG_BIPOLAR_RD(x) (((x) >> 11) & 0x1) +#define AD7124_CFG_REG_REF_BUFP_RD(x) (((x) >> 8) & 0x1) +#define AD7124_CFG_REG_REF_BUFM_RD(x) (((x) >> 7) & 0x1) +#define AD7124_CFG_REG_AIN_BUFP_RD(x) (((x) >> 6) & 0x1) +#define AD7124_CFG_REG_AINM_BUFP_RD(x) (((x) >> 5) & 0x1) +#define AD7124_CFG_REG_REF_SEL_MSK GENMASK(4, 3) +#define AD7124_CFG_REG_REF_SEL_RD(x) (((x) >> 3) & 0x3) +#define AD7124_CFG_REG_PGA_MSK GENMASK(2, 0) +#define AD7124_CFG_REG_PGA_RD(x) (((x) >> 0) & 0x7) + +/* Filter Register 0-7 bits */ +#define AD7124_FILT_REG_FILTER_MSK GENMASK(23, 21) +#define AD7124_FILT_REG_FILTER_RD(x) (((x) >> 21) & 0x7) +#define AD7124_FILT_REG_FS_MSK GENMASK(10, 0) +#define AD7124_FILT_REG_FS_RD(x) (((x) >> 0) & 0x7FF) + uint8_t ad7124_get_channel_setup(struct ad7124_dev *dev, uint8_t channel); uint8_t ad7124_get_channel_pga(struct ad7124_dev *dev, uint8_t channel); bool ad7124_get_channel_bipolar(struct ad7124_dev *dev, uint8_t channel);
diff -r 46c263287b2f -r 3e1005bd4d41 app/adi_console_menu.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/adi_console_menu.lib Tue Aug 03 12:05:42 2021 +0100 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/AnalogDevices/code/adi_console_menu/#ced4fa6875ed \ No newline at end of file
diff -r 46c263287b2f -r 3e1005bd4d41 app/app_config.h --- a/app/app_config.h Wed Dec 02 11:23:19 2020 +0000 +++ b/app/app_config.h Tue Aug 03 12:05:42 2021 +0100 @@ -29,17 +29,11 @@ // Pin mapping of AD7124 with SDP-K1/Arduino (reference: PinNames.h) #ifdef ARDUINO -#define I2C_SCL D15 // I2C_SCL -#define I2C_SDA D14 // I2C_SDA - #define SPI_SS_A D10 // SPI_CS -#define SPI_MISO D11 // SPI_MISO -#define SPI_MOSI D12 // SPI_MOSI +#define SPI_MISO D12 // SPI_MISO +#define SPI_MOSI D11 // SPI_MOSI #define SPI_SCK D13 // SPI_SCK #else -#define I2C_SCL SDP_I2C_SCL // PH_7 -#define I2C_SDA SDP_I2C_SDA // PC_9 - #define SPI_SS_A SDP_SPI_CS_A // PB_9 #define SPI_MISO SDP_SPI_MISO // PF_8 #define SPI_MOSI SDP_SPI_MOSI // PF_9
diff -r 46c263287b2f -r 3e1005bd4d41 app/mbed_platform_drivers.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/mbed_platform_drivers.lib Tue Aug 03 12:05:42 2021 +0100 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/AnalogDevices/code/platform_drivers/#af1f2416dd26 \ No newline at end of file
diff -r 46c263287b2f -r 3e1005bd4d41 app/no-OS.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/no-OS.lib Tue Aug 03 12:05:42 2021 +0100 @@ -0,0 +1,1 @@ +https://github.com/analogdevicesinc/no-OS/#d14f824a6bee78881a277790310b12d9a3e822bd \ No newline at end of file
diff -r 46c263287b2f -r 3e1005bd4d41 mbed-os.lib --- a/mbed-os.lib Wed Dec 02 11:23:19 2020 +0000 +++ b/mbed-os.lib Tue Aug 03 12:05:42 2021 +0100 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#5941d1718339116cd12914238ec331c84da3d08f +https://github.com/ARMmbed/mbed-os/#26606218ad9d1ee1c8781aa73774fd7ea3a7658e
diff -r 46c263287b2f -r 3e1005bd4d41 mbed_app.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_app.json Tue Aug 03 12:05:42 2021 +0100 @@ -0,0 +1,10 @@ +{ + "requires": ["bare-metal"], + "target_overrides": { + "*": { + "platform.default-serial-baud-rate": 230400, + "target.printf_lib": "std", + "target.device_has_remove": ["CAN"] + } + } +} \ No newline at end of file
diff -r 46c263287b2f -r 3e1005bd4d41 platform_drivers.lib --- a/platform_drivers.lib Wed Dec 02 11:23:19 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/teams/AnalogDevices/code/platform_drivers/#70fc373a5f46