
IIO firmware for the AD717x and AD411x family of devices.
Dependencies: sdp_k1_sdram
Revision 2:d0c2d3e1fb93, committed 2022-09-29
- Comitter:
- Janani Sunil
- Date:
- Thu Sep 29 09:02:39 2022 +0530
- Parent:
- 1:f71de62b7179
- Child:
- 3:0dcba3253ec1
- Commit message:
- V3: Fixed issues with data capturing in continuous read mode
Changed in this revision
--- a/app/ad717x_data_capture.c Fri Jun 10 09:37:03 2022 +0530 +++ b/app/ad717x_data_capture.c Thu Sep 29 09:02:39 2022 +0530 @@ -23,6 +23,7 @@ #include "ad717x_support.h" #include "no_os_error.h" #include "ad717x_user_config.h" +#include "no_os_delay.h" /******************************************************************************/ /********************* Macros and Constants Definition ************************/ @@ -37,6 +38,8 @@ * is tested for SDP-K1 platform @180Mhz default core clock */ #define BUF_READ_TIMEOUT 0xffffffff +#define AD717x_CONV_TIMEOUT 10000 + /******************************************************************************/ /******************** Variables and User Defined Data Types *******************/ /******************************************************************************/ @@ -156,7 +159,7 @@ int32_t prepare_data_transfer(uint32_t ch_mask, uint8_t num_of_chns, uint8_t sample_size) { - uint8_t mask = 0x1; + uint32_t mask = 0x1; int32_t ret; uint8_t ch_id; @@ -223,10 +226,36 @@ */ int32_t end_data_transfer(void) { - int32_t ret; + int32_t ret = 0; start_cont_data_capture = false; + uint32_t adc_raw_data; + uint8_t rdy_value = NO_OS_GPIO_LOW; + uint32_t timeout = AD717x_CONV_TIMEOUT; #if (DATA_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) + ret = no_os_irq_disable(external_int_desc, IRQ_INT_ID); + if (ret) { + return ret; + } + + /* Read the data register when RDY is low to exit continuous read mode */ + do { + ret = no_os_gpio_get_value(rdy_gpio, &rdy_value); + if (ret) { + return ret; + } + timeout--; + } while ((rdy_value != NO_OS_GPIO_LOW) && (timeout > 0)); + + if (timeout == 0) { + return -ETIMEDOUT; + } + + ret = AD717X_ReadData(p_ad717x_dev_inst, &adc_raw_data); + if (ret) { + return ret; + } + /* Disable continous read mode */ ret = ad717x_enable_cont_read(p_ad717x_dev_inst, false); if (ret) {
--- a/app/app_config.c Fri Jun 10 09:37:03 2022 +0530 +++ b/app/app_config.c Thu Sep 29 09:02:39 2022 +0530 @@ -37,6 +37,9 @@ /* GPIO descriptor for the chip select pin */ struct no_os_gpio_desc *csb_gpio; +/* GPIO descriptor for the RDY pin */ +struct no_os_gpio_desc *rdy_gpio; + /* External interrupt descriptor */ struct no_os_irq_ctrl_desc *external_int_desc; @@ -57,6 +60,13 @@ .extra = NULL }; +/* GPIO RDY Pin init parameters */ +static struct no_os_gpio_init_param rdy_init_param = { + .number = RDY_PIN, + .platform_ops = &rdy_platform_ops, + .extra = NULL +}; + /* External interrupt init parameters */ static struct no_os_irq_init_param ext_int_init_params = { .irq_ctrl_id = 0, @@ -152,6 +162,16 @@ if (ret) { return ret; } + + ret = no_os_gpio_get(&rdy_gpio, &rdy_init_param); + if (ret) { + return ret; + } + + ret = no_os_gpio_direction_input(rdy_gpio); + if (ret) { + return ret; + } #endif return 0; } \ No newline at end of file
--- a/app/app_config.h Fri Jun 10 09:37:03 2022 +0530 +++ b/app/app_config.h Thu Sep 29 09:02:39 2022 +0530 @@ -98,6 +98,7 @@ #define spi_extra_init_params mbed_spi_extra_init_params #define ext_int_extra_init_params mbed_ext_int_extra_init_params #define csb_platform_ops mbed_gpio_ops +#define rdy_platform_ops mbed_gpio_ops #define irq_platform_ops mbed_irq_ops #define spi_platform_ops mbed_spi_ops #define IRQ_INT_ID EXTERNAL_INT_ID1 @@ -288,6 +289,8 @@ extern struct no_os_gpio_desc *csb_gpio; +extern struct no_os_gpio_desc *rdy_gpio; + extern struct no_os_irq_ctrl_desc *external_int_desc; int32_t init_system(void);