precision-converters-firmware
Macros | Functions | Variables
app_config_stm32.c File Reference

Application configurations module for STM32 platform. More...

#include "app_config_stm32.h"
#include "no_os_error.h"
#include "no_os_util.h"
#include "no_os_pwm.h"
#include "ad7091r_iio.h"
Include dependency graph for app_config_stm32.c:

Macros

#define TIM_CCMR_CCS_OUTPUT   0
 
#define TIM_CR2_MMS_COMPARE_PULSE   3
 
#define TIM_SMCR_SMS_TRIGGER   6
 
#define TIM_ITR_SOURCE   0
 

Functions

void stm32_system_init (void)
 Initialize the STM32 system peripherals. More...
 
void tim2_config (void)
 Configure CS timer. More...
 
void tim8_config (void)
 Configure Tx Trigger timer. More...
 
void stm32_timer_enable (void)
 Starts the timer signal generation for PWM and OC channels all at once. More...
 
void stm32_timer_stop (void)
 Stop generating timer signals. More...
 
void stm32_abort_dma_transfer (void)
 Abort DMA Transfers. More...
 
void stm32_cs_output_gpio_config (bool is_gpio)
 Configures the chip select pin as output mode. More...
 
void receivecomplete_callback (DMA_HandleTypeDef *hdma)
 Callback function to flag the capture of number of requested samples. More...
 
void halfcmplt_callback (DMA_HandleTypeDef *hdma)
 Callback function to flag the capture of Half the number of requested samples. More...
 
void update_buff (uint32_t *local_buf, uint32_t *buf_start_addr)
 Update buffer index. More...
 
void ad7091r8_pulse_convst_stm (void)
 Pull the CONVST line down then up. More...
 
int ad7091r8_read_one_stm (uint8_t channel, uint16_t *read_val)
 Read one sample. More...
 
void configure_intr_priority (void)
 Prioritizes the UART1 interrupt over the other peripheral interrupts. More...
 

Variables

struct stm32_uart_init_param stm32_uart_init_params
 
struct stm32_usb_uart_init_param stm32_vcom_extra_init_params
 
struct stm32_gpio_irq_init_param stm32_trigger_gpio_irq_init_params
 
struct stm32_spi_init_param stm32_spi_init_params
 
struct stm32_i2c_init_param stm32_i2c_init_params
 
struct stm32_gpio_init_param stm32_gpio_cnv_init_params
 
struct stm32_gpio_init_param stm32_pwm_cnv_gpio_init_params
 
struct stm32_gpio_init_param stm32_gpio_reset_init_params
 
struct stm32_gpio_init_param stm32_gpio_gp0_extra_init_params
 
struct stm32_pwm_init_param stm32_cnv_pwm_init_params
 
struct stm32_pwm_init_param stm32_cs_extra_init_params
 
struct stm32_pwm_init_param stm32_tx_trigger_extra_init_params
 
struct stm32_dma_channel txdma_channel
 
struct stm32_dma_channel rxdma_channel
 
struct stm32_gpio_init_param stm32_cs_pwm_gpio_extra_init_params
 
struct stm32_gpio_init_param stm32_cs_gpio_extra_init_params
 
volatile struct stm32_spi_desc * sdesc
 
uint32_t rxdma_ndtr
 
uint32_t dma_cycle_count = 0
 
uint8_t * iio_buf_start_idx
 
uint8_t * dma_buf_start_idx
 
uint8_t * iio_buf_current_idx
 
uint8_t * dma_buf_current_idx
 

Detailed Description

Application configurations module for STM32 platform.

Copyright (c) 2024 Analog Devices, Inc. All rights reserved.

This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement.

Macro Definition Documentation

◆ TIM_CCMR_CCS_OUTPUT

#define TIM_CCMR_CCS_OUTPUT   0

◆ TIM_CR2_MMS_COMPARE_PULSE

#define TIM_CR2_MMS_COMPARE_PULSE   3

◆ TIM_ITR_SOURCE

#define TIM_ITR_SOURCE   0

◆ TIM_SMCR_SMS_TRIGGER

#define TIM_SMCR_SMS_TRIGGER   6

Function Documentation

◆ ad7091r8_pulse_convst_stm()

void ad7091r8_pulse_convst_stm ( void  )

Pull the CONVST line down then up.

Returns
none.
Here is the caller graph for this function:

◆ ad7091r8_read_one_stm()

int ad7091r8_read_one_stm ( uint8_t  channel,
uint16_t *  read_val 
)

Read one sample.

Parameters
channel[in]- Channel.
read_val[out]- Value.
Returns
0 in case of success, negative error code otherwise.

◆ configure_intr_priority()

