Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
main.h
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
62/* USER CODE END Header */
63
64/* Define to prevent recursive inclusion -------------------------------------*/
65#ifndef __MAIN_H
66#define __MAIN_H
67
68#ifdef __cplusplus
69extern "C" {
70#endif
71
72/* Includes ------------------------------------------------------------------*/
73#include "stm32h7xx_hal.h"
74
75/* Private includes ----------------------------------------------------------*/
76/* USER CODE BEGIN Includes */
77#include <stdint.h>
78#include <string.h>
79#include <stdio.h>
80#include <math.h>
81#include <stdbool.h>
82
84#include "bmp3.h"
85#include "lsm6dso32_reg.h"
86#include "flight_control.h"
87#include "utilities.h"
88#include "lis2mdl_reg.h"
89/* USER CODE END Includes */
90
91/* Exported types ------------------------------------------------------------*/
92/* USER CODE BEGIN ET */
98extern QSPI_HandleTypeDef hqspi;
99extern SPI_HandleTypeDef hspi2;
100extern SPI_HandleTypeDef hspi3;
101extern TIM_HandleTypeDef htim15;
102
103extern uint8_t mainp;
104extern uint8_t drogue;
105
106extern bool flag_kf;
107extern bool flag_MPC;
108extern bool flag_flash;
109extern bool flag_attitude;
111/* USER CODE END ET */
112
113/* Exported constants --------------------------------------------------------*/
114/* USER CODE BEGIN EC */
115
116/* USER CODE END EC */
117
118/* Exported macro ------------------------------------------------------------*/
119/* USER CODE BEGIN EM */
120
121/* USER CODE END EM */
122
123void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
124
125/* Exported functions prototypes ---------------------------------------------*/
126void Error_Handler(void);
127
128/* USER CODE BEGIN EFP */
129
130/* USER CODE END EFP */
131
132/* Private defines -----------------------------------------------------------*/
138#define GPIO_1_Pin GPIO_PIN_5
139#define GPIO_1_GPIO_Port GPIOE
140#define TIM15_CH2_BUZZER_Pin GPIO_PIN_6
141#define TIM15_CH2_BUZZER_GPIO_Port GPIOE
142#define ADC3_BATTERY_Pin GPIO_PIN_1
143#define ADC3_BATTERY_GPIO_Port GPIOC
144#define GPIO_2_Pin GPIO_PIN_0
145#define GPIO_2_GPIO_Port GPIOA
146#define GPIO_3_AIRBRAKES_AUX_Pin GPIO_PIN_1
147#define GPIO_3_AIRBRAKES_AUX_GPIO_Port GPIOA
148#define TIM2_CH3_PWM_AIRBRAKES_Pin GPIO_PIN_2
149#define TIM2_CH3_PWM_AIRBRAKES_GPIO_Port GPIOA
150#define GPIO4_CAMERA_Pin GPIO_PIN_3
151#define GPIO4_CAMERA_GPIO_Port GPIOA
152#define GIO_SPI1_CS_Pin GPIO_PIN_4
153#define GIO_SPI1_CS_GPIO_Port GPIOA
154#define ADC1_Pyrocheck1_Pin GPIO_PIN_5
155#define ADC1_Pyrocheck1_GPIO_Port GPIOC
156#define ADC2_Pyrocheck2_Pin GPIO_PIN_0
157#define ADC2_Pyrocheck2_GPIO_Port GPIOB
158#define GPIO_LED_FLASH_Pin GPIO_PIN_12
159#define GPIO_LED_FLASH_GPIO_Port GPIOE
160#define BARO_CS_Pin GPIO_PIN_8
161#define BARO_CS_GPIO_Port GPIOD
162#define IMU_CS_Pin GPIO_PIN_9
163#define IMU_CS_GPIO_Port GPIOD
164#define MAG_CS_Pin GPIO_PIN_10
165#define MAG_CS_GPIO_Port GPIOD
166#define GPIO_LED1_Pin GPIO_PIN_13
167#define GPIO_LED1_GPIO_Port GPIOD
168#define GPIO_Pyro_EN1_Pin GPIO_PIN_6
169#define GPIO_Pyro_EN1_GPIO_Port GPIOC
170#define GPIO_Pyro_EN2_Pin GPIO_PIN_7
171#define GPIO_Pyro_EN2_GPIO_Port GPIOC
172#define GPIO_DaVinci_Marc_SYNC_Pin GPIO_PIN_9
173#define GPIO_DaVinci_Marc_SYNC_GPIO_Port GPIOC
174#define GPIO_LED_USB_Pin GPIO_PIN_15
175#define GPIO_LED_USB_GPIO_Port GPIOA
176#define UART4_RX_DEBUG_Pin GPIO_PIN_0
177#define UART4_RX_DEBUG_GPIO_Port GPIOD
178#define UART4_TX_DEBUG_Pin GPIO_PIN_1
179#define UART4_TX_DEBUG_GPIO_Port GPIOD
180#define SPI3_MOSI_SENSEB_Pin GPIO_PIN_5
181#define SPI3_MOSI_SENSEB_GPIO_Port GPIOB
182#define GPIO_LED2_Pin GPIO_PIN_0
183#define GPIO_LED2_GPIO_Port GPIOE
184#define GPIO_LED3_Pin GPIO_PIN_1
185#define GPIO_LED3_GPIO_Port GPIOE
187/* USER CODE BEGIN Private defines */
193// --- SPI Chip Select Macros ---
194#define IMU_CS_HIGH HAL_GPIO_WritePin(IMU_CS_GPIO_Port, IMU_CS_Pin, GPIO_PIN_SET)
195#define IMU_CS_LOW HAL_GPIO_WritePin(IMU_CS_GPIO_Port, IMU_CS_Pin, GPIO_PIN_RESET)
196#define BMP390_CS_LOW HAL_GPIO_WritePin(BARO_CS_GPIO_Port, BARO_CS_Pin, GPIO_PIN_RESET)
197#define BMP390_CS_HIGH HAL_GPIO_WritePin(BARO_CS_GPIO_Port, BARO_CS_Pin, GPIO_PIN_SET)
198#define MAG_CS_LOW HAL_GPIO_WritePin(MAG_CS_GPIO_Port, MAG_CS_Pin, GPIO_PIN_RESET)
199#define MAG_CS_HIGH HAL_GPIO_WritePin(MAG_CS_GPIO_Port, MAG_CS_Pin, GPIO_PIN_SET)
200
201// --- LED Control Macros ---
202#define LED_ON(port, pin) HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET)
203#define LED_OFF(port, pin) HAL_GPIO_WritePin(port, pin, GPIO_PIN_RESET)
204#define LED_TOGGLE(port,pin) HAL_GPIO_TogglePin(port,pin)
206/* USER CODE END Private defines */
207
208#ifdef __cplusplus
209}
210#endif
211
212#endif /* __MAIN_H */
Defines mission-critical constants and tunable parameters for the flight software.
Defines the states, events, and data structures for the rocket's main Flight State Machine (FSM).
bool flag_kf
RTOS event flag to trigger the Kalman Filter task.
Definition main.c:301
bool flag_MPC
RTOS event flag to trigger the MPC task.
Definition main.c:303
TIM_HandleTypeDef htim15
HAL Timer handle for the buzzer PWM.
Definition main.c:69
bool flag_flash
RTOS event flag to trigger the data logging task.
Definition main.c:307
uint8_t drogue
Status flag for the drogue parachute pyro channel.
Definition main.c:229
SPI_HandleTypeDef hspi2
HAL SPI handle for Sensor Bus 1 (e.g., IMU, Baro).
Definition main.c:62
bool flag_attitude
RTOS event flag to trigger the attitude estimation task.
Definition main.c:302
QSPI_HandleTypeDef hqspi
HAL QSPI handle for the external flash memory.
Definition main.c:58
SPI_HandleTypeDef hspi3
HAL SPI handle for Sensor Bus 2 (e.g., secondary sensors).
Definition main.c:63
uint8_t mainp
Status flag for the main parachute pyro channel.
Definition main.c:230
This file contains all the functions prototypes for the lis2mdl_reg.c driver.
This file contains all the functions prototypes for the lsm6dso32_reg.c driver.
void Error_Handler(void)
This function is executed in case of error occurrence.
Definition main.c:2042
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim)
Provides low-level hardware drivers, sensor initialization routines, and various utility functions fo...