source: ecs_cellMon/firmware/Core/Src/dac.c

Last change on this file was 3, checked in by f.jahn, 20 months ago

fw hinzugfügt-->zed

File size: 3.1 KB
Line 
1/**
2  ******************************************************************************
3  * @file    dac.c
4  * @brief   This file provides code for the configuration
5  *          of the DAC instances.
6  ******************************************************************************
7  * @attention
8  *
9  * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
10  * All rights reserved.</center></h2>
11  *
12  * This software component is licensed by ST under BSD 3-Clause license,
13  * the "License"; You may not use this file except in compliance with the
14  * License. You may obtain a copy of the License at:
15  *                        opensource.org/licenses/BSD-3-Clause
16  *
17  ******************************************************************************
18  */
19
20/* Includes ------------------------------------------------------------------*/
21#include "dac.h"
22
23/* USER CODE BEGIN 0 */
24
25/* USER CODE END 0 */
26
27DAC_HandleTypeDef hdac1;
28
29/* DAC1 init function */
30void MX_DAC1_Init(void)
31{
32
33  /* USER CODE BEGIN DAC1_Init 0 */
34
35  /* USER CODE END DAC1_Init 0 */
36
37  DAC_ChannelConfTypeDef sConfig = {0};
38
39  /* USER CODE BEGIN DAC1_Init 1 */
40
41  /* USER CODE END DAC1_Init 1 */
42  /** DAC Initialization
43  */
44  hdac1.Instance = DAC1;
45  if (HAL_DAC_Init(&hdac1) != HAL_OK)
46  {
47    Error_Handler();
48  }
49  /** DAC channel OUT1 config
50  */
51  sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;
52  sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
53  sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
54  sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_ENABLE;
55  sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY;
56  if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK)
57  {
58    Error_Handler();
59  }
60  /* USER CODE BEGIN DAC1_Init 2 */
61
62  /* USER CODE END DAC1_Init 2 */
63
64}
65
66void HAL_DAC_MspInit(DAC_HandleTypeDef* dacHandle)
67{
68
69  GPIO_InitTypeDef GPIO_InitStruct = {0};
70  if(dacHandle->Instance==DAC1)
71  {
72  /* USER CODE BEGIN DAC1_MspInit 0 */
73
74  /* USER CODE END DAC1_MspInit 0 */
75    /* DAC1 clock enable */
76    __HAL_RCC_DAC1_CLK_ENABLE();
77
78    __HAL_RCC_GPIOA_CLK_ENABLE();
79    /**DAC1 GPIO Configuration
80    PA4     ------> DAC1_OUT1
81    */
82    GPIO_InitStruct.Pin = DAC1_OUT1_I_CTR_TP_Pin;
83    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
84    GPIO_InitStruct.Pull = GPIO_NOPULL;
85    HAL_GPIO_Init(DAC1_OUT1_I_CTR_TP_GPIO_Port, &GPIO_InitStruct);
86
87  /* USER CODE BEGIN DAC1_MspInit 1 */
88
89  /* USER CODE END DAC1_MspInit 1 */
90  }
91}
92
93void HAL_DAC_MspDeInit(DAC_HandleTypeDef* dacHandle)
94{
95
96  if(dacHandle->Instance==DAC1)
97  {
98  /* USER CODE BEGIN DAC1_MspDeInit 0 */
99
100  /* USER CODE END DAC1_MspDeInit 0 */
101    /* Peripheral clock disable */
102    __HAL_RCC_DAC1_CLK_DISABLE();
103
104    /**DAC1 GPIO Configuration
105    PA4     ------> DAC1_OUT1
106    */
107    HAL_GPIO_DeInit(DAC1_OUT1_I_CTR_TP_GPIO_Port, DAC1_OUT1_I_CTR_TP_Pin);
108
109  /* USER CODE BEGIN DAC1_MspDeInit 1 */
110
111  /* USER CODE END DAC1_MspDeInit 1 */
112  }
113}
114
115/* USER CODE BEGIN 1 */
116
117/* USER CODE END 1 */
118
119/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Note: See TracBrowser for help on using the repository browser.