void configure_intr_priority ( void  )

Prioritizes the UART1 interrupt over the other peripheral interrupts.

Returns
None

◆ halfcmplt_callback()

void halfcmplt_callback ( DMA_HandleTypeDef *  hdma)

Callback function to flag the capture of Half the number of requested samples.

Callback function to flag the capture of half the number of requested samples.

Parameters
hdma- DMA Handler (Unused)
Returns
None

◆ receivecomplete_callback()

void receivecomplete_callback ( DMA_HandleTypeDef *  hdma)

Callback function to flag the capture of number of requested samples.

Parameters
hdma- DMA Handler (Unused)
Returns
None

◆ stm32_abort_dma_transfer()

void stm32_abort_dma_transfer ( void  )

Abort DMA Transfers.

Abort ongoing SPI RX DMA transfer.

Returns
None

◆ stm32_cs_output_gpio_config()

void stm32_cs_output_gpio_config ( bool  is_gpio)

Configures the chip select pin as output mode.

Parameters
is_gpio[in]Mode of the Pin
Returns
None

◆ stm32_system_init()

void stm32_system_init ( void  )

Initialize the STM32 system peripherals.

Returns
None

◆ stm32_timer_enable()

void stm32_timer_enable ( void  )

Starts the timer signal generation for PWM and OC channels all at once.

Returns
None

◆ stm32_timer_stop()

void stm32_timer_stop ( void  )

Stop generating timer signals.

Stops generating timer signals.

Returns
None

◆ tim2_config()

void tim2_config ( void  )

Configure CS timer.

Returns
None

◆ tim8_config()

void tim8_config ( void  )

Configure Tx Trigger timer.

Returns
None
Note
Tx timer acts as a slave for External Trigger (ETR1) in one-pulse mode to generate DMA requests

◆ update_buff()

void update_buff ( uint32_t *  local_buf,
uint32_t *  buf_start_addr 
)

Update buffer index.

Parameters
local_buf[out]- Local Buffer
buf_start_addr[out]- Buffer start addr
Returns
None

Variable Documentation

◆ dma_buf_current_idx

uint8_t* dma_buf_current_idx

◆ dma_buf_start_idx

uint8_t* dma_buf_start_idx

◆ dma_cycle_count

uint32_t dma_cycle_count = 0

◆ iio_buf_current_idx

uint8_t* iio_buf_current_idx

◆ iio_buf_start_idx

uint8_t* iio_buf_start_idx

◆ rxdma_channel

struct stm32_dma_channel rxdma_channel
Initial value:
= {
.hdma = &hdma_spi1_rx,
.ch_num = RxDMA_CHANNEL_NUM,
.mem_increment = true,
.mem_data_alignment = DATA_ALIGN_BYTE,
.per_data_alignment = DATA_ALIGN_BYTE,
.dma_mode = DMA_CIRCULAR_MODE,
}
DMA_HandleTypeDef hdma_spi1_rx
#define RxDMA_CHANNEL_NUM
Definition: app_config_stm32.h:95

◆ rxdma_ndtr

uint32_t rxdma_ndtr

◆ sdesc

volatile struct stm32_spi_desc* sdesc

◆ stm32_cnv_pwm_init_params

struct stm32_pwm_init_param stm32_cnv_pwm_init_params
Initial value:
= {
.prescaler = CNV_PWM_PRESCALER,
.timer_autoreload = true,
.mode = TIM_OC_PWM2,
.timer_chn = CNV_PWM_CHANNEL,
.get_timer_clock = HAL_RCC_GetPCLK2Freq,
.clock_divider = CNV_PWM_CLK_DIVIDER,
.complementary_channel = false,
.trigger_enable = false,
.trigger_output = PWM_TRGO_RESET
}
#define CNV_PWM_PRESCALER
Definition: app_config_stm32.h:143
#define CNV_PWM_CHANNEL
Definition: app_config_stm32.h:76
#define CNV_PWM_CLK_DIVIDER
Definition: app_config_stm32.h:77

◆ stm32_cs_extra_init_params

struct stm32_pwm_init_param stm32_cs_extra_init_params
Initial value:
= {
.prescaler = CS_TIMER_PRESCALER,
.timer_autoreload = false,
.mode = TIM_OC_PWM2,
.timer_chn = CS_TIMER_CHANNEL,
.complementary_channel = false,
.get_timer_clock = HAL_RCC_GetPCLK1Freq,
.clock_divider = TIMER_2_CLK_DIVIDER
}
#define TIMER_2_CLK_DIVIDER
Definition: app_config_stm32.h:69
#define CS_TIMER_PRESCALER
Definition: app_config_stm32.h:83
#define CS_TIMER_CHANNEL
Definition: app_config_stm32.h:84

