precision-converters-firmware
Loading...
Searching...
No Matches
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 <stdint.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_gpio_irq.h"
27#include "app_config.h"
28
29/******************************************************************************/
30/********************** Macros and Constants Definition ***********************/
31/******************************************************************************/
32
33/* Note: The SDP-K1 board with the STM32F469NI MCU has been used
34* for developing the firmware. The below parameters will change depending
35* on the controller used. */
36#define HW_CARRIER_NAME SDP_K1
37
38/* STM32 UART specific parameters */
39#define APP_UART_HANDLE &huart5
40#define UART_IRQ_ID UART5_IRQn
41
42/* GPIO Pins associated with DAC */
43#define RESET_PIN 11 // PG11
44#define RESET_PORT 6 // PORTG
45#define LDAC_PIN 15 // PB15
46#define LDAC_PORT 1 // PORTB
47#define GPIO_TRIGGER_INT_PORT 1 //PORTB
48#define SPI_DMA_TX_STOP_PWM_GPIO_PIN 12 //PD12
49#define SPI_DMA_TX_STOP_PWM_GPIO_PORT 3 //PORTD
50
51/* STM32 SPI Specific parameters */
52#define SPI_DEVICE_ID 1 //SPI1
53#define SPI_CSB 15 //PA15
54#define STM32_SPI_CS_PORT 0 //PORTA
55
56/* Interrupt Callback parameters */
57#define IRQ_CTRL_ID 15 // PB15
58#define TRIGGER_INT_ID 15 // PB15
59#define trigger_gpio_handle 0
60#define LDAC_GPIO_PRIORITY 1
61
62/* STM32 LDAC PWM Specific parameters */
63#define LDAC_PWM_ID 12 //Timer12
64#define LDAC_PWM_CHANNEL 2 // Channel 2
65#define LDAC_PWM_CLK_DIVIDER 2 // multiplier to get timer clock from PLCK1
66#define LDAC_PWM_HANDLE htim12
67
68/* STM32 PWM specific parameters to stop spi dma transfer */
69#define SPI_DMA_TX_STOP_PWM_ID 4 //Timer4
70#define SPI_DMA_TX_STOP_PWM_PRESCALER 0
71#define SPI_DMA_TX_STOP_PWM_CHANNEL 1 // Channel 1
72#define SPI_DMA_TX_STOP_PWM_CLK_DIVIDER 2 // multiplier to get timer clock from PLCK1
73#define SPI_DMA_TX_STOP_PWM_HANDLE htim4
74
75/* Redefine the init params structure mapping wrt platform */
76#define spi_extra_init_params stm32_spi_init_params
77#define spi_extra_init_params_without_sw_csb stm32_spi_init_params_without_sw_csb
78#define uart_extra_init_params stm32_uart_init_params
79#define ldac_pwm_extra_init_params stm32_ldac_pwm_init_params
80#define spi_dma_tx_stop_pwm_extra_init_params stm32_spi_dma_tx_stop_pwm_init_params
81#define gpio_ldac_extra_init_params stm32_gpio_ldac_init_params
82#define spi_dma_tx_stop_pwm_gpio_extra_init_params stm32_spi_dma_tx_stop_pwm_gpio_init_params
83#define gpio_reset_extra_init_params stm32_gpio_reset_init_params
84#define ext_int_extra_init_params stm32_trigger_gpio_irq_init_params
85
86/* Platform Ops */
87#define irq_platform_ops stm32_gpio_irq_ops
88#define gpio_ops stm32_gpio_ops
89#define spi_ops stm32_spi_ops
90#define pwm_ops stm32_pwm_ops
91#define uart_ops stm32_uart_ops
92
93/* Define the max possible sampling rate for a given platform.
94 * Note: This is derived by testing the firmware on SDP-K1 controller
95 * board with STM32F469NI MCU.
96 * The max possible sampling rate can vary from board to board */
97#if (INTERFACE_MODE == SPI_DMA)
98#define MAX_SAMPLING_RATE 274423
99#define LDAC_PWM_DUTY_CYCLE 99
100#define MAX_SPI_SCLK 11250000
101#define LDAC_PWM_PRESCALER 0
102#define SPI_DMA_TX_STOP_PWM_DUTY_CYCLE 50
103#else
104#define MAX_SAMPLING_RATE 21593
105#define LDAC_PWM_DUTY_CYCLE 50
106#define MAX_SPI_SCLK 22500000
107#define LDAC_PWM_PRESCALER 3
108#endif
109
110/******************************************************************************/
111/********************** Variables and User Defined Data Types *****************/
112/******************************************************************************/
113extern struct stm32_uart_init_param stm32_uart_init_params;
114extern struct stm32_gpio_irq_init_param stm32_trigger_gpio_irq_init_params;
115extern struct stm32_spi_init_param stm32_spi_init_params;
116extern struct stm32_spi_init_param stm32_spi_init_params_without_sw_csb;
117extern struct stm32_gpio_init_param stm32_gpio_ldac_init_params;
118extern struct stm32_gpio_init_param
120extern struct stm32_gpio_init_param stm32_gpio_reset_init_params;
121extern struct stm32_pwm_init_param stm32_ldac_pwm_init_params;
122extern struct stm32_pwm_init_param stm32_spi_dma_tx_stop_pwm_init_params;
123extern UART_HandleTypeDef huart5;
124extern SPI_HandleTypeDef hspi1;
125extern TIM_HandleTypeDef htim4;
126extern TIM_HandleTypeDef htim12;
128
129int32_t stm32_spi_dma_enable(struct stm32_spi_desc* spidesc,
130 struct iio_device_data* iio_dev_data, uint16_t num_of_bytes_transfer,
131 uint8_t start_addr);
132int32_t stm32_spi_dma_disable(struct stm32_spi_desc* spidesc);
133#endif // APP_CONFIG_STM32_H_
UART_HandleTypeDef huart5
struct stm32_gpio_init_param stm32_gpio_ldac_init_params
Definition app_config_stm32.c:59
struct stm32_pwm_init_param stm32_ldac_pwm_init_params
Definition app_config_stm32.c:77
struct stm32_spi_init_param stm32_spi_init_params
Definition app_config_stm32.c:48
struct stm32_gpio_init_param stm32_gpio_reset_init_params
Definition app_config_stm32.c:72
struct stm32_gpio_irq_init_param stm32_trigger_gpio_irq_init_params
Definition app_config_stm32.c:43
struct stm32_uart_init_param stm32_uart_init_params
Definition app_config_stm32.c:33
#define NUMBER_OF_CHANNELS
Definition app_config.h:83
struct stm32_pwm_init_param stm32_spi_dma_tx_stop_pwm_init_params
Definition app_config_stm32.c:83
struct stm32_spi_init_param stm32_spi_init_params_without_sw_csb
Definition app_config_stm32.c:46
uint32_t spi_dma_tx_stop_pwm_frquency[NUMBER_OF_CHANNELS]
Definition app_config_stm32.h:127
int32_t stm32_spi_dma_enable(struct stm32_spi_desc *spidesc, struct iio_device_data *iio_dev_data, uint16_t num_of_bytes_transfer, uint8_t start_addr)
Enables SPI DMA to move data from iio buffer to SPI TX buffer.
Definition app_config_stm32.c:177
TIM_HandleTypeDef htim4
SPI_HandleTypeDef hspi1
TIM_HandleTypeDef htim12
int32_t stm32_spi_dma_disable(struct stm32_spi_desc *spidesc)
Disable SPI DMA which move data from iio buffer to SPI TX buffer.
Definition app_config_stm32.c:225
struct stm32_gpio_init_param stm32_spi_dma_tx_stop_pwm_gpio_init_params
Definition app_config_stm32.c:60
Configuration file of nanodac firmware example program.