13 #ifndef APP_CONFIG_STM32_H_
14 #define APP_CONFIG_STM32_H_
21 #include "stm32_hal.h"
22 #include "stm32_i2c.h"
23 #include "stm32_irq.h"
24 #include "stm32_gpio_irq.h"
25 #include "stm32_spi.h"
26 #include "stm32_gpio.h"
27 #include "stm32_uart.h"
28 #include "stm32_dma.h"
29 #include "stm32_pwm.h"
37 #define TARGET_NAME SDP_K1
42 #define UART_IRQ UART5_IRQn
43 #define SPI_DEVICE_ID 1
44 #define SPI_CS_PIN_NUM 15
45 #define STM32_SPI_CS_PORT_BASE GPIOA
46 #define STM32_SPI_CS_PORT_NUM 0
47 #define CNV_PIN_NUM 10
48 #define CNV_PORT_NUM 0
49 #define GP0_PIN_NUM 15
50 #define GP0_PORT_NUM 1
51 #define GP1_PIN_NUM 11
52 #define GP1_PORT_NUM 6
53 #define STM32_GP1_IRQ EXTI15_10_IRQn
54 #define STM32_DMA_CONT_HANDLE hdma_tim1_ch2
55 #define STM32_DMA_CONT_TRIGGER DMA2_Stream2_IRQn
56 #define STM32_DMA_SPI_RX_TRIGGER DMA2_Stream0_IRQn
60 #define TIMER_1_PRESCALER 1
61 #define TIMER_2_PRESCALER 0
62 #define TIMER_1_CLK_DIVIDER 2
63 #define TIMER_2_CLK_DIVIDER 2
66 #define TIMER_CHANNEL_1 1
67 #define TIMER_CHANNEL_2 2
68 #define TIMER_CHANNEL_3 3
70 #define TIMER_8_PRESCALER 0
71 #define TIMER_8_CLK_DIVIDER 2
73 #define TRIGGER_GPIO_PORT 0
74 #define TRIGGER_GPIO_PIN PWM_TRIGGER
80 #define AD405x_DMA_NUM_CHANNELS 2
82 #define AD405x_TxDMA_CHANNEL_NUM DMA_CHANNEL_7
83 #define AD405x_RxDMA_CHANNEL_NUM DMA_CHANNEL_3
84 #define Rx_DMA_IRQ_ID DMA2_Stream0_IRQn
87 #define uart_extra_init_params stm32_uart_extra_init_params
88 #define spi_extra_init_params stm32_spi_extra_init_params
89 #define cnv_extra_init_params stm32_gpio_cnv_extra_init_params
90 #define pwm_extra_init_params stm32_pwm_cnv_extra_init_params
91 #define pwm_gpio_extra_init_params stm32_pwm_gpio_extra_init_params
92 #define gp0_extra_init_params stm32_gpio_gp0_extra_init_params
93 #define gp1_extra_init_params stm32_gpio_gp1_extra_init_params
94 #define trigger_gpio_irq_extra_params stm32_gpio_irq_extra_init_params
95 #define dma_extra_init_params stm32_dma_extra_init_params
96 #define cs_extra_init_params stm32_cs_extra_init_params
97 #define tx_trigger_extra_init_params stm32_tx_trigger_extra_init_params
100 #define gpio_ops stm32_gpio_ops
101 #define spi_ops stm32_spi_ops
102 #define i2c_ops stm32_i2c_ops
103 #define uart_ops stm32_uart_ops
104 #define pwm_ops stm32_pwm_ops
105 #define trigger_gpio_irq_ops stm32_gpio_irq_ops
106 #define dma_ops stm32_dma_ops
108 #define MAX_SPI_SCLK 22500000
109 #define MAX_SPI_SCLK_45MHz 45000000
118 #if (INTERFACE_MODE == SPI_INTERRUPT)
119 #if (APP_CAPTURE_MODE == WINDOWED_DATA_CAPTURE)
120 #define SAMPLING_RATE 62500
122 #define SAMPLING_RATE 30000
124 #define CONV_TRIGGER_DUTY_CYCLE_NSEC(x) (x / 10)
126 #define SAMPLING_RATE (1000000)
127 #define DMA_MSB_DUTY_CYCLE_NS 200
128 #define DMA_LSB_DUTY_CYCLE_NS 600
129 #define OUTPUT_COMPARE_DUTY_CYCLE_NS 200
130 #define CHIP_SELECT_DUTY_CYCLE_NS 800
132 #define CONV_TRIGGER_PERIOD_NSEC(x) (((float)(1.0 / x) * 1000000) * 1000)
137 extern I2C_HandleTypeDef
hi2c1;
138 extern SPI_HandleTypeDef
hspi1;
140 extern TIM_HandleTypeDef
htim1;
141 extern TIM_HandleTypeDef
htim2;
145 extern UART_HandleTypeDef
huart5;
158 #if (INTERFACE_MODE == SPI_DMA)
179 struct no_os_spi_desc* spi_desc,
bool is_dma_mode);
UART_HandleTypeDef huart5
struct stm32_dma_channel txdma_channel
Definition: app_config_stm32.c:29
DMA_HandleTypeDef hdma_tim1_ch2
struct stm32_dma_init_param stm32_spi_dma_extra_init_params
void tim1_config(void)
Configure CNV timer.
Definition: app_config_stm32.c:402
DMA_HandleTypeDef hdma_tim8_ch1
struct stm32_pwm_init_param stm32_oc_extra_init_params
volatile bool data_ready
Definition: ad405x_iio.c:168
volatile bool ad405x_conversion_flag
Definition: app_config_stm32.c:151
struct stm32_dma_channel rxdma_channel
Definition: app_config_stm32.c:39
uint32_t rxdma_ndtr
Definition: app_config_stm32.c:159
void stm32_cs_output_gpio_config(bool is_gpio)
Configures the chip select pin as output mode.
Definition: app_config_stm32.c:344
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:233
void tim8_config(void)
Configure Tx Trigger timer.
Definition: app_config_stm32.c:412
struct stm32_pwm_init_param stm32_cs_extra_init_params
Definition: app_config_stm32.c:125
void stm32_timer_enable(void)
Starts the timer signal generation for PWM and OC channels all at once.
Definition: app_config_stm32.c:267
struct stm32_gpio_init_param stm32_gpio_cnv_extra_init_params
Definition: app_config_stm32.c:60
void receivecomplete_callback(DMA_HandleTypeDef *hdma)
Callback function to flag the capture of number of requested samples.
Definition: app_config_stm32.c:306
struct stm32_pwm_init_param stm32_pwm_cnv_extra_init_params
Definition: app_config_stm32.c:112
DMA_HandleTypeDef hdma_tim1_ch3
int dma_cycle_count
Definition: app_config_stm32.c:156
struct stm32_pwm_init_param stm32_tx_trigger_extra_init_params
Definition: app_config_stm32.c:135
void stm32_cnv_output_gpio_config(bool is_gpio)
Configures the conversion pin as output mode.
Definition: app_config_stm32.c:363
struct stm32_pwm_init_param stm32_dma_extra_init_params
int stm32_abort_dma_transfer(void)
Abort ongoing SPI RX DMA transfer.
Definition: app_config_stm32.c:380
struct stm32_gpio_init_param stm32_pwm_gpio_extra_init_params
Definition: app_config_stm32.c:102
struct stm32_uart_init_param stm32_uart_extra_init_params
Definition: app_config_stm32.c:49
struct stm32_gpio_irq_init_param stm32_gpio_irq_extra_init_params
Definition: app_config_stm32.c:78
DMA_HandleTypeDef hdma_spi1_rx
void stm32_configure_spi_dma(struct no_os_spi_init_param *spi_init_par, struct no_os_spi_desc *spi_desc, bool is_dma_mode)
void stm32_timer_stop(void)
Stops generating timer signals.
Definition: app_config_stm32.c:285
void update_buff(uint32_t *local_buf, uint32_t *buf_start_addr)
Update buffer index.
Definition: app_config_stm32.c:253
struct stm32_spi_init_param stm32_spi_extra_init_params
Definition: app_config_stm32.c:54
struct stm32_gpio_init_param stm32_cs_pwm_gpio_extra_init_params
Definition: app_config_stm32.c:89
struct stm32_gpio_init_param stm32_gpio_gp0_extra_init_params
Definition: app_config_stm32.c:66
struct stm32_gpio_init_param stm32_gpio_gp1_extra_init_params
Definition: app_config_stm32.c:72
uint8_t local_buf[MAX_LOCAL_BUF_SIZE]
Definition: ad405x_iio.c:177