13 #ifndef APP_CONFIG_STM32_H_
14 #define APP_CONFIG_STM32_H_
21 #include "stm32_uart.h"
22 #include "stm32_spi.h"
23 #include "stm32_gpio.h"
24 #include "stm32_irq.h"
25 #include "stm32_pwm.h"
26 #include "stm32_i2c.h"
27 #include "stm32_gpio_irq.h"
28 #include "stm32_dma.h"
29 #include "stm32_usb_uart.h"
39 #define TARGET_NAME SDP_K1
42 #define APP_UART_HANDLE &huart5
43 #define UART_IRQ_ID UART5_IRQn
44 #define APP_UART_USB_HANDLE &hUsbDeviceHS
53 #define GPIO_TRIGGER_INT_PORT BSY_PORT
57 #define STM32_SPI_CS_PORT 0
59 #define SPI_CS_PORT_NUM 0
60 #define SPI_CS_PIN_NUM 15
64 #define I2C_DEVICE_ID 1
65 #define SPI_DEVICE_ID 1
70 #define TRIGGER_INT_ID BSY_PIN
71 #define trigger_gpio_handle 0
72 #define BSY_GPIO_PRIORITY 1
76 #define CNV_PWM_CHANNEL 3
77 #define CNV_PWM_CLK_DIVIDER 2
78 #define PWM_GPIO_PORT CNV_PORT
79 #define PWM_GPIO_PIN CNV_PIN
83 #define CS_TIMER_PRESCALER 0
84 #define CS_TIMER_CHANNEL 1
85 #define TIMER_2_CLK_DIVIDER 2
89 #define TIMER_8_PRESCALER 0
90 #define TIMER_8_CLK_DIVIDER 2
91 #define TIMER_CHANNEL_1 1
93 #define Rx_DMA_IRQ_ID DMA2_Stream0_IRQn
94 #define TxDMA_CHANNEL_NUM DMA_CHANNEL_7
95 #define RxDMA_CHANNEL_NUM DMA_CHANNEL_3
97 #define AD7091R_DMA_NUM_CHANNELS 2
100 #define spi_extra_init_params stm32_spi_init_params
101 #define uart_extra_init_params stm32_uart_init_params
102 #define i2c_extra_init_params stm32_i2c_init_params
103 #define pwm_extra_init_params stm32_cnv_pwm_init_params
104 #define cnv_gpio_extra_init_param stm32_gpio_cnv_init_params
105 #define reset_gpio_extra_init_param stm32_gpio_reset_init_params
106 #define trigger_gpio_irq_extra_params stm32_trigger_gpio_irq_init_params
107 #define pwm_gpio_extra_init_params stm32_pwm_cnv_gpio_init_params
108 #define alt_bsy_gpio_extra_init_params stm32_gpio_gp0_extra_init_params
109 #define tx_trigger_extra_init_params stm32_tx_trigger_extra_init_params
110 #define cs_extra_init_params stm32_cs_extra_init_params
111 #define cs_pwm_gpio_extra_init_params stm32_cs_pwm_gpio_extra_init_params
112 #define vcom_extra_init_params stm32_vcom_extra_init_params
115 #define trigger_gpio_irq_ops stm32_gpio_irq_ops
116 #define gpio_ops stm32_gpio_ops
117 #define spi_ops stm32_spi_ops
118 #define pwm_ops stm32_pwm_ops
119 #define uart_ops stm32_uart_ops
120 #define i2c_ops stm32_i2c_ops
121 #define dma_ops stm32_dma_ops
122 #define vcom_ops stm32_usb_uart_ops
125 #define MAX_SPI_SCLK 40000000
131 #if (INTERFACE_MODE == SPI_INTERRUPT)
132 #if (DATA_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE)
133 #define MAX_SAMPLING_RATE 40000
135 #define MAX_SAMPLING_RATE 50000
137 #define PWM_DUTY_CYCLE_PERCENT 90
138 #define CNV_PWM_PRESCALER 3
139 #define PWM_DUTY_CYCLE_NSEC 360
141 #define MAX_SAMPLING_RATE 830000
142 #define CHIP_SELECT_DUTY_CYCLE_NS 530
143 #define CNV_PWM_PRESCALER 1
144 #define PWM_DUTY_CYCLE_NSEC 250
148 #define TX_TRIGGER_PERIOD 400
149 #define TX_TRIGGER_DUTY_CYCLE_NS 30
163 extern UART_HandleTypeDef
huart5;
164 extern TIM_HandleTypeDef
htim1;
165 extern TIM_HandleTypeDef
htim2;
168 #if (INTERFACE_MODE == SPI_DMA)
UART_HandleTypeDef huart5
struct stm32_spi_init_param stm32_spi_init_params
Definition: app_config_stm32.c:40
struct stm32_gpio_init_param stm32_gpio_reset_init_params
Definition: app_config_stm32.c:67
struct stm32_gpio_irq_init_param stm32_trigger_gpio_irq_init_params
Definition: app_config_stm32.c:35
struct stm32_uart_init_param stm32_uart_init_params
Definition: app_config_stm32.c:30
struct stm32_dma_channel txdma_channel
Definition: app_config_stm32.c:29
DMA_HandleTypeDef hdma_tim8_ch1
struct stm32_dma_channel rxdma_channel
Definition: app_config_stm32.c:39
uint32_t rxdma_ndtr
Definition: app_config_stm32.c:175
USBD_HandleTypeDef hUsbDeviceHS
void stm32_cs_output_gpio_config(bool is_gpio)
Configures the chip select pin as output mode.
Definition: app_config_stm32.c:384
void stm32_system_init(void)
Initialize the STM32 system peripherals.
Definition: app_config_stm32.c:111
void halfcmplt_callback(DMA_HandleTypeDef *hdma)
Callback function to flag the capture of half the number of requested samples.
Definition: app_config_stm32.c:268
struct stm32_pwm_init_param stm32_cs_extra_init_params
Definition: app_config_stm32.c:133
void stm32_timer_enable(void)
Starts the timer signal generation for PWM and OC channels all at once.
Definition: app_config_stm32.c:303
void receivecomplete_callback(DMA_HandleTypeDef *hdma)
Callback function to flag the capture of number of requested samples.
Definition: app_config_stm32.c:345
int dma_cycle_count
Definition: app_config_stm32.c:169
struct stm32_pwm_init_param stm32_tx_trigger_extra_init_params
Definition: app_config_stm32.c:143
int stm32_abort_dma_transfer(void)
Abort ongoing SPI RX DMA transfer.
Definition: app_config_stm32.c:420
struct stm32_usb_uart_init_param stm32_vcom_extra_init_params
Definition: app_config_stm32.c:54
DMA_HandleTypeDef hdma_spi1_rx
void stm32_timer_stop(void)
Stops generating timer signals.
Definition: app_config_stm32.c:324
void update_buff(uint32_t *local_buf, uint32_t *buf_start_addr)
Update buffer index.
Definition: app_config_stm32.c:289
struct stm32_gpio_init_param stm32_cs_pwm_gpio_extra_init_params
Definition: app_config_stm32.c:95
struct stm32_gpio_init_param stm32_gpio_gp0_extra_init_params
Definition: app_config_stm32.c:72
uint8_t local_buf[MAX_LOCAL_BUF_SIZE]
Definition: ad405x_iio.c:172
void tim8_config(void)
Configure Tx Trigger timer.
Definition: app_config_stm32.c:335
void tim2_config(void)
Configure CS timer.
Definition: app_config_stm32.c:224
struct stm32_gpio_init_param stm32_gpio_cnv_init_params
Definition: app_config_stm32.c:70
void configure_intr_priority(void)
Prioritizes the UART1 interrupt over the other peripheral interrupts.
Definition: app_config_stm32.c:475
struct stm32_pwm_init_param stm32_cnv_pwm_init_params
Definition: app_config_stm32.c:94
void ad7091r8_pulse_convst_stm(void)
Pull the CONVST line down then up.
Definition: app_config_stm32.c:422
int ad7091r8_read_one_stm(uint8_t channel, uint16_t *read_val)
Read one sample.
Definition: app_config_stm32.c:434
struct stm32_i2c_init_param stm32_i2c_init_params
Definition: app_config_stm32.c:65
struct stm32_gpio_init_param stm32_pwm_cnv_gpio_init_params
Definition: app_config_stm32.c:76
Configuration file of nanodac firmware example program.