Subversion Repositories LedShow

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 9
Line 1... Line 1...
1
/**
1
/**
2
  ******************************************************************************
2
  ******************************************************************************
3
  * @file    stm32f1xx_hal_dac_ex.c
3
  * @file    stm32f1xx_hal_dac_ex.c
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @brief   DAC HAL module driver.
5
  * @brief   DAC HAL module driver.
6
  *         This file provides firmware functions to manage the following
6
  *          This file provides firmware functions to manage the extended
7
  *         functionalities of DAC extension peripheral:
7
  *          functionalities of the DAC peripheral.
8
  *           + Extended features functions
-
 
9
  *    
-
 
10
  *
8
  *
-
 
9
  *
11
  @verbatim      
10
  @verbatim
12
  ==============================================================================
11
  ==============================================================================
13
                      ##### How to use this driver #####
12
                      ##### How to use this driver #####
14
  ==============================================================================
13
  ==============================================================================
15
    [..]          
14
    [..]
-
 
15
     *** Dual mode IO operation ***
-
 
16
     ==============================
16
      (+) When Dual mode is enabled (i.e DAC Channel1 and Channel2 are used simultaneously) :
17
      (+) When Dual mode is enabled (i.e. DAC Channel1 and Channel2 are used simultaneously) :
17
          Use HAL_DACEx_DualGetValue() to get digital data to be converted and use
18
          Use HAL_DACEx_DualGetValue() to get digital data to be converted and use
18
          HAL_DACEx_DualSetValue() to set digital value to converted simultaneously in Channel 1 and Channel 2.  
19
          HAL_DACEx_DualSetValue() to set digital value to converted simultaneously in
-
 
20
          Channel 1 and Channel 2.
-
 
21
 
-
 
22
     *** Signal generation operation ***
-
 
23
     ===================================
19
      (+) Use HAL_DACEx_TriangleWaveGenerate() to generate Triangle signal.
24
      (+) Use HAL_DACEx_TriangleWaveGenerate() to generate Triangle signal.
20
      (+) Use HAL_DACEx_NoiseWaveGenerate() to generate Noise signal.
25
      (+) Use HAL_DACEx_NoiseWaveGenerate() to generate Noise signal.
21
   
26
 
22
 @endverbatim    
27
 @endverbatim
23
  ******************************************************************************
28
  ******************************************************************************
24
  * @attention
29
  * @attention
25
  *
30
  *
26
  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
31
  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
-
 
32
  * All rights reserved.</center></h2>
27
  *
33
  *
28
  * Redistribution and use in source and binary forms, with or without modification,
34
  * This software component is licensed by ST under BSD 3-Clause license,
29
  * are permitted provided that the following conditions are met:
35
  * the "License"; You may not use this file except in compliance with the
30
  *   1. Redistributions of source code must retain the above copyright notice,
-
 
31
  *      this list of conditions and the following disclaimer.
-
 
32
  *   2. Redistributions in binary form must reproduce the above copyright notice,
-
 
33
  *      this list of conditions and the following disclaimer in the documentation
-
 
34
  *      and/or other materials provided with the distribution.
36
  * License. You may obtain a copy of the License at:
35
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-
 
36
  *      may be used to endorse or promote products derived from this software
37
  *                        opensource.org/licenses/BSD-3-Clause
37
  *      without specific prior written permission.
-
 
38
  *
-
 
39
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-
 
40
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-
 
41
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-
 
42
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-
 
43
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-
 
44
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-
 
45
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-
 
46
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-
 
47
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-
 
48
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
49
  *
38
  *
50
  ******************************************************************************
39
  ******************************************************************************
51
  */
40
  */
52
 
41
 
53
 
42
 
54
/* Includes ------------------------------------------------------------------*/
43
/* Includes ------------------------------------------------------------------*/
55
#include "stm32f1xx_hal.h"
44
#include "stm32f1xx_hal.h"
56
 
45
 
57
/** @addtogroup STM32F1xx_HAL_Driver
46
/** @addtogroup STM32F1xx_HAL_Driver
58
  * @{
47
  * @{
59
  */
48
  */
60
 
49
 
-
 
50
#ifdef HAL_DAC_MODULE_ENABLED
-
 
51
 
-
 
52
#if defined(DAC)
-
 
53
 
61
/** @defgroup DACEx DACEx
54
/** @defgroup DACEx DACEx
62
  * @brief DACEx driver module
55
  * @brief DAC Extended HAL module driver
63
  * @{
56
  * @{
64
  */
57
  */
65
 
-
 
66
#ifdef HAL_DAC_MODULE_ENABLED
-
 
67
#if defined (STM32F100xB) || defined (STM32F100xE) || defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
-
 
68
 
58
 
69
/* Private typedef -----------------------------------------------------------*/
59
/* Private typedef -----------------------------------------------------------*/
70
/* Private define ------------------------------------------------------------*/
60
/* Private define ------------------------------------------------------------*/
71
/* Private macro -------------------------------------------------------------*/
61
/* Private macro -------------------------------------------------------------*/
72
/* Private variables ---------------------------------------------------------*/
62
/* Private variables ---------------------------------------------------------*/
73
/* Private function prototypes -----------------------------------------------*/
63
/* Private function prototypes -----------------------------------------------*/
74
/* Exported functions --------------------------------------------------------*/
64
/* Exported functions --------------------------------------------------------*/
75
 
