Files
RFG_stm32_ADC_STM32F429/Core/Inc/main.h

118 lines
3.6 KiB
C

/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
#define CURR_STEP_START_TRG_Pin GPIO_PIN_0
#define CURR_STEP_START_TRG_GPIO_Port GPIOC
#define CURR_STEP_START_TRG_EXTI_IRQn EXTI0_IRQn
#define SWEEP_CYCLE_START_TRG_Pin GPIO_PIN_3
#define SWEEP_CYCLE_START_TRG_GPIO_Port GPIOC
#define SWEEP_CYCLE_START_TRG_EXTI_IRQn EXTI3_IRQn
#define LED_RED_Pin GPIO_PIN_14
#define LED_RED_GPIO_Port GPIOB
#define LED_BLUE_Pin GPIO_PIN_7
#define LED_BLUE_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
/* Shared ADC app types and declarations */
/* Size of circular DMA buffer for ADC1 */
#ifndef ADC_BUFF_SIZE
#define ADC_BUFF_SIZE 64
#endif
#define SYNC_DET_ON
/* Structure describing simple accumulation state for ADC processing */
struct ADC_proc_typedef {
uint8_t status; /* 0 - stopped, 1 - collecting, 2 - filled */
uint32_t sum;
uint32_t sum_ON;
uint32_t sum_OFF;
uint32_t avg_ON;
uint32_t avg_OFF;
uint32_t N; /* number of ON/OFF pairs accumulated */
uint32_t N_on; /* number of ON samples accumulated */
uint32_t N_off; /* number of OFF samples accumulated */
};
/* Sweep state shared between ISR and main */
struct Sweep_state_typedef {
uint32_t curr_step_N;
uint8_t curr_step_started_flag; //0 -- not started or waiting for; 1 -- first 1/2 DMA buff; 2 -- second 1/2 DMA buff
uint32_t curr_step_start_DMA_N;
uint8_t sweep_cycle_started_flag; // 0 -- not started; 1 -- started
};
/* Externs provided by main.c */
extern volatile struct ADC_proc_typedef ADC_proc;
extern volatile struct ADC_proc_typedef ADC_proc_shadow;
extern volatile struct Sweep_state_typedef Sweep_state;
extern volatile uint32_t curr_step_start_N;
extern uint16_t ADC1_buff_circular[ADC_BUFF_SIZE];
extern volatile uint32_t sample_seq;
/* USER CODE END Private defines */
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */