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 "stm32_uart.h"
21#include "stm32_spi.h"
22#include "stm32_i2c.h"
23#include "stm32_irq.h"
24#include "main.h"
25#include "stm32_pwm.h"
26#include "stm32_usb_uart.h"
27
28/******************************************************************************/
29/********************** Macros and Constants Definition ***********************/
30/******************************************************************************/
31
32/* Note: The SDP-K1 board with the STM32F469NI MCU has been used
33* for developing the firmware. The below parameters will change depending
34* on the controller used. */
35#define HW_CARRIER_NAME SDP_K1
36
37/* STM32 SPI Specific parameters */
38#define MAX_SPI_BAUDRATE 20000000
39#define SPI_DEVICE_ID 1 // SPI1
40#define SPI_CS_PORT 0 // GPIO Port A
41#define SPI_CSB 15 // PA_15
42
43/* STM32 UART specific parameters */
44#define APP_UART_HANDLE &huart5
45#define APP_UART_USB_HANDLE hUsbDeviceHS
46
47/* UART Device ID */
48#define UART_IRQ_ID UART5_IRQn
49
50/* STM32 I2C Specific parameters */
51#define I2C_DEVICE_ID 1 // I2C1
52#define I2C_BAUDRATE 400000
53
54/* STM32 PWM Specific parameters */
55#define PWM_TIM_IRQ_ID TIM1_CC_IRQn
56#define APP_TIM_HANDLE &htim1
57#define TIMER_PWM_ID 1 // Timer 1
58#define TIMER1_ID 1
59#define TIMER_1_PRESCALER 0
60#define TIMER_1_CLK_DIVIDER 2
61#define TIMER_CHANNEL_3 3 // Channel 3
62
63/* Minimum Duty cycle needed */
64#define DUTY_CYCLE_IN_NS 50
65
66/* Minimum Period needed at 20 Mhz Clock frequency
67 * This is calculated as 16* 50ns + duty cycle + offset time needed when one channel is enabled
68 * This offset is a result of time needed for activation of Interrupt in STM32 platform and additional
69 * processing after each iteration are captured */
70#define PERIOD_IN_NS 22500
71
72/* Period needed for one read at 20Mhz
73 * Period for one read (9us) */
74#define PERIOD_FOR_ONE_READ 9000
75
76#define INTR_CALLBACK_EVENT NO_OS_EVT_TIM_PWM_PULSE_FINISHED
77#define INTR_CALLBACK_PERIPHERAL NO_OS_TIM_IRQ
78#define trigger_handle APP_TIM_HANDLE
79#define TRIGGER_INT_ID PWM_TIM_IRQ_ID
80
81/* Priority for the PWM Timer */
82#define PWM_PRIORITY 1
83
84/* Define the init params structure mapping wrt STM32 platform */
85#define spi_extra_init_params stm32_spi_extra_init_params
86#define uart_extra_init_params stm32_uart_extra_init_params
87#define gpio_ops stm32_gpio_ops
88#define spi_ops stm32_spi_ops
89#define i2c_ops stm32_i2c_ops
90#define uart_ops stm32_uart_ops
91#define irq_platform_ops stm32_irq_ops
92#define pwm_ops stm32_pwm_ops
93#define vcom_ops stm32_usb_uart_ops
94#define vcom_extra_init_params stm32_vcom_extra_init_params
95
96/******************************************************************************/
97/********************** Variables and User Defined Data Types *****************/
98/******************************************************************************/
99extern UART_HandleTypeDef huart5;
100extern USBD_HandleTypeDef APP_UART_USB_HANDLE;
101extern TIM_HandleTypeDef htim1;
102
103extern struct stm32_uart_init_param stm32_uart_extra_init_params;
104extern struct stm32_spi_init_param stm32_spi_extra_init_params;
105extern struct stm32_i2c_init_param stm32_i2c_extra_init_params;
106extern struct stm32_pwm_init_param stm32_pwm_extra_init_params;
107extern struct stm32_pwm_desc *pwm_extra_params;
109
110extern void stm32_system_init();
112
113#endif // APP_CONFIG_STM32_H_
UART_HandleTypeDef huart5
void stm32_system_init(void)
Initialize the STM32 system peripherals.
Definition app_config_stm32.c:178
struct stm32_usb_uart_init_param stm32_vcom_extra_init_params
Definition app_config_stm32.c:39
struct stm32_i2c_init_param stm32_i2c_extra_init_params
Definition app_config_stm32.c:166
struct stm32_uart_init_param stm32_uart_extra_init_params
Definition app_config_stm32.c:102
#define APP_UART_USB_HANDLE
Definition app_config_stm32.h:133
struct stm32_spi_init_param stm32_spi_extra_init_params
Definition app_config_stm32.c:43
struct stm32_pwm_init_param stm32_pwm_extra_init_params
Definition app_config_stm32.c:77
TIM_HandleTypeDef htim1
void MX_USB_DEVICE_Init(void)
struct stm32_pwm_desc * pwm_extra_params
Definition app_config_stm32.c:58
VCOM driver for stm32 as a no_os_uart implementation.
Specific initialization parameters for stm32 UART over USB.
Definition stm32_usb_uart.h:27