65
 
76
/** @defgroup DACEx_Exported_Functions DACEx Exported Functions
66
/** @defgroup DACEx_Exported_Functions DACEx Exported Functions
77
  * @{
67
  * @{
78
  */
68
  */
79
 
69
 
80
/** @defgroup DACEx_Exported_Functions_Group1 Extended features functions
70
/** @defgroup DACEx_Exported_Functions_Group2 IO operation functions
81
 *  @brief    Extended features functions
71
  *  @brief    Extended IO operation functions
82
 *
72
  *
83
@verbatim  
73
@verbatim
84
  ==============================================================================
74
  ==============================================================================
85
                 ##### Extended features functions #####
75
                 ##### Extended features functions #####
86
  ==============================================================================  
76
  ==============================================================================
87
    [..]  This section provides functions allowing to:
77
    [..]  This section provides functions allowing to:
88
      (+) Start conversion.
78
      (+) Start conversion.
89
      (+) Stop conversion.
79
      (+) Stop conversion.
90
      (+) Start conversion and enable DMA transfer.
80
      (+) Start conversion and enable DMA transfer.
91
      (+) Stop conversion and disable DMA transfer.
81
      (+) Stop conversion and disable DMA transfer.
92
      (+) Get result of conversion.
82
      (+) Get result of conversion.
93
      (+) Get result of dual mode conversion.
83
      (+) Get result of dual mode conversion.
94
                     
-
 
-
 
84
 
95
@endverbatim
85
@endverbatim
96
  * @{
86
  * @{
97
  */
87
  */
98
 
88
 
99
/**
89
/**
100
  * @brief  Returns the last data output value of the selected DAC channel.
-
 
101
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
-
 
102
  *         the configuration information for the specified DAC.
-
 
103
  * @retval The selected DAC channel data output value.
-
 
104
  */
-
 
105
uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac)
-
 
106
{
-
 
107
  uint32_t tmp = 0U;
-
 
108
 
-
 
109
  tmp |= hdac->Instance->DOR1;
-
 
110
 
-
 
111
  tmp |= hdac->Instance->DOR2 << 16U;
-
 
112
 
-
 
113
  /* Returns the DAC channel data output register value */
-
 
114
  return tmp;
-
 
115
}
-
 
116
 
-
 
117
/**
-
 
118
  * @brief  Enables or disables the selected DAC channel wave generation.
90
  * @brief  Enable or disable the selected DAC channel wave generation.
119
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
91
  * @param  hdac pointer to a DAC_HandleTypeDef structure that contains
120
  *         the configuration information for the specified DAC.
92
  *         the configuration information for the specified DAC.
121
  * @param  Channel: The selected DAC channel.
93
  * @param  Channel The selected DAC channel.
122
  *          This parameter can be one of the following values:
94
  *          This parameter can be one of the following values:
123
  *            DAC_CHANNEL_1 / DAC_CHANNEL_2
95
  *            @arg DAC_CHANNEL_1: DAC Channel1 selected
-
 
96
  *            @arg DAC_CHANNEL_2: DAC Channel2 selected
124
  * @param  Amplitude: Select max triangle amplitude.
97
  * @param  Amplitude Select max triangle amplitude.
125
  *          This parameter can be one of the following values:
98
  *          This parameter can be one of the following values:
126
  *            @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1
99
  *            @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1
127
  *            @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3
100
  *            @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3
128
  *            @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7
101
  *            @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7
129
  *            @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15
102
  *            @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15
Line 132... Line 105...
132
  *            @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127
105
  *            @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127
133
  *            @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255
106
  *            @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255
134
  *            @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511
107
  *            @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511
135
  *            @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023
108
  *            @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023
136
  *            @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047
109
  *            @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047
137
  *            @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095                              
110
  *            @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095
138
  * @retval HAL status
111
  * @retval HAL status
139
  */
112
  */
140
HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude)
113
HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Amplitude)
141
{  
114
{
142
  /* Check the parameters */
115
  /* Check the parameters */
143
  assert_param(IS_DAC_CHANNEL(Channel));
116
  assert_param(IS_DAC_CHANNEL(Channel));
144
  assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
117
  assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
145
 
118
 
146
  /* Process locked */
119
  /* Process locked */
147
  __HAL_LOCK(hdac);
120
  __HAL_LOCK(hdac);
148
 
121
 
149
  /* Change DAC state */
122
  /* Change DAC state */
150
  hdac->State = HAL_DAC_STATE_BUSY;
123
  hdac->State = HAL_DAC_STATE_BUSY;
151
 
124
 
152
  /* Enable the selected wave generation for the selected DAC channel */
125
  /* Enable the triangle wave generation for the selected DAC channel */
153
  MODIFY_REG(hdac->Instance->CR, ((DAC_CR_WAVE1)|(DAC_CR_MAMP1))<<Channel, (DAC_CR_WAVE1_1 | Amplitude) << Channel);
126
  MODIFY_REG(hdac->Instance->CR, ((DAC_CR_WAVE1) | (DAC_CR_MAMP1)) << (Channel & 0x10UL), (DAC_CR_WAVE1_1 | Amplitude) << (Channel & 0x10UL));
154
 
127
 
155
  /* Change DAC state */
128
  /* Change DAC state */
156
  hdac->State = HAL_DAC_STATE_READY;
129
  hdac->State = HAL_DAC_STATE_READY;
157
 
130
 
158
  /* Process unlocked */
131
  /* Process unlocked */
159
  __HAL_UNLOCK(hdac);
132
  __HAL_UNLOCK(hdac);
160
 
133
 
161
  /* Return function status */
134
  /* Return function status */
162
  return HAL_OK;
135
  return HAL_OK;
163
}
136
}
164
 