◆ stm32_cs_gpio_extra_init_params

struct stm32_gpio_init_param stm32_cs_gpio_extra_init_params
Initial value:
= {
.mode = GPIO_MODE_OUTPUT_PP,
.speed = GPIO_SPEED_FREQ_VERY_HIGH,
}

◆ stm32_cs_pwm_gpio_extra_init_params

struct stm32_gpio_init_param stm32_cs_pwm_gpio_extra_init_params
Initial value:
= {
.mode = GPIO_MODE_AF_PP,
.speed = GPIO_SPEED_FREQ_VERY_HIGH,
.alternate = GPIO_AF1_TIM2
}

◆ stm32_gpio_cnv_init_params

struct stm32_gpio_init_param stm32_gpio_cnv_init_params
Initial value:
= {
.mode = GPIO_MODE_OUTPUT_PP,
.speed = GPIO_SPEED_FREQ_VERY_HIGH
}

◆ stm32_gpio_gp0_extra_init_params

struct stm32_gpio_init_param stm32_gpio_gp0_extra_init_params
Initial value:
= {
.mode = GPIO_MODE_INPUT,
.speed = GPIO_SPEED_FREQ_VERY_HIGH,
}

◆ stm32_gpio_reset_init_params

struct stm32_gpio_init_param stm32_gpio_reset_init_params
Initial value:
= {
.mode = GPIO_MODE_OUTPUT_PP
}

◆ stm32_i2c_init_params

struct stm32_i2c_init_param stm32_i2c_init_params
Initial value:
= {
.i2c_timing = I2C_TIMING
}
#define I2C_TIMING
Definition: app_config_stm32.h:119

◆ stm32_pwm_cnv_gpio_init_params

struct stm32_gpio_init_param stm32_pwm_cnv_gpio_init_params
Initial value:
= {
.mode = GPIO_MODE_AF_PP,
.speed = GPIO_SPEED_FREQ_VERY_HIGH,
.alternate = GPIO_AF1_TIM1
}

◆ stm32_spi_init_params

struct stm32_spi_init_param stm32_spi_init_params
Initial value:
= {
.chip_select_port = STM32_SPI_CS_PORT,
.get_input_clock = HAL_RCC_GetPCLK2Freq
}
#define STM32_SPI_CS_PORT
Definition: app_config_stm32.h:54

◆ stm32_trigger_gpio_irq_init_params

struct stm32_gpio_irq_init_param stm32_trigger_gpio_irq_init_params
Initial value:
= {
}
#define GPIO_TRIGGER_INT_PORT
Definition: app_config_stm32.h:47

◆ stm32_tx_trigger_extra_init_params

struct stm32_pwm_init_param stm32_tx_trigger_extra_init_params
Initial value:
= {
.prescaler = TIMER_8_PRESCALER,
.timer_autoreload = true,
.mode = TIM_OC_TOGGLE,
.timer_chn = TIMER_CHANNEL_1,
.complementary_channel = false,
.get_timer_clock = HAL_RCC_GetPCLK1Freq,
.clock_divider = TIMER_8_CLK_DIVIDER,
.trigger_output = PWM_TRGO_ENABLE,
.dma_enable = true,
.repetitions = 1,
.onepulse_enable = true
}
#define TIMER_8_CLK_DIVIDER
Definition: app_config_stm32.h:77
#define TIMER_CHANNEL_1
Definition: app_config_stm32.h:72
#define TIMER_8_PRESCALER
Definition: app_config_stm32.h:76

◆ stm32_uart_init_params

struct stm32_uart_init_param stm32_uart_init_params
Initial value:
= {
.huart = APP_UART_HANDLE
}
#define APP_UART_HANDLE
Definition: app_config_stm32.h:39

◆ stm32_vcom_extra_init_params

struct stm32_usb_uart_init_param stm32_vcom_extra_init_params
Initial value:
= {
.husbdevice = APP_UART_USB_HANDLE
}
#define APP_UART_USB_HANDLE
Definition: app_config_stm32.h:44

◆ txdma_channel

struct stm32_dma_channel txdma_channel
Initial value:
= {
.hdma = &hdma_tim8_ch1,
.ch_num = TxDMA_CHANNEL_NUM,
.mem_increment = false,
.mem_data_alignment = DATA_ALIGN_BYTE,
.per_data_alignment = DATA_ALIGN_BYTE,
.dma_mode = DMA_CIRCULAR_MODE
}
DMA_HandleTypeDef hdma_tim8_ch1
#define TxDMA_CHANNEL_NUM
Definition: app_config_stm32.h:94