CubeMX broke things on my other computer
This commit is contained in:
parent
69e7641b34
commit
58c696f094
39 changed files with 335807 additions and 48449 deletions
51
Src/main.c
51
Src/main.c
|
|
@ -40,7 +40,6 @@
|
|||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "math.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
|
@ -65,6 +64,7 @@
|
|||
/* Private variables ---------------------------------------------------------*/
|
||||
ADC_HandleTypeDef hadc2;
|
||||
|
||||
TIM_HandleTypeDef htim2;
|
||||
TIM_HandleTypeDef htim4;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
|
@ -79,6 +79,7 @@ void SystemClock_Config(void);
|
|||
static void MX_GPIO_Init(void);
|
||||
static void MX_ADC2_Init(void);
|
||||
static void MX_TIM4_Init(void);
|
||||
static void MX_TIM2_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
|
@ -118,6 +119,7 @@ int main(void)
|
|||
MX_GPIO_Init();
|
||||
MX_ADC2_Init();
|
||||
MX_TIM4_Init();
|
||||
MX_TIM2_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
HAL_ADC_Start_IT(&hadc2);
|
||||
//Use PWM to control? or simple loop?
|
||||
|
|
@ -230,6 +232,53 @@ static void MX_ADC2_Init(void)
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM2 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM2_Init 0 */
|
||||
|
||||
/* USER CODE END TIM2_Init 0 */
|
||||
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM2_Init 1 */
|
||||
|
||||
/* USER CODE END TIM2_Init 1 */
|
||||
htim2.Instance = TIM2;
|
||||
htim2.Init.Prescaler = 0;
|
||||
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim2.Init.Period = 0xFFFFFFFF;
|
||||
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
if (HAL_TIM_OC_Init(&htim2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sConfigOC.OCMode = TIM_OCMODE_TIMING;
|
||||
sConfigOC.Pulse = 0;
|
||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||
if (HAL_TIM_OC_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM2_Init 2 */
|
||||
|
||||
/* USER CODE END TIM2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM4 Initialization Function
|
||||
* @param None
|
||||
|
|
|
|||
|
|
@ -168,6 +168,29 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM_OC MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param htim_oc: TIM_OC handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc)
|
||||
{
|
||||
|
||||
if(htim_oc->Instance==TIM2)
|
||||
{
|
||||
/* USER CODE BEGIN TIM2_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM2_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_TIM2_CLK_ENABLE();
|
||||
/* USER CODE BEGIN TIM2_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM2_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM_PWM MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
|
|
@ -218,6 +241,30 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
|
|||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief TIM_OC MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param htim_oc: TIM_OC handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc)
|
||||
{
|
||||
|
||||
if(htim_oc->Instance==TIM2)
|
||||
{
|
||||
/* USER CODE BEGIN TIM2_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM2_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM2_CLK_DISABLE();
|
||||
/* USER CODE BEGIN TIM2_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM2_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM_PWM MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue