77 lines
2.2 KiB
C
77 lines
2.2 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file dac.c
|
|
* @brief This file provides code for the configuration
|
|
* of the DAC instances.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* Copyright (c) 2023 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 */
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "dac.h"
|
|
|
|
/* USER CODE BEGIN 0 */
|
|
|
|
/* USER CODE END 0 */
|
|
|
|
/* DAC1 init function */
|
|
void MX_DAC1_Init(void)
|
|
{
|
|
|
|
/* USER CODE BEGIN DAC1_Init 0 */
|
|
|
|
/* USER CODE END DAC1_Init 0 */
|
|
|
|
LL_DAC_InitTypeDef DAC_InitStruct = {0};
|
|
|
|
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
|
|
/* Peripheral clock enable */
|
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_DAC1);
|
|
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA);
|
|
/**DAC1 GPIO Configuration
|
|
PA5 ------> DAC1_OUT2
|
|
*/
|
|
GPIO_InitStruct.Pin = DAC_CONTROL_Pin;
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
LL_GPIO_Init(DAC_CONTROL_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/* DAC1 interrupt Init */
|
|
NVIC_SetPriority(TIM6_DAC_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),6, 0));
|
|
NVIC_EnableIRQ(TIM6_DAC_IRQn);
|
|
|
|
/* USER CODE BEGIN DAC1_Init 1 */
|
|
|
|
/* USER CODE END DAC1_Init 1 */
|
|
|
|
/** DAC channel OUT2 config
|
|
*/
|
|
DAC_InitStruct.TriggerSource = LL_DAC_TRIG_SOFTWARE;
|
|
DAC_InitStruct.WaveAutoGeneration = LL_DAC_WAVE_AUTO_GENERATION_NONE;
|
|
DAC_InitStruct.OutputBuffer = LL_DAC_OUTPUT_BUFFER_DISABLE;
|
|
DAC_InitStruct.OutputConnection = LL_DAC_OUTPUT_CONNECT_GPIO;
|
|
DAC_InitStruct.OutputMode = LL_DAC_OUTPUT_MODE_NORMAL;
|
|
LL_DAC_Init(DAC1, LL_DAC_CHANNEL_2, &DAC_InitStruct);
|
|
LL_DAC_DisableTrigger(DAC1, LL_DAC_CHANNEL_2);
|
|
/* USER CODE BEGIN DAC1_Init 2 */
|
|
|
|
/* USER CODE END DAC1_Init 2 */
|
|
|
|
}
|
|
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE END 1 */
|