precision-converters-firmware
app_config_stm32.h
Go to the documentation of this file.
1 /***************************************************************************/
13 #ifndef APP_CONFIG_STM32_H_
14 #define APP_CONFIG_STM32_H_
15 
16 /******************************************************************************/
17 /***************************** Include Files **********************************/
18 /******************************************************************************/
19 
20 #include "app_config.h"
21 #include "stm32_uart.h"
22 #include "stm32_spi.h"
23 #include "stm32_hal.h"
24 #include "stm32_tdm.h"
25 #include "stm32_gpio.h"
26 #include "stm32_i2c.h"
27 #include "stm32_gpio_irq.h"
28 
29 /******************************************************************************/
30 /********************** Macros and Constants Definition ***********************/
31 /******************************************************************************/
32 
33 /* The below pin mapping is specific to STM32H563ZIT6 MCU on NUCLEO-H563ZI Board */
34 #define STM32_SPI_ID 1 // SPI1
35 #define SPI_CSB 14 // PD_14
36 #define STM32_SPI_CS_PORT 3 // GPIO Port D
37 
38 #define DCLK_PIN 14 // PG14
39 #define ODR_PIN 13 // PE13
40 #define DOUT0_PIN 14 // PE14
41 #define DOUT1_PIN 11 // PE11
42 #define PDN_PIN 6 // PB6
43 
44 #define GPIO_TRIGGER_INT_PORT 4 // PORTE
45 #define PDN_PORT 1 // PORTB
46 
47 /* STM32 specific UART parameters */
48 #define STM32_UART_BASE 3
49 
50 /* STM32 specific SAI Parameters */
51 #define STM32_SAI_BASE SAI1_Block_A
52 
53 #define APP_UART_HANDLE &huart3
54 
55 /* TDM specific Parameters */
56 #define TDM_DATA_SIZE 16
57 #define TDM_SLOTS_PER_FRAME 4
58 #define TDM_FS_ACTIVE_LENGTH 8
59 
60 /* This makes sure that the processor gets into the
61  * Half complete callback function after every 400 samples */
62 #define TDM_N_SAMPLES_DMA_READ 800
63 #define TDM_DMA_READ_SIZE TDM_N_SAMPLES_DMA_READ * TDM_SLOTS_PER_FRAME/2
64 
65 /* GPIO Pin Mask Values (Unused) */
66 #define DCLK_PIN_MASK 0
67 #define ODR_PIN_MASK 0
68 #define DOUT0_PIN_MASK 0
69 #define DOUT1_PIN_MASK 0
70 
71 #define DOUT1_IDR 0
72 #define PORTD_IDR 0
73 #define DCLK_IDR 0
74 #define DOUT0_IDR 0
75 
76 #define UART_IRQ_ID USART3_IRQn
77 #define UART_DEVICE_ID 0
78 #define SPI_DEVICE_ID STM32_SPI_ID
79 #define trigger_gpio_handle 0 // Unused macro
80 #define IRQ_INT_ID ODR_PIN
81 #define DMA_IRQ_ID GPDMA1_Channel7_IRQn
82 #define I2C_DEVICE_ID 1 // I2C1
83 
84 /* I2C timing register value for standard mode of operation
85  * Check here for more understanding on I2C timing register
86  * configuration: https://wiki.analog.com/resources/no-os/drivers/i2c */
87 #define I2C_TIMING 0x00000E14
88 
89 /* Define the max possible sampling (or output data) rate for a given platform.
90  * Note: Max possible ODR is 500KSPS per channel for continuous data capture on
91  * IIO client. This is derived by testing the firmware on NUCLEO-H563ZI controller
92  * board. The max possible ODR can vary from board to board and data
93  * continuity is not guaranteed above this ODR on IIO oscilloscope */
94 #define SAMPLING_RATE (500000)
95 
96 /******************************************************************************/
97 /********************** Public/Extern Declarations ****************************/
98 /******************************************************************************/
99 
100 extern struct stm32_uart_init_param stm32_uart_extra_init_params;
101 extern struct stm32_spi_init_param stm32_spi_extra_init_params;
102 extern struct stm32_tdm_init_param stm32_tdm_extra_init_params;
103 extern struct stm32_gpio_irq_init_param stm32_trigger_gpio_irq_init_params;
104 extern struct stm32_gpio_init_param stm32_pdn_extra_init_params;
105 extern struct stm32_i2c_init_param stm32_i2c_extra_init_params;
106 extern UART_HandleTypeDef huart3;
107 extern bool data_capture_operation;
108 extern struct iio_device_data *ad7134_iio_dev_data;
109 extern void SystemClock_Config(void);
110 extern HAL_StatusTypeDef HAL_Init(void);
112 void MX_SPI1_Init(void);
113 void MX_ICACHE_Init(void);
114 void MX_GPIO_Init(void);
115 void ad7134_dma_rx_cplt(SAI_HandleTypeDef *hsai);
116 void ad7134_dma_rx_half_cplt(SAI_HandleTypeDef *hsai);
117 #endif /* APP_CONFIG_STM32_H_ */
118 
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_extra_init_params
Definition: app_config_stm32.c:49
struct stm32_spi_init_param stm32_spi_extra_init_params
Definition: app_config_stm32.c:59
struct stm32_tdm_init_param stm32_tdm_extra_init_params
Definition: app_config_stm32.c:52
struct stm32_i2c_init_param stm32_i2c_extra_init_params
Definition: app_config_stm32.c:99
bool data_capture_operation
Definition: ad4170_iio.c:337
UART_HandleTypeDef huart3
void MX_ICACHE_Init(void)
void MX_LPUART1_UART_Init(void)
void ad7134_dma_rx_half_cplt(SAI_HandleTypeDef *hsai)
SAI DMA Receive Half Complete Callback function.
Definition: app_config_stm32.c:100
void SystemClock_Config(void)
struct iio_device_data * ad7134_iio_dev_data
Definition: ad7134_iio.c:89
void MX_GPIO_Init(void)
struct stm32_gpio_init_param stm32_pdn_extra_init_params
Definition: app_config_stm32.c:62
HAL_StatusTypeDef HAL_Init(void)
void ad7134_dma_rx_cplt(SAI_HandleTypeDef *hsai)
SAI DMA Receive Complete Callback function.
Definition: app_config_stm32.c:115
void MX_SPI1_Init(void)
Configuration file of nanodac firmware example program.