137
 
165
/**
138
/**
166
  * @brief  Enables or disables the selected DAC channel wave generation.
139
  * @brief  Enable or disable the selected DAC channel wave generation.
167
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
140
  * @param  hdac pointer to a DAC_HandleTypeDef structure that contains
168
  *         the configuration information for the specified DAC.
141
  *         the configuration information for the specified DAC.
169
  * @param  Channel: The selected DAC channel.
142
  * @param  Channel The selected DAC channel.
-
 
143
  *          This parameter can be one of the following values:
-
 
144
  *            @arg DAC_CHANNEL_1: DAC Channel1 selected
-
 
145
  *            @arg DAC_CHANNEL_2: DAC Channel2 selected
-
 
146
  * @param  Amplitude Unmask DAC channel LFSR for noise wave generation.
170
  *          This parameter can be one of the following values:
147
  *          This parameter can be one of the following values:
171
  *            DAC_CHANNEL_1 / DAC_CHANNEL_2
-
 
172
  * @param  Amplitude: Unmask DAC channel LFSR for noise wave generation.
-
 
173
  *          This parameter can be one of the following values:
-
 
174
  *            @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation
148
  *            @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation
175
  *            @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation  
149
  *            @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation
176
  *            @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation
150
  *            @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation
177
  *            @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation
151
  *            @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation
178
  *            @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation
152
  *            @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation
179
  *            @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation
153
  *            @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation
180
  *            @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation
154
  *            @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation
181
  *            @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation
155
  *            @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation
182
  *            @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation
156
  *            @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation
183
  *            @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation
157
  *            @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation
184
  *            @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation
158
  *            @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation
185
  *            @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation
159
  *            @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation
186
  * @retval HAL status
160
  * @retval HAL status
187
  */
161
  */
188
HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude)
162
HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Amplitude)
189
{  
163
{
190
  /* Check the parameters */
164
  /* Check the parameters */
191
  assert_param(IS_DAC_CHANNEL(Channel));
165
  assert_param(IS_DAC_CHANNEL(Channel));
192
  assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
166
  assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
193
 
167
 
194
  /* Process locked */
168
  /* Process locked */
195
  __HAL_LOCK(hdac);
169
  __HAL_LOCK(hdac);
196
 
170
 
197
  /* Change DAC state */
171
  /* Change DAC state */
198
  hdac->State = HAL_DAC_STATE_BUSY;
172
  hdac->State = HAL_DAC_STATE_BUSY;
199
 
173
 
200
  /* Enable the selected wave generation for the selected DAC channel */
174
  /* Enable the noise wave generation for the selected DAC channel */
201
  MODIFY_REG(hdac->Instance->CR, ((DAC_CR_WAVE1)|(DAC_CR_MAMP1))<<Channel, (DAC_CR_WAVE1_0 | Amplitude) << Channel);
175
  MODIFY_REG(hdac->Instance->CR, ((DAC_CR_WAVE1) | (DAC_CR_MAMP1)) << (Channel & 0x10UL), (DAC_CR_WAVE1_0 | Amplitude) << (Channel & 0x10UL));
202
 
176
 
203
  /* Change DAC state */
177
  /* Change DAC state */
204
  hdac->State = HAL_DAC_STATE_READY;
178
  hdac->State = HAL_DAC_STATE_READY;
205
 
179
 
206
  /* Process unlocked */
180
  /* Process unlocked */
207
  __HAL_UNLOCK(hdac);
181
  __HAL_UNLOCK(hdac);
208
 
182
 
209
  /* Return function status */
183
  /* Return function status */
210
  return HAL_OK;
184
  return HAL_OK;
211
}
185
}
212
 
186
 
