Skip to content

Commit

Permalink
projects:ad405x_iio: Add AD4050 support
Browse files Browse the repository at this point in the history
1. Add appropriate bit resolutions for the devices
2. Bug fix - Move if directives to suitable places
3. Remove reference of adc drivers present in app folder from
   .extSettings
4. Migrate CubeMX to 6.11.1

Signed-off-by: Anush Shetty <[email protected]>
  • Loading branch information
Shetty-Anush authored and SaikiranGudla committed Nov 7, 2024
1 parent b1cd310 commit 8f05208
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion projects/ad405x_iio/STM32/.extSettings
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
HeaderPath=../app;../../../libraries/no-OS/util;../../../libraries/no-OS/include;../../../libraries/no-OS/drivers/platform/stm32;../../../libraries/no-OS/iio;../../../libraries/no-OS/drivers/api;../../../libraries/precision-converters-library/board_info/;../../../libraries/no-OS/drivers/eeprom/24xx32a/;../../../libraries/precision-converters-library/sdp_k1_sdram/;../../../libraries/precision-converters-library/common/;../../../libraries/no-OS/drivers/adc/ad405x/;

[Groups]
app/=../app/main.c;../app/ad405x.c;../app/ad405x.h;../app/ad405x_iio.c;../app/ad405x_iio.h;../app/app_config.h;../app/app_config.c;../app/app_config_stm32.c;../app/app_config_stm32.h;../app/stm32_gpio_irq_generated.c;../app/ad405x_user_config.c;../app/ad405x_user_config.h;
app/=../app/main.c;../app/ad405x_iio.c;../app/ad405x_iio.h;../app/app_config.h;../app/app_config.c;../app/app_config_stm32.c;../app/app_config_stm32.h;../app/stm32_gpio_irq_generated.c;../app/ad405x_user_config.c;../app/ad405x_user_config.h;

app/libraries/precision-converters-library/board_info/=../../../libraries/precision-converters-library/board_info/board_info.c;../../../libraries/precision-converters-library/board_info/board_info.h;

Expand Down
6 changes: 3 additions & 3 deletions projects/ad405x_iio/STM32/ad405x_iio.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ Mcu.PinsNb=21
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F469NIHx
MxCube.Version=6.10.0
MxDb.Version=DB.6.0.100
MxCube.Version=6.11.1
MxDb.Version=DB.6.0.111
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.DMA2_Stream0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
Expand Down Expand Up @@ -158,7 +158,7 @@ ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32F469NIHx
ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.27.1
ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.28.1
ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200
Expand Down
12 changes: 1 addition & 11 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
13 changes: 8 additions & 5 deletions projects/ad405x_iio/app/app_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#define ADC_CAPTURE_MODE SAMPLE_MODE
#endif

/* Select the ADC output data format (default is straight binary mode) */
/* Select the ADC output data format (default is twos complement mode) */
#if !defined(ADC_DATA_FORMAT)
#define ADC_DATA_FORMAT TWOS_COMPLEMENT
#endif
Expand Down 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 8f05208

Please sign in to comment.