Skip to content

Commit

Permalink
projects:ad405x_iio: AD4050 support was added
Browse files Browse the repository at this point in the history
1. Appropriate bit resolutions were added for the devices
2. Bug fix - if directive were moved to suitable places

Signed-off-by: Anush Shetty <[email protected]>
  • Loading branch information
Shetty-Anush committed Oct 29, 2024
1 parent b1cd310 commit 32cb93a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
22 changes: 6 additions & 16 deletions projects/ad405x_iio/app/ad405x_iio.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,16 +525,6 @@ static int iio_ad405x_attr_get(void *device,

switch (priv) {
case ADC_RAW:
#if (ACTIVE_PLATFORM == MBED_PLATFORM)
/* By default Mbed configures the I/O direction of a gpio
* (when used for PWM) in analog mode, after disabling or
* removing the PWM object.
* In this applications, the conversion trigger pin is being shared with
* ad405x drivers as gpio output pin and is configured in output mode
* only when it is initialized.
* Hence we need to reinitialize the gpio so that ad405x drivers
* can gain access to pin configured in output mode.
* */
ret = no_os_gpio_remove(p_ad405x_dev->gpio_cnv);
if (ret) {
return ret;
Expand All @@ -549,7 +539,7 @@ static int iio_ad405x_attr_get(void *device,
if (ret) {
return ret;
}
#endif

#if (ADC_CAPTURE_MODE == SAMPLE_MODE)
ret = ad405x_set_adc_mode(p_ad405x_dev);
#elif (ADC_CAPTURE_MODE == BURST_AVERAGING_MODE)
Expand Down Expand Up @@ -1482,11 +1472,11 @@ int32_t iio_ad405x_initialize(void)

/* Read context attributes */
init_status = get_iio_context_attributes(&iio_init_params.ctx_attrs,
&iio_init_params.nb_ctx_attr,
eeprom_desc,
HW_MEZZANINE_NAME,
STR(HW_CARRIER_NAME),
&hw_mezzanine_is_valid);
&iio_init_params.nb_ctx_attr,
eeprom_desc,
HW_MEZZANINE_NAME,
STR(HW_CARRIER_NAME),
&hw_mezzanine_is_valid);
if (init_status) {
return init_status;
}
Expand Down
11 changes: 7 additions & 4 deletions projects/ad405x_iio/app/app_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,24 @@
#define DEVICE_NAME "DEV_AD4052"
#define ACTIVE_DEVICE_ID ID_AD4052
#define HW_MEZZANINE_NAME "EVAL-AD4052-ARDZ"
#define ADC_SAMPLE_MODE_RESOLUTION 16
#define ADC_AVERAGING_MODE_RESOLUTION 20
#define ADC_BURST_AVG_MODE_RESOLUTION 20
#elif defined(DEV_AD4050)
#define ACTIVE_DEVICE_NAME "ad4050"
#define DEVICE_NAME "DEV_AD4050"
#define ACTIVE_DEVICE_ID ID_AD4050
#define HW_MEZZANINE_NAME "EVAL-AD4050-ARDZ"
#define ADC_BURST_AVG_MODE_RESOLUTION 16
#define ADC_SAMPLE_MODE_RESOLUTION 12
#define ADC_AVERAGING_MODE_RESOLUTION 14
#define ADC_BURST_AVG_MODE_RESOLUTION 14
#else
#define ACTIVE_DEVICE_NAME "ad4052"
#define DEVICE_NAME "DEV_AD4052"
#define ACTIVE_DEVICE_ID ID_AD4052
#define HW_MEZZANINE_NAME "EVAL-AD4052-ARDZ"
#define ADC_SAMPLE_MODE_RESOLUTION 16
#define ADC_AVERAGING_MODE_RESOLUTION 20
#define ADC_BURST_AVG_MODE_RESOLUTION 20
#endif

Expand All @@ -139,9 +145,6 @@
#error "No/Invalid active platform selected"
#endif

/* ADC resolution for active device */
#define ADC_SAMPLE_MODE_RESOLUTION 16
#define ADC_AVERAGING_MODE_RESOLUTION 24 //TODO check if it works for AD4050 too
#define DEFAULT_BURST_SAMPLE_RATE 2000000

/* ADC reference voltage (Range: 2.5 to 3.3v) */
Expand Down
4 changes: 2 additions & 2 deletions projects/ad405x_iio/app/app_config_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ void stm32_system_init(void)
#endif
}

#if (INTERFACE_MODE == SPI_DMA)
/**
* @brief Callback function to flag the capture of half the number
* of requested samples.
Expand Down Expand Up @@ -302,7 +303,6 @@ void stm32_timer_stop(void)
* @return None
*/

#if (INTERFACE_MODE == SPI_DMA)
void receivecomplete_callback(DMA_HandleTypeDef * hdma)
{
if (!dma_cycle_count) {
Expand Down Expand Up @@ -335,7 +335,6 @@ void receivecomplete_callback(DMA_HandleTypeDef * hdma)

return;
}
#endif

/**
* @brief Configures the chip select pin as output mode.
Expand Down Expand Up @@ -431,3 +430,4 @@ void tim8_config(void)

TIM8->DIER |= TIM_DIER_CC1DE; // Generate DMA request after overflow
}
#endif

0 comments on commit 32cb93a

Please sign in to comment.