213
/**
187
/**
214
  * @brief  Set the specified data holding register value for dual DAC channel.
188
  * @brief  Set the specified data holding register value for dual DAC channel.
215
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
189
  * @param  hdac pointer to a DAC_HandleTypeDef structure that contains
216
  *               the configuration information for the specified DAC.
190
  *               the configuration information for the specified DAC.
217
  * @param  Alignment: Specifies the data alignment for dual channel DAC.
191
  * @param  Alignment Specifies the data alignment for dual channel DAC.
218
  *          This parameter can be one of the following values:
192
  *          This parameter can be one of the following values:
219
  *            DAC_ALIGN_8B_R: 8bit right data alignment selected
193
  *            DAC_ALIGN_8B_R: 8bit right data alignment selected
220
  *            DAC_ALIGN_12B_L: 12bit left data alignment selected
194
  *            DAC_ALIGN_12B_L: 12bit left data alignment selected
221
  *            DAC_ALIGN_12B_R: 12bit right data alignment selected
195
  *            DAC_ALIGN_12B_R: 12bit right data alignment selected
222
  * @param  Data1: Data for DAC Channel2 to be loaded in the selected data holding register.
196
  * @param  Data1 Data for DAC Channel1 to be loaded in the selected data holding register.
223
  * @param  Data2: Data for DAC Channel1 to be loaded in the selected data  holding register.
197
  * @param  Data2 Data for DAC Channel2 to be loaded in the selected data  holding register.
224
  * @note   In dual mode, a unique register access is required to write in both
198
  * @note   In dual mode, a unique register access is required to write in both
225
  *          DAC channels at the same time.
199
  *          DAC channels at the same time.
226
  * @retval HAL status
200
  * @retval HAL status
227
  */
201
  */
228
HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2)
202
HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef *hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2)
229
{  
203
{
230
  uint32_t data = 0U, tmp = 0U;
204
  uint32_t data;
-
 
205
  uint32_t tmp;
231
 
206
 
232
  /* Check the parameters */
207
  /* Check the parameters */
233
  assert_param(IS_DAC_ALIGN(Alignment));
208
  assert_param(IS_DAC_ALIGN(Alignment));
234
  assert_param(IS_DAC_DATA(Data1));
209
  assert_param(IS_DAC_DATA(Data1));
235
  assert_param(IS_DAC_DATA(Data2));
210
  assert_param(IS_DAC_DATA(Data2));
236
 
211
 
237
  /* Calculate and set dual DAC data holding register value */
212
  /* Calculate and set dual DAC data holding register value */
238
  if (Alignment == DAC_ALIGN_8B_R)
213
  if (Alignment == DAC_ALIGN_8B_R)
239
  {
214
  {
240
    data = ((uint32_t)Data2 << 8U) | Data1;
215
    data = ((uint32_t)Data2 << 8U) | Data1;
241
  }
216
  }
242
  else
217
  else
243
  {
218
  {
244
    data = ((uint32_t)Data2 << 16U) | Data1;
219
    data = ((uint32_t)Data2 << 16U) | Data1;
245
  }
220
  }
246
 
221
 
247
  tmp = (uint32_t)hdac->Instance;
222
  tmp = (uint32_t)hdac->Instance;
248
  tmp += DAC_DHR12RD_ALIGNMENT(Alignment);
223
  tmp += DAC_DHR12RD_ALIGNMENT(Alignment);
249
 
224
 
250
  /* Set the dual DAC selected data holding register */
225
  /* Set the dual DAC selected data holding register */
251
  *(__IO uint32_t *)tmp = data;
226
  *(__IO uint32_t *)tmp = data;
252
 
227
 
253
  /* Return function status */
228
  /* Return function status */
254
  return HAL_OK;
229
  return HAL_OK;
255
}
230
}
256
 
231
 
257
/**
232
/**
258
  * @brief  Conversion complete callback in non blocking mode for Channel2
233
  * @brief  Conversion complete callback in non-blocking mode for Channel2.
259
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
234
  * @param  hdac pointer to a DAC_HandleTypeDef structure that contains
260
  *         the configuration information for the specified DAC.
235
  *         the configuration information for the specified DAC.
261
  * @retval None
236
  * @retval None
262
  */
237
  */
263
__weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac)
238
__weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef *hdac)
264
{
239
{
265
  /* Prevent unused argument(s) compilation warning */
240
  /* Prevent unused argument(s) compilation warning */
266
  UNUSED(hdac);
241
  UNUSED(hdac);
-
 
242
 
267
  /* NOTE : This function Should not be modified, when the callback is needed,
243
  /* NOTE : This function should not be modified, when the callback is needed,
268
            the HAL_DACEx_ConvCpltCallbackCh2 could be implemented in the user file
244
            the HAL_DACEx_ConvCpltCallbackCh2 could be implemented in the user file
269
   */
245
   */
270
}
246
}
271
 
247
 
272
/**
248
/**
273
  * @brief  Conversion half DMA transfer callback in non blocking mode for Channel2
249
  * @brief  Conversion half DMA transfer callback in non-blocking mode for Channel2.
274
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
250
  * @param  hdac pointer to a DAC_HandleTypeDef structure that contains
275
  *         the configuration information for the specified DAC.
251
  *         the configuration information for the specified DAC.
276
  * @retval None
252
  * @retval None
277
  */
253
  */
278
__weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac)
254
__weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef *hdac)
279
{
255
{
280
  /* Prevent unused argument(s) compilation warning */
256
  /* Prevent unused argument(s) compilation warning */
281
  UNUSED(hdac);
257
  UNUSED(hdac);
-
 
258
 
282
  /* NOTE : This function Should not be modified, when the callback is needed,
259
  /* NOTE : This function should not be modified, when the callback is needed,
283
            the HAL_DACEx_ConvHalfCpltCallbackCh2 could be implemented in the user file
260
            the HAL_DACEx_ConvHalfCpltCallbackCh2 could be implemented in the user file
284
   */
261
   */
285
}
262
}
286
 
