|
|
|
@ -2,8 +2,8 @@ |
|
|
|
|
****************************************************************************** |
|
|
|
|
* @file stm32f0xx_dac.c |
|
|
|
|
* @author MCD Application Team |
|
|
|
|
* @version V1.0.0 |
|
|
|
|
* @date 23-March-2012 |
|
|
|
|
* @version V1.0.1 |
|
|
|
|
* @date 20-April-2012 |
|
|
|
|
* @brief This file provides firmware functions to manage the following
|
|
|
|
|
* functionalities of the Digital-to-Analog Converter (DAC) peripheral: |
|
|
|
|
* + DAC channel configuration: trigger, output buffer, data format |
|
|
|
@ -98,6 +98,7 @@ |
|
|
|
|
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/ |
|
|
|
|
#include "stm32f0xx_dac.h" |
|
|
|
|
#include "stm32f0xx_rcc.h" |
|
|
|
|
|
|
|
|
|
/** @addtogroup STM32F0xx_StdPeriph_Driver
|
|
|
|
|
* @{ |
|
|
|
@ -157,11 +158,10 @@ void DAC_DeInit(void) |
|
|
|
|
* @brief Initializes the DAC peripheral according to the specified
|
|
|
|
|
* parameters in the DAC_InitStruct. |
|
|
|
|
* @param DAC_Channel: the selected DAC channel.
|
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* @param DAC_InitStruct: pointer to a DAC_InitTypeDef structure that |
|
|
|
|
* contains the configuration information for the specified DAC channel. |
|
|
|
|
* |
|
|
|
|
* @retval None |
|
|
|
|
*/ |
|
|
|
|
void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct) |
|
|
|
@ -194,7 +194,7 @@ void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct) |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Fills each DAC_InitStruct member with its default value. |
|
|
|
|
* @param DAC_InitStruct : pointer to a DAC_InitTypeDef structure which will
|
|
|
|
|
* @param DAC_InitStruct: pointer to a DAC_InitTypeDef structure which will
|
|
|
|
|
* be initialized. |
|
|
|
|
* @retval None |
|
|
|
|
*/ |
|
|
|
@ -210,12 +210,11 @@ void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct) |
|
|
|
|
/**
|
|
|
|
|
* @brief Enables or disables the specified DAC channel. |
|
|
|
|
* @param DAC_Channel: The selected DAC channel.
|
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* @param NewState: new state of the DAC channel.
|
|
|
|
|
* This parameter can be: ENABLE or DISABLE. |
|
|
|
|
* @note When the DAC channel is enabled the trigger source can no more |
|
|
|
|
* be modified. |
|
|
|
|
* This parameter can be: ENABLE or DISABLE. |
|
|
|
|
* @note When the DAC channel is enabled the trigger source can no more be modified. |
|
|
|
|
* @retval None |
|
|
|
|
*/ |
|
|
|
|
void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState) |
|
|
|
@ -239,10 +238,10 @@ void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState) |
|
|
|
|
/**
|
|
|
|
|
* @brief Enables or disables the selected DAC channel software trigger. |
|
|
|
|
* @param DAC_Channel: the selected DAC channel.
|
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* @param NewState: new state of the selected DAC channel software trigger. |
|
|
|
|
* This parameter can be: ENABLE or DISABLE. |
|
|
|
|
* This parameter can be: ENABLE or DISABLE. |
|
|
|
|
* @retval None |
|
|
|
|
*/ |
|
|
|
|
void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState) |
|
|
|
@ -266,11 +265,11 @@ void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState) |
|
|
|
|
/**
|
|
|
|
|
* @brief Set the specified data holding register value for DAC channel1. |
|
|
|
|
* @param DAC_Align: Specifies the data alignment for DAC channel1. |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Align_8b_R: 8bit right data alignment selected |
|
|
|
|
* @arg DAC_Align_12b_L: 12bit left data alignment selected |
|
|
|
|
* @arg DAC_Align_12b_R: 12bit right data alignment selected |
|
|
|
|
* @param Data : Data to be loaded in the selected data holding register. |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Align_8b_R: 8bit right data alignment selected |
|
|
|
|
* @arg DAC_Align_12b_L: 12bit left data alignment selected |
|
|
|
|
* @arg DAC_Align_12b_R: 12bit right data alignment selected |
|
|
|
|
* @param Data: Data to be loaded in the selected data holding register. |
|
|
|
|
* @retval None |
|
|
|
|
*/ |
|
|
|
|
void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data) |
|
|
|
@ -291,8 +290,8 @@ void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data) |
|
|
|
|
/**
|
|
|
|
|
* @brief Returns the last data output value of the selected DAC channel. |
|
|
|
|
* @param DAC_Channel: the selected DAC channel.
|
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* @retval The selected DAC channel data output value. |
|
|
|
|
*/ |
|
|
|
|
uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel) |
|
|
|
@ -330,11 +329,11 @@ uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel) |
|
|
|
|
* When enabled DMA1 is generated when an external trigger (EXTI Line9, |
|
|
|
|
* TIM2, TIM3, TIM6 or TIM15 but not a software trigger) occurs |
|
|
|
|
* @param DAC_Channel: the selected DAC channel. |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* @param NewState: new state of the selected DAC channel DMA request. |
|
|
|
|
* This parameter can be: ENABLE or DISABLE. |
|
|
|
|
* The DAC channel1 is mapped on DMA1 channel3 which must be already configured.
|
|
|
|
|
* This parameter can be: ENABLE or DISABLE. |
|
|
|
|
* @note The DAC channel1 is mapped on DMA1 channel3 which must be already configured.
|
|
|
|
|
* @retval None |
|
|
|
|
*/ |
|
|
|
|
void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState) |
|
|
|
@ -374,15 +373,15 @@ void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState) |
|
|
|
|
/**
|
|
|
|
|
* @brief Enables or disables the specified DAC interrupts. |
|
|
|
|
* @param DAC_Channel: the selected DAC channel.
|
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* @param DAC_IT: specifies the DAC interrupt sources to be enabled or disabled.
|
|
|
|
|
* This parameter can be the following values: |
|
|
|
|
* @arg DAC_IT_DMAUDR: DMA underrun interrupt mask |
|
|
|
|
* @note The DMA underrun occurs when a second external trigger arrives before |
|
|
|
|
* the acknowledgement for the first external trigger is received (first request). |
|
|
|
|
* This parameter can be the following values: |
|
|
|
|
* @arg DAC_IT_DMAUDR: DMA underrun interrupt mask |
|
|
|
|
* @note The DMA underrun occurs when a second external trigger arrives before |
|
|
|
|
* the acknowledgement for the first external trigger is received (first request). |
|
|
|
|
* @param NewState: new state of the specified DAC interrupts. |
|
|
|
|
* This parameter can be: ENABLE or DISABLE. |
|
|
|
|
* This parameter can be: ENABLE or DISABLE. |
|
|
|
|
* @retval None |
|
|
|
|
*/
|
|
|
|
|
void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState)
|
|
|
|
@ -407,13 +406,13 @@ void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewStat |
|
|
|
|
/**
|
|
|
|
|
* @brief Checks whether the specified DAC flag is set or not. |
|
|
|
|
* @param DAC_Channel: thee selected DAC channel.
|
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* @param DAC_FLAG: specifies the flag to check.
|
|
|
|
|
* This parameter can be only of the following value: |
|
|
|
|
* @arg DAC_FLAG_DMAUDR: DMA underrun flag |
|
|
|
|
* @note The DMA underrun occurs when a second external trigger arrives before |
|
|
|
|
* the acknowledgement for the first external trigger is received (first request). |
|
|
|
|
* This parameter can be only of the following value: |
|
|
|
|
* @arg DAC_FLAG_DMAUDR: DMA underrun flag |
|
|
|
|
* @note The DMA underrun occurs when a second external trigger arrives before |
|
|
|
|
* the acknowledgement for the first external trigger is received (first request). |
|
|
|
|
* @retval The new state of DAC_FLAG (SET or RESET). |
|
|
|
|
*/ |
|
|
|
|
FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG) |
|
|
|
@ -442,11 +441,11 @@ FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG) |
|
|
|
|
/**
|
|
|
|
|
* @brief Clears the DAC channel's pending flags. |
|
|
|
|
* @param DAC_Channel: the selected DAC channel.
|
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* @param DAC_FLAG: specifies the flag to clear.
|
|
|
|
|
* This parameter can be of the following value: |
|
|
|
|
* @arg DAC_FLAG_DMAUDR: DMA underrun flag |
|
|
|
|
* This parameter can be of the following value: |
|
|
|
|
* @arg DAC_FLAG_DMAUDR: DMA underrun flag |
|
|
|
|
* @retval None |
|
|
|
|
*/ |
|
|
|
|
void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG) |
|
|
|
@ -462,13 +461,13 @@ void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG) |
|
|
|
|
/**
|
|
|
|
|
* @brief Checks whether the specified DAC interrupt has occurred or not. |
|
|
|
|
* @param DAC_Channel: the selected DAC channel.
|
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* @param DAC_IT: specifies the DAC interrupt source to check.
|
|
|
|
|
* This parameter can be the following values: |
|
|
|
|
* @arg DAC_IT_DMAUDR: DMA underrun interrupt mask |
|
|
|
|
* @note The DMA underrun occurs when a second external trigger arrives before |
|
|
|
|
* the acknowledgement for the first external trigger is received (first request). |
|
|
|
|
* This parameter can be the following values: |
|
|
|
|
* @arg DAC_IT_DMAUDR: DMA underrun interrupt mask |
|
|
|
|
* @note The DMA underrun occurs when a second external trigger arrives before |
|
|
|
|
* the acknowledgement for the first external trigger is received (first request). |
|
|
|
|
* @retval The new state of DAC_IT (SET or RESET). |
|
|
|
|
*/ |
|
|
|
|
ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT) |
|
|
|
@ -501,11 +500,11 @@ ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT) |
|
|
|
|
/**
|
|
|
|
|
* @brief Clears the DAC channel's interrupt pending bits. |
|
|
|
|
* @param DAC_Channel: the selected DAC channel.
|
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* This parameter can be one of the following values: |
|
|
|
|
* @arg DAC_Channel_1: DAC Channel1 selected |
|
|
|
|
* @param DAC_IT: specifies the DAC interrupt pending bit to clear. |
|
|
|
|
* This parameter can be the following values: |
|
|
|
|
* @arg DAC_IT_DMAUDR: DMA underrun interrupt mask |
|
|
|
|
* This parameter can be the following values: |
|
|
|
|
* @arg DAC_IT_DMAUDR: DMA underrun interrupt mask |
|
|
|
|
* @retval None |
|
|
|
|
*/ |
|
|
|
|
void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT) |
|
|
|
|