diff --git a/projects/ad405x_iio/STM32/ad405x_iio.ioc b/projects/ad405x_iio/STM32/ad405x_iio.ioc index 875a84ae..99fc57e7 100644 --- a/projects/ad405x_iio/STM32/ad405x_iio.ioc +++ b/projects/ad405x_iio/STM32/ad405x_iio.ioc @@ -534,8 +534,9 @@ UART5.BaudRate=230400 UART5.IPParameters=VirtualMode,BaudRate UART5.VirtualMode=Asynchronous USB_DEVICE.CLASS_NAME_HS=CDC -USB_DEVICE.IPParameters=VirtualMode-CDC_HS,VirtualModeHS,CLASS_NAME_HS,VID-CDC_HS,PID_CDC_HS +USB_DEVICE.IPParameters=VirtualMode-CDC_HS,VirtualModeHS,CLASS_NAME_HS,VID-CDC_HS,PID_CDC_HS,PRODUCT_STRING_CDC_HS USB_DEVICE.PID_CDC_HS=0xB66C +USB_DEVICE.PRODUCT_STRING_CDC_HS=STM32_Virtual_COM_Port USB_DEVICE.VID-CDC_HS=0x0456 USB_DEVICE.VirtualMode-CDC_HS=Cdc USB_DEVICE.VirtualModeHS=Cdc_HS diff --git a/projects/ad405x_iio/app/ad405x_iio.c b/projects/ad405x_iio/app/ad405x_iio.c index f9c73b16..e7d6ba3d 100644 --- a/projects/ad405x_iio/app/ad405x_iio.c +++ b/projects/ad405x_iio/app/ad405x_iio.c @@ -322,7 +322,7 @@ static struct iio_attribute ad405x_debug_attributes[] = { volatile struct iio_device_data* iio_dev_data_g; /* Global variable for number of samples */ -uint32_t nb_of_samples_g; +uint32_t nb_of_bytes_g; /* Global variable for data read from CB functions */ int32_t data_read; @@ -935,7 +935,6 @@ int32_t ad405x_stop_data_capture(void) if (ret) { return ret; } -#endif #if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) ret = iio_trig_disable(ad405x_hw_trig_desc); @@ -948,6 +947,7 @@ int32_t ad405x_stop_data_capture(void) return ret; } #endif +#endif #if (INTERFACE_MODE == SPI_DMA) /* Abort DMA and Timers and configure CS and CNV as GPIOs */ @@ -987,7 +987,7 @@ static int32_t iio_ad405x_prepare_transfer(void *dev, uint32_t mask) { int ret; -#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) +#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) && (INTERFACE_MODE == SPI_INTERRUPT) return ad405x_start_data_capture(); #endif @@ -1072,7 +1072,7 @@ static int32_t iio_ad405x_submit_samples(struct iio_device_data *iio_dev_data) uint16_t spirxdma_ndtr; nb_of_samples = iio_dev_data->buffer->size / BYTES_PER_SAMPLE; - nb_of_samples_g = nb_of_samples; + nb_of_bytes_g = nb_of_samples * BYTES_PER_SAMPLE; iio_dev_data_g = iio_dev_data; if (!buf_size_updated) { @@ -1179,7 +1179,6 @@ static int32_t iio_ad405x_submit_samples(struct iio_device_data *iio_dev_data) no_os_cb_end_async_write(iio_dev_data->buffer->buf); #else - if (!dma_config_updated) { ret = no_os_cb_prepare_async_write(iio_dev_data->buffer->buf, nb_of_samples * (BYTES_PER_SAMPLE), @@ -1192,7 +1191,7 @@ static int32_t iio_ad405x_submit_samples(struct iio_device_data *iio_dev_data) struct no_os_spi_msg ad405x_spi_msg = { .tx_buff = (uint32_t*)local_tx_data, .rx_buff = (uint32_t*)buff_start_addr, - .bytes_number = nb_of_samples * (BYTES_PER_SAMPLE) + .bytes_number = spirxdma_ndtr }; ret = no_os_spi_transfer_dma_async(p_ad405x_dev->spi_desc, @@ -1207,8 +1206,9 @@ static int32_t iio_ad405x_submit_samples(struct iio_device_data *iio_dev_data) no_os_pwm_disable(sdesc->pwm_desc); // CS PWM htim2.Instance->CNT = 0; htim1.Instance->CNT = 0; + TIM8->CNT = 0; dma_config_updated = true; - tim8_config(); + stm32_timer_enable(); } @@ -1237,7 +1237,6 @@ static int32_t ad405x_trigger_handler(struct iio_device_data *iio_dev_data) buf_size_updated = true; } -#if (INTERFACE_MODE == SPI_INTERRUPT) #if (ADC_CAPTURE_MODE == AVERAGING_MODE) cnv_count += 1; if (cnv_count < (1 << (1 + p_ad405x_dev->filter_length))) { @@ -1256,11 +1255,6 @@ static int32_t ad405x_trigger_handler(struct iio_device_data *iio_dev_data) #endif return no_os_cb_write(iio_dev_data->buffer->buf, &data_read, BYTES_PER_SAMPLE); -#else - no_os_cb_prepare_async_write(iio_dev_data->buffer->buf, - nb_of_samples * (BYTES_PER_SAMPLE), &buff_start_addr, &data_read); - no_os_cb_end_async_write(iio_dev_data->buffer->buf); -#endif } /*! @@ -1468,7 +1462,7 @@ int32_t iio_ad405x_initialize(void) enum ad405x_device_type dev_type; uint8_t indx; -#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) +#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) && (INTERFACE_MODE == SPI_INTERRUPT) static struct iio_trigger ad405x_iio_trig_desc = { .is_synchronous = true, .enable = NULL, @@ -1484,7 +1478,7 @@ int32_t iio_ad405x_initialize(void) /* IIO interface init parameters */ struct iio_init_param iio_init_params = { .phy_type = USE_UART, -#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) +#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) && (INTERFACE_MODE == SPI_INTERRUPT) .trigs = &iio_trigger_init_params, #endif }; @@ -1492,7 +1486,7 @@ int32_t iio_ad405x_initialize(void) /* IIOD init parameters */ static struct iio_device_init iio_device_init_params[NUM_OF_IIO_DEVICES] = { { -#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) +#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) && (INTERFACE_MODE == SPI_INTERRUPT) .trigger_id = "trigger0", #endif } @@ -1568,7 +1562,7 @@ int32_t iio_ad405x_initialize(void) iio_init_params.nb_devs++; -#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) +#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) && (INTERFACE_MODE == SPI_INTERRUPT) iio_init_params.nb_trigs++; #endif } @@ -1581,7 +1575,7 @@ int32_t iio_ad405x_initialize(void) return init_status; } -#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) +#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE) && (INTERFACE_MODE == SPI_INTERRUPT) init_status = ad405x_iio_trigger_param_init(&ad405x_hw_trig_desc); if (init_status) { return init_status; diff --git a/projects/ad405x_iio/app/app_config.h b/projects/ad405x_iio/app/app_config.h index e35198f1..d5d032af 100644 --- a/projects/ad405x_iio/app/app_config.h +++ b/projects/ad405x_iio/app/app_config.h @@ -58,8 +58,8 @@ #define ACTIVE_PLATFORM STM32_PLATFORM #endif -/* Enable the UART/VirtualCOM port connection */ -#define USE_PHY_COM_PORT // Uncomment to select UART +/* Enable the UART/VirtualCOM port connection (default VCOM) */ +//#define USE_PHY_COM_PORT // Uncomment to select UART #if !defined(USE_PHY_COM_PORT) #define USE_VIRTUAL_COM_PORT @@ -181,7 +181,7 @@ extern struct no_os_gpio_init_param cs_pwm_gpio_params; extern struct no_os_gpio_init_param pwm_gpio_params; extern volatile uint32_t* buff_start_addr; extern volatile struct iio_device_data* iio_dev_data_g; -extern uint32_t nb_of_samples_g; +extern uint32_t nb_of_bytes_g; extern int32_t data_read; extern struct no_os_pwm_desc* tx_trigger_desc; #endif diff --git a/projects/ad405x_iio/app/app_config_stm32.c b/projects/ad405x_iio/app/app_config_stm32.c index f3131d85..e033cdaf 100644 --- a/projects/ad405x_iio/app/app_config_stm32.c +++ b/projects/ad405x_iio/app/app_config_stm32.c @@ -18,6 +18,8 @@ #include "app_config_stm32.h" #include "ad405x_iio.h" #include "ad405x.h" +#include "iio.h" + /******************************************************************************/ /************************ Macros/Constants ************************************/ /******************************************************************************/ @@ -246,7 +248,7 @@ void stm32_system_init(void) */ void DMA2_Stream0_IRQHandler(void) { -#if (DATA_CAPTURE_MODE == BURST_DATA_CAPTURE) +#if (APP_CAPTURE_MODE == WINDOWED_DATA_CAPTURE) /* Stop timers at the last entry to the callback */ if (callback_count == 1) { sdesc = p_ad405x_dev->spi_desc->extra; @@ -344,6 +346,7 @@ void stm32_timer_stop(void) void receivecomplete_callback(DMA_HandleTypeDef * hdma) { +#if (APP_CAPTURE_MODE == WINDOWED_DATA_CAPTURE) if (!dma_cycle_count) { return; } @@ -374,6 +377,13 @@ void receivecomplete_callback(DMA_HandleTypeDef * hdma) } return; +#else + no_os_cb_end_async_write(iio_dev_data_g->buffer->buf); + no_os_cb_prepare_async_write(iio_dev_data_g->buffer->buf, + nb_of_bytes_g, + &buff_start_addr, + &data_read); +#endif } /**