263
 
287
/**
264
/**
288
  * @brief  Error DAC callback for Channel2.
265
  * @brief  Error DAC callback for Channel2.
289
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
266
  * @param  hdac pointer to a DAC_HandleTypeDef structure that contains
290
  *         the configuration information for the specified DAC.
267
  *         the configuration information for the specified DAC.
291
  * @retval None
268
  * @retval None
292
  */
269
  */
293
__weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac)
270
__weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac)
294
{
271
{
295
  /* Prevent unused argument(s) compilation warning */
272
  /* Prevent unused argument(s) compilation warning */
296
  UNUSED(hdac);
273
  UNUSED(hdac);
297
  /* NOTE : This function Should not be modified, when the callback is needed,
-
 
298
            the HAL_DACEx_ErrorCallbackCh2 could be implemented in the user file
-
 
299
   */
-
 
300
}
-
 
301
 
274
 
302
#if defined (STM32F100xB) || defined (STM32F100xE)
-
 
303
/**
-
 
304
  * @brief  DMA underrun DAC callback for channel1.
-
 
305
  *         Note: For STM32F100x devices with specific feature: DMA underrun.
-
 
306
  *         On these devices, this function uses the interruption of DMA
-
 
307
  *         underrun.
-
 
308
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
-
 
309
  *         the configuration information for the specified DAC.
-
 
310
  * @retval None
-
 
311
  */
-
 
312
__weak void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac)
-
 
313
{
-
 
314
  /* Prevent unused argument(s) compilation warning */
-
 
315
  UNUSED(hdac);
-
 
316
  /* NOTE : This function Should not be modified, when the callback is needed,
275
  /* NOTE : This function should not be modified, when the callback is needed,
317
            the HAL_DAC_DMAUnderrunCallbackCh1 could be implemented in the user file
276
            the HAL_DACEx_ErrorCallbackCh2 could be implemented in the user file
318
   */
277
   */
319
}
278
}
320
 
279
 
321
/**
280
/**
322
  * @brief  DMA underrun DAC callback for channel2.
281
  * @brief  DMA underrun DAC callback for Channel2.
323
  *         Note: For STM32F100x devices with specific feature: DMA underrun.
-
 
324
  *         On these devices, this function uses the interruption of DMA
-
 
325
  *         underrun.
-
 
326
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
282
  * @param  hdac pointer to a DAC_HandleTypeDef structure that contains
327
  *         the configuration information for the specified DAC.
283
  *         the configuration information for the specified DAC.
328
  * @retval None
284
  * @retval None
329
  */
285
  */
330
__weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac)
286
__weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac)
331
{
287
{
332
  /* Prevent unused argument(s) compilation warning */
288
  /* Prevent unused argument(s) compilation warning */
333
  UNUSED(hdac);
289
  UNUSED(hdac);
-
 
290
 
334
  /* NOTE : This function Should not be modified, when the callback is needed,
291
  /* NOTE : This function should not be modified, when the callback is needed,
335
            the HAL_DACEx_DMAUnderrunCallbackCh2 could be implemented in the user file
292
            the HAL_DACEx_DMAUnderrunCallbackCh2 could be implemented in the user file
336
   */
293
   */
337
}
294
}
338
#endif /* STM32F100xB) || defined (STM32F100xE) */
-
 
339
 
295
 
340
/**
296
/**
341
  * @}
297
  * @}
342
  */
298
  */
343
 
299
 
344
#if defined (STM32F100xB) || defined (STM32F100xE)
-
 
345
/**
-
 
346
  * @brief  Enables DAC and starts conversion of channel.
-
 
347
  *         Note: For STM32F100x devices with specific feature: DMA underrun.
-
 
348
  *         On these devices, this function enables the interruption of DMA
-
 
349
  *         underrun.
-
 
350
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
300
/** @defgroup DACEx_Exported_Functions_Group3 Peripheral Control functions
351
  *         the configuration information for the specified DAC.
-
 
352
  * @param  Channel: The selected DAC channel.
-
 
353
  *          This parameter can be one of the following values:
-
 
354
  *            @arg DAC_CHANNEL_1: DAC Channel1 selected
-
 
355
  *            @arg DAC_CHANNEL_2: DAC Channel2 selected
-
 
356
  * @param  pData: The destination peripheral Buffer address.
301
  *  @brief    Extended Peripheral Control functions
357
  * @param  Length: The length of data to be transferred from memory to DAC peripheral
-
 
358
  * @param  Alignment: Specifies the data alignment for DAC channel.
-
 
359
  *          This parameter can be one of the following values:
-
 
360
  *            @arg DAC_ALIGN_8B_R: 8bit right data alignment selected
-
 
361
  *            @arg DAC_ALIGN_12B_L: 12bit left data alignment selected
-
 
362
  *            @arg DAC_ALIGN_12B_R: 12bit right data alignment selected
-
 
363
  * @retval HAL status
-
 
364
  */
302
  *
365
HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment)
-
 
366
{
-
 
367
  uint32_t tmpreg = 0U;
-
 
368
   
303
@verbatim
369
  /* Check the parameters */
-
 
370
  assert_param(IS_DAC_CHANNEL(Channel));
-
 
371
  assert_param(IS_DAC_ALIGN(Alignment));
-
 
372
 
-
 
373
  /* Process locked */
-
 
374
  __HAL_LOCK(hdac);
-
 
375
 
-
 
376
  /* Change DAC state */
-
 
377
  hdac->State = HAL_DAC_STATE_BUSY;
-
 
378
 
-
 
379
  if(Channel == DAC_CHANNEL_1)
-
 
380
  {
-
 
381
    /* Set the DMA transfer complete callback for channel1 */
-
 
382
    hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1;
-
 
383
 
-
 
384
    /* Set the DMA half transfer complete callback for channel1 */
-
 
385
    hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1;
304
  ==============================================================================
386
 
-
 
387
    /* Set the DMA error callback for channel1 */
305
             ##### Peripheral Control functions #####
388
    hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1;
306
  ==============================================================================
389
 
-
 
390
    /* Enable the selected DAC channel1 DMA request */
307
    [..]  This section provides functions allowing to:
391
    SET_BIT(hdac->Instance->CR, DAC_CR_DMAEN1);
-
 
392
       
-
 
393
    /* Case of use of channel 1 */
-
 
394
    switch(Alignment)
-
 
395
    {
-
 
396
      case DAC_ALIGN_12B_R:
-
 
397
        /* Get DHR12R1 address */
-
 
398
        tmpreg = (uint32_t)&hdac->Instance->DHR12R1;
-
 
399
        break;
-
 
400
      case DAC_ALIGN_12B_L:
-
 
401
        /* Get DHR12L1 address */
-
 
402
        tmpreg = (uint32_t)&hdac->Instance->DHR12L1;
-
 
403
        break;
-
 
404
      case DAC_ALIGN_8B_R:
-
 
405
        /* Get DHR8R1 address */
-
 
406
        tmpreg = (uint32_t)&hdac->Instance->DHR8R1;
-
 
407
        break;
-
 
408
      default:
-
 
409
        break;
-
 
410
    }
-
 
411
  }
-
 
412
  else
-
 
413
  {
-
 
414
    /* Set the DMA transfer complete callback for channel2 */
308
      (+) Set the specified data holding register value for DAC channel.
415
    hdac->DMA_Handle2->XferCpltCallback = DAC_DMAConvCpltCh2;
-
 
416
 
309
 
417
    /* Set the DMA half transfer complete callback for channel2 */
-
 
418
    hdac->DMA_Handle2->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh2;
-
 
419
   
-
 
420
    /* Set the DMA error callback for channel2 */
-
 
421
    hdac->DMA_Handle2->XferErrorCallback = DAC_DMAErrorCh2;
-
 
422
 
-
 
423
    /* Enable the selected DAC channel2 DMA request */
-
 
424
    SET_BIT(hdac->Instance->CR, DAC_CR_DMAEN2);
-
 
425
 
-
 
426
    /* Case of use of channel 2 */
-
 
427
    switch(Alignment)
-
 
428
    {
-
 
429
      case DAC_ALIGN_12B_R:
-
 
430
        /* Get DHR12R2 address */
-
 
431
        tmpreg = (uint32_t)&hdac->Instance->DHR12R2;
-
 
432
        break;
-
 
433
      case DAC_ALIGN_12B_L:
-
 
434
        /* Get DHR12L2 address */
-
 
435
        tmpreg = (uint32_t)&hdac->Instance->DHR12L2;
-
 
436
        break;
-
 
437
      case DAC_ALIGN_8B_R:
-
 
438
        /* Get DHR8R2 address */
-
 
439
        tmpreg = (uint32_t)&hdac->Instance->DHR8R2;
-
 
440
        break;
310
@endverbatim
441
      default:
-
 
442
        break;
-
 
443
    }
311
  * @{
444
  }
-
 
445
 
-
 
446
  /* Enable the DMA channel */
-
 
447
  if(Channel == DAC_CHANNEL_1)
-
 
448
  {
-
 
449
    /* Enable the DAC DMA underrun interrupt */
-
 
450
    __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1);
-
 
451
   
-
 
452
    /* Enable the DMA channel */
-
 
453
    HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length);
-
 
454
  }
-
 
455
  else
-
 
456
  {
-
 
457
    /* Enable the DAC DMA underrun interrupt */
-
 
458
    __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR2);
-
 
459
   
312
  */
460
    /* Enable the DMA channel */
-
 
461
    HAL_DMA_Start_IT(hdac->DMA_Handle2, (uint32_t)pData, tmpreg, Length);
-
 
462
  }
-
 
463
 
-
 
464
  /* Enable the Peripharal */
-
 
465
  __HAL_DAC_ENABLE(hdac, Channel);
-
 
466
 
-
 
467
  /* Process Unlocked */
-
 
468
  __HAL_UNLOCK(hdac);
-
 
469
 
-
 
470
  /* Return function status */
-
 
471
  return HAL_OK;
-
 
472
}
-
 
473
#endif /* STM32F100xB) || defined (STM32F100xE) */
-
 
474
 
313
 
475
#if defined (STM32F100xB) || defined (STM32F100xE)
-
 
476
/**
314
/**
477
  * @brief  Disables DAC and stop conversion of channel.
315
  * @brief  Return the last data output value of the selected DAC channel.
478
  *         Note: For STM32F100x devices with specific feature: DMA underrun.
-
 
479
  *         On these devices, this function disables the interruption of DMA
-
 
480
  *         underrun.
-
 
481
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
316
  * @param  hdac pointer to a DAC_HandleTypeDef structure that contains
482
  *         the configuration information for the specified DAC.
317
  *         the configuration information for the specified DAC.
483
  * @param  Channel: The selected DAC channel.
318
  * @retval The selected DAC channel data output value.
484
  *          This parameter can be one of the following values:
-
 
485
  *            @arg DAC_CHANNEL_1: DAC Channel1 selected
-
 
486
  *            @arg DAC_CHANNEL_2: DAC Channel2 selected  
-
 
487
  * @retval HAL status
-
 
488
  */
319
  */
489
HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel)
320
uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef *hdac)
490
{
321
{
491
  HAL_StatusTypeDef status = HAL_OK;
322
  uint32_t tmp = 0U;
492
 
323
 
493
  /* Check the parameters */
-
 
494
  assert_param(IS_DAC_CHANNEL(Channel));
-
 
495
 
-
 
496
  /* Disable the selected DAC channel DMA request */
-
 
497
  hdac->Instance->CR &= ~(DAC_CR_DMAEN1 << Channel);
-
 
498
   
-
 
499
  /* Disable the Peripharal */
-
 
500
  __HAL_DAC_DISABLE(hdac, Channel);
-
 
501
 
-
 
502
  /* Disable the DMA Channel */
-
 
503
  /* Channel1 is used */
-
 
504
  if(Channel == DAC_CHANNEL_1)
-
 
505
  {
-
 
506
    /* Disable the DMA channel */
-
 
507
    status = HAL_DMA_Abort(hdac->DMA_Handle1);
-
 
508
   
-
 
509
    /* Disable the DAC DMA underrun interrupt */
-
 
510
    __HAL_DAC_DISABLE_IT(hdac, DAC_IT_DMAUDR1);
-
 
511
  }
-
 
512
  else /* Channel2 is used for */
324
  tmp |= hdac->Instance->DOR1;
513
  {
-
 
514
    /* Disable the DMA channel */
-
 
515
    status = HAL_DMA_Abort(hdac->DMA_Handle2);
-
 
516
   
-
 
517
    /* Disable the DAC DMA underrun interrupt */
-
 
518
    __HAL_DAC_DISABLE_IT(hdac, DAC_IT_DMAUDR2);
-
 
519
  }
-
 
520
 
325
 
521
  /* Check if DMA Channel effectively disabled */
-
 
522
  if(status != HAL_OK)
-
 
523
  {
-
 
524
    /* Update ADC state machine to error */
-
 
525
    hdac->State = HAL_DAC_STATE_ERROR;      
-
 
526
  }
-
 
527
  else
-
 
528
  {
-
 
529
    /* Change DAC state */
-
 
530
    hdac->State = HAL_DAC_STATE_READY;
326
  tmp |= hdac->Instance->DOR2 << 16U;
531
  }
-
 
532
 
327
 
533
  /* Return function status */
328
  /* Returns the DAC channel data output register value */
534
  return status;
329
  return tmp;
535
}
330
}
536
#endif /* STM32F100xB) || defined (STM32F100xE) */
-
 
537
 
331
 
538
#if defined (STM32F100xB) || defined (STM32F100xE)
-
 
539
/**
332
/**
540
  * @brief  Handles DAC interrupt request
-
 
541
  *         Note: For STM32F100x devices with specific feature: DMA underrun.
-
 
542
  *         On these devices, this function uses the interruption of DMA
-
 
543
  *         underrun.
-
 
544
  * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
-
 
545
  *         the configuration information for the specified DAC.
-
 
546
  * @retval None
333
  * @}
547
  */
334
  */
548
void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac)
-
 
549
{
-
 
550
 
-
 
551
  if(__HAL_DAC_GET_IT_SOURCE(hdac, DAC_IT_DMAUDR1))
-
 
552
  {
-
 
553
    /* Check underrun flag of DAC channel 1 */
-
 
554
    if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR1))
-
 
555
    {
-
 
556
      /* Change DAC state to error state */
-
 
557
      hdac->State = HAL_DAC_STATE_ERROR;
-
 
558
     
-
 
559
      /* Set DAC error code to chanel1 DMA underrun error */
-
 
560
      SET_BIT(hdac->ErrorCode, HAL_DAC_ERROR_DMAUNDERRUNCH1);
-
 
561
     
-
 
562
      /* Clear the underrun flag */
-
 
563
      __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR1);
-
 
564
     
-
 
565
      /* Disable the selected DAC channel1 DMA request */
-
 
566
      CLEAR_BIT(hdac->Instance->CR, DAC_CR_DMAEN1);
-
 
567
     
-
 
568
      /* Error callback */
-
 
569
      HAL_DAC_DMAUnderrunCallbackCh1(hdac);
-
 
570
    }
-
 
571
  }
-
 
572
 
-
 
573
  if(__HAL_DAC_GET_IT_SOURCE(hdac, DAC_IT_DMAUDR2))
-
 
574
  {
-
 
575
    /* Check underrun flag of DAC channel 2 */
-
 
576
    if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR2))
-
 
577
    {
-
 
578
      /* Change DAC state to error state */
-
 
579
      hdac->State = HAL_DAC_STATE_ERROR;
-
 
580
     
-
 
581
      /* Set DAC error code to channel2 DMA underrun error */
-
 
582
      SET_BIT(hdac->ErrorCode, HAL_DAC_ERROR_DMAUNDERRUNCH2);
-
 
583
     
-
 
584
      /* Clear the underrun flag */
-
 
585
      __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR2);
-
 
586
     
-
 
587
      /* Disable the selected DAC channel1 DMA request */
-
 
588
      CLEAR_BIT(hdac->Instance->CR, DAC_CR_DMAEN2);
-
 
589
     
-
 
590
      /* Error callback */
-
 
591
      HAL_DACEx_DMAUnderrunCallbackCh2(hdac);
-
 
592
    }
-
 
593
  }
-
 
594
}
-
 
595
#endif /* STM32F100xB || STM32F100xE */
-
 
596
 
-
 
597
 
335
 
598
/**
336
/**
599
  * @}
337
  * @}
600
  */
338
  */
601
 
339
 
-
 
340
/* Private functions ---------------------------------------------------------*/
602
/** @defgroup DACEx_Private_Functions DACEx Private Functions
341
/** @defgroup DACEx_Private_Functions DACEx private functions
-
 
342
  *  @brief    Extended private functions
603
  * @{
343
   * @{
604
  */
344
  */
605
 
345
 
606
/**
346
/**
607
  * @brief  DMA conversion complete callback.
347
  * @brief  DMA conversion complete callback.
608
  * @param  hdma: pointer to a DMA_HandleTypeDef structure that contains
348
  * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
609
  *                the configuration information for the specified DMA module.
349
  *                the configuration information for the specified DMA module.
610
  * @retval None
350
  * @retval None
611
  */
351
  */
612
void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma)  
352
void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma)
613
{
353
{
614
  DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
354
  DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
615
 
355
 
-
 
356
#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
-
 
357
  hdac->ConvCpltCallbackCh2(hdac);
-
 
358
#else
616
  HAL_DACEx_ConvCpltCallbackCh2(hdac);
359
  HAL_DACEx_ConvCpltCallbackCh2(hdac);
-
 
360
#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
617
 
361
 
618
  hdac->State= HAL_DAC_STATE_READY;
362
  hdac->State = HAL_DAC_STATE_READY;
619
}
363
}
620
 
364
 
621
/**
365
/**
622
  * @brief  DMA half transfer complete callback.
366
  * @brief  DMA half transfer complete callback.
623
  * @param  hdma: pointer to a DMA_HandleTypeDef structure that contains
367
  * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
624
  *                the configuration information for the specified DMA module.
368
  *                the configuration information for the specified DMA module.
625
  * @retval None
369
  * @retval None
626
  */
370
  */
627
void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma)  
371
void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma)
628
{
372
{
629
    DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
373
  DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
630
    /* Conversion complete callback */
374
  /* Conversion complete callback */
-
 
375
#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
-
 
376
  hdac->ConvHalfCpltCallbackCh2(hdac);
-
 
377
#else
631
    HAL_DACEx_ConvHalfCpltCallbackCh2(hdac);
378
  HAL_DACEx_ConvHalfCpltCallbackCh2(hdac);
-
 
379
#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
632
}
380
}
633
 
381
 
634
/**
382
/**
635
  * @brief  DMA error callback
383
  * @brief  DMA error callback.
636
  * @param  hdma: pointer to a DMA_HandleTypeDef structure that contains
384
  * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
637
  *                the configuration information for the specified DMA module.
385
  *                the configuration information for the specified DMA module.
638
  * @retval None
386
  * @retval None
639
  */
387
  */
640
void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma)  
388
void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma)
641
{
389
{
642
  DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
390
  DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
643
   
391
 
644
  /* Set DAC error code to DMA error */
392
  /* Set DAC error code to DMA error */
645
  hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
393
  hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
-
 
394
 
-
 
395
#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
-
 
396
  hdac->ErrorCallbackCh2(hdac);
646
   
397
#else
647
  HAL_DACEx_ErrorCallbackCh2(hdac);
398
  HAL_DACEx_ErrorCallbackCh2(hdac);
-
 
399
#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
648
   
400
 
649
  hdac->State= HAL_DAC_STATE_READY;
401
  hdac->State = HAL_DAC_STATE_READY;
650
}
402
}
651
 
403
 
652
/**
404
/**
653
  * @}
405
  * @}
654
  */
406
  */
655
 
407
 
656
#endif /* STM32F100xB || STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
-
 
657
#endif /* HAL_DAC_MODULE_ENABLED */
-
 
658
 
-
 
659
/**
408
/**
660
  * @}
409
  * @}
661
  */
410
  */
662
 
411
 
-
 
412
#endif /* DAC */
-
 
413
 
-
 
414
#endif /* HAL_DAC_MODULE_ENABLED */
-
 
415
 
663
/**
416
/**
664
  * @}
417
  * @}
665
  */
418
  */
666
 
419
 
667
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
420
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/