亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? stm32l1xx_dac.c

?? STM32+Grlib
?? C
?? 第 1 頁 / 共 2 頁
字號:
/**
  ******************************************************************************
  * @file    stm32l1xx_dac.c
  * @author  MCD Application Team
  * @version V1.0.0
  * @date    31-December-2010
  * @brief   This file provides firmware functions to manage the following 
  *          functionalities of the Digital-to-Analog Converter (DAC) peripheral: 
  *           - DAC channels configuration: trigger, output buffer, data format
  *           - DMA management      
  *           - Interrupts and flags management
  *
  *  @verbatim
  *    
  *          ===================================================================
  *                             DAC Peripheral features
  *          ===================================================================
  *          The device integrates two 12-bit Digital Analog Converters that can 
  *          be used independently or simultaneously (dual mode):
  *            1- DAC channel1 with DAC_OUT1 (PA4) as output
  *            1- DAC channel2 with DAC_OUT2 (PA5) as output
  *
  *          Digital to Analog conversion can be non-triggered using DAC_Trigger_None
  *          and DAC_OUT1/DAC_OUT2 is available once writing to DHRx register using 
  *          DAC_SetChannel1Data()/DAC_SetChannel2Data.
  *   
  *         Digital to Analog conversion can be triggered by:
  *             1- External event: EXTI Line 9 (any GPIOx_Pin9) using DAC_Trigger_Ext_IT9.
  *                The used pin (GPIOx_Pin9) must be configured in input mode.
  *
  *             2- Timers TRGO: TIM2, TIM4, TIM6, TIM7 and TIM9 
  *                (DAC_Trigger_T2_TRGO, DAC_Trigger_T4_TRGO...)
  *                The timer TRGO event should be selected using TIM_SelectOutputTrigger()
  *
  *             3- Software using DAC_Trigger_Software
  *
  *          Each DAC channel integrates an output buffer that can be used to 
  *          reduce the output impedance, and to drive external loads directly
  *          without having to add an external operational amplifier.
  *          To enable, the output buffer use  
  *              DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
  *          
  *          Refer to the device datasheet for more details about output impedance
  *          value with and without output buffer.
  *
  *          Both DAC channels can be used to generate
  *             1- Noise wave using DAC_WaveGeneration_Noise
  *             2- Triangle wave using DAC_WaveGeneration_Triangle
  *        
  *          Wave generation can be disabled using DAC_WaveGeneration_None
  *
  *          The DAC data format can be:
  *             1- 8-bit right alignment using DAC_Align_8b_R
  *             2- 12-bit left alignment using DAC_Align_12b_L
  *             3- 12-bit right alignment using DAC_Align_12b_R
  *
  *          The analog output voltage on each DAC channel pin is determined
  *          by the following equation: DAC_OUTx = VREF+ * DOR / 4095
  *             with  DOR is the Data Output Register
  *                   VEF+ is the input voltage reference (refer to the device datasheet)
  *          e.g. To set DAC_OUT1 to 0.7V, use
  *            DAC_SetChannel1Data(DAC_Align_12b_R, 868);
  *          Assuming that VREF+ = 3.3, DAC_OUT1 = (3.3 * 868) / 4095 = 0.7V
  *
  *          A DMA1 request can be generated when an external trigger (but not
  *          a software trigger) occurs if DMA1 requests are enabled using
  *          DAC_DMACmd()
  *          DMA1 requests are mapped as following:
  *             1- DAC channel1 is mapped on DMA1 channel3 which must be already 
  *                configured
  *             2- DAC channel2 is mapped on DMA1 channel4 which must be already 
  *                configured
  *
  *          ===================================================================      
  *                              How to use this driver 
  *          ===================================================================          
  *            - DAC APB clock must be enabled to get write access to DAC
  *              registers using
  *              RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE)
  *            - Configure DAC_OUTx (DAC_OUT1: PA4, DAC_OUT2: PA5) in analog mode.
  *            - Configure the DAC channel using DAC_Init()
  *            - Enable the DAC channel using DAC_Cmd()
  * 
  *  @endverbatim
  *    
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
  ******************************************************************************  
  */ 

/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx_dac.h"
#include "stm32l1xx_rcc.h"

/** @addtogroup STM32L1xx_StdPeriph_Driver
  * @{
  */

/** @defgroup DAC 
  * @brief DAC driver modules
  * @{
  */ 

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* CR register Mask */
#define CR_CLEAR_MASK              ((uint32_t)0x00000FFE)

/* DAC Dual Channels SWTRIG masks */
#define DUAL_SWTRIG_SET            ((uint32_t)0x00000003)
#define DUAL_SWTRIG_RESET          ((uint32_t)0xFFFFFFFC)

/* DHR registers offsets */
#define DHR12R1_OFFSET             ((uint32_t)0x00000008)
#define DHR12R2_OFFSET             ((uint32_t)0x00000014)
#define DHR12RD_OFFSET             ((uint32_t)0x00000020)

/* DOR register offset */
#define DOR_OFFSET                 ((uint32_t)0x0000002C)

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/** @defgroup DAC_Private_Functions
  * @{
  */ 

/** @defgroup DAC_Group1 DAC channels configuration
 *  @brief   DAC channels configuration: trigger, output buffer, data format 
 *
@verbatim   
 ===============================================================================
          DAC channels configuration: trigger, output buffer, data format
 ===============================================================================  

@endverbatim
  * @{
  */

/**
  * @brief  Deinitializes the DAC peripheral registers to their default reset values.
  * @param  None
  * @retval None
  */
void DAC_DeInit(void)
{
  /* Enable DAC reset state */
  RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, ENABLE);
  /* Release DAC from reset state */
  RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, DISABLE);
}

/**
  * @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
  *     @arg DAC_Channel_2: DAC Channel2 selected
  * @param  DAC_InitStruct: pointer to a DAC_InitTypeDef structure that
  *         contains the configuration information for the specified DAC channel.
  *         DAC_Trigger selects the trigger source: EXTI Line 9, TIM2, TIM4....
  *         DAC_WaveGeneration selects the waveform to be generated: noise, triangle
  *         DAC_LFSRUnmask_TriangleAmplitude 
  *             defines the LFSR when noise waveform is selected by DAC_WaveGeneration
  *             or defines the amplitude of the triangle waveform when it is 
  *             selected by DAC_WaveGeneration
  *         DAC_OutputBuffer enables/disables the output buffer on DAC_OUTx
  * @retval None
  */
void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct)
{
  uint32_t tmpreg1 = 0, tmpreg2 = 0;

  /* Check the DAC parameters */
  assert_param(IS_DAC_TRIGGER(DAC_InitStruct->DAC_Trigger));
  assert_param(IS_DAC_GENERATE_WAVE(DAC_InitStruct->DAC_WaveGeneration));
  assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude));
  assert_param(IS_DAC_OUTPUT_BUFFER_STATE(DAC_InitStruct->DAC_OutputBuffer));

/*---------------------------- DAC CR Configuration --------------------------*/
  /* Get the DAC CR value */
  tmpreg1 = DAC->CR;
  /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */
  tmpreg1 &= ~(CR_CLEAR_MASK << DAC_Channel);
  /* Configure for the selected DAC channel: buffer output, trigger, wave generation,
     mask/amplitude for wave generation */
  /* Set TSELx and TENx bits according to DAC_Trigger value */
  /* Set WAVEx bits according to DAC_WaveGeneration value */
  /* Set MAMPx bits according to DAC_LFSRUnmask_TriangleAmplitude value */ 
  /* Set BOFFx bit according to DAC_OutputBuffer value */   
  tmpreg2 = (DAC_InitStruct->DAC_Trigger | DAC_InitStruct->DAC_WaveGeneration |
             DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude | DAC_InitStruct->DAC_OutputBuffer);
  /* Calculate CR register value depending on DAC_Channel */
  tmpreg1 |= tmpreg2 << DAC_Channel;
  /* Write to DAC CR */
  DAC->CR = tmpreg1;
}

/**
  * @brief  Fills each DAC_InitStruct member with its default value.
  * @param  DAC_InitStruct : pointer to a DAC_InitTypeDef structure which will 
  *         be initialized.
  * @retval None
  */
void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct)
{
/*--------------- Reset DAC init structure parameters values -----------------*/
  /* Initialize the DAC_Trigger member */
  DAC_InitStruct->DAC_Trigger = DAC_Trigger_None;
  /* Initialize the DAC_WaveGeneration member */
  DAC_InitStruct->DAC_WaveGeneration = DAC_WaveGeneration_None;
  /* Initialize the DAC_LFSRUnmask_TriangleAmplitude member */
  DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bit0;
  /* Initialize the DAC_OutputBuffer member */
  DAC_InitStruct->DAC_OutputBuffer = DAC_OutputBuffer_Enable;
}

/**
  * @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
  *     @arg DAC_Channel_2: DAC Channel2 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.
  * @retval None
  */
void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_DAC_CHANNEL(DAC_Channel));
  assert_param(IS_FUNCTIONAL_STATE(NewState));

  if (NewState != DISABLE)
  {
    /* Enable the selected DAC channel */
    DAC->CR |= (DAC_CR_EN1 << DAC_Channel);
  }
  else
  {
    /* Disable the selected DAC channel */
    DAC->CR &= (~(DAC_CR_EN1 << DAC_Channel));
  }
}

/**
  * @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
  *     @arg DAC_Channel_2: DAC Channel2 selected
  * @param  NewState: new state of the selected DAC channel software trigger.
  *   This parameter can be: ENABLE or DISABLE.
  * @retval None
  */
void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_DAC_CHANNEL(DAC_Channel));
  assert_param(IS_FUNCTIONAL_STATE(NewState));

  if (NewState != DISABLE)
  {
    /* Enable software trigger for the selected DAC channel */
    DAC->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4);
  }
  else
  {
    /* Disable software trigger for the selected DAC channel */
    DAC->SWTRIGR &= ~((uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4));
  }
}

/**
  * @brief  Enables or disables simultaneously the two DAC channels software
  *         triggers.
  * @param  NewState: new state of the DAC channels software triggers.
  *   This parameter can be: ENABLE or DISABLE.
  * @retval None
  */
void DAC_DualSoftwareTriggerCmd(FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_FUNCTIONAL_STATE(NewState));

  if (NewState != DISABLE)
  {
    /* Enable software trigger for both DAC channels */
    DAC->SWTRIGR |= DUAL_SWTRIG_SET;
  }
  else
  {
    /* Disable software trigger for both DAC channels */
    DAC->SWTRIGR &= DUAL_SWTRIG_RESET;
  }
}

/**
  * @brief  Enables or disables the selected DAC channel wave generation.
  * @param  DAC_Channel: the selected DAC channel. 
  *   This parameter can be one of the following values:
  *     @arg DAC_Channel_1: DAC Channel1 selected
  *     @arg DAC_Channel_2: DAC Channel2 selected
  * @param  DAC_Wave: Specifies the wave type to enable or disable.
  *   This parameter can be one of the following values:
  *     @arg DAC_Wave_Noise: noise wave generation
  *     @arg DAC_Wave_Triangle: triangle wave generation
  * @param  NewState: new state of the selected DAC channel wave generation.
  *   This parameter can be: ENABLE or DISABLE.
  * @note   
  * @retval None
  */
void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_DAC_CHANNEL(DAC_Channel));
  assert_param(IS_DAC_WAVE(DAC_Wave)); 
  assert_param(IS_FUNCTIONAL_STATE(NewState));

  if (NewState != DISABLE)
  {
    /* Enable the selected wave generation for the selected DAC channel */
    DAC->CR |= DAC_Wave << DAC_Channel;
  }
  else
  {
    /* Disable the selected wave generation for the selected DAC channel */
    DAC->CR &= ~(DAC_Wave << DAC_Channel);
  }
}

/**

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区三区视频在线| 免费欧美在线视频| 夜色激情一区二区| 秋霞午夜av一区二区三区| 国产一区二区免费看| av电影天堂一区二区在线| 欧日韩精品视频| 精品黑人一区二区三区久久| 中文字幕综合网| 免费欧美日韩国产三级电影| 岛国精品在线播放| 欧美人成免费网站| 国产精品久久毛片av大全日韩| 亚洲网友自拍偷拍| 国产激情精品久久久第一区二区| 99久久精品免费看国产免费软件| 在线播放一区二区三区| 国产精品久久久久影视| 奇米亚洲午夜久久精品| 久久成人av少妇免费| 在线一区二区三区| 国产区在线观看成人精品| 亚洲成人动漫在线免费观看| 99久久精品久久久久久清纯| 精品欧美一区二区三区精品久久| 一区二区三区欧美亚洲| av中文字幕亚洲| 久久只精品国产| 国产精品高清亚洲| 国产精品一区免费在线观看| 日韩三级在线免费观看| 亚洲成在人线在线播放| 国产成人8x视频一区二区| 在线不卡的av| 亚洲午夜久久久| 成人av在线看| 国产亚洲欧美色| 国产一区二区美女| 9191精品国产综合久久久久久| 久久久久久日产精品| 美女久久久精品| 91精品国产欧美一区二区18 | 欧美一激情一区二区三区| 综合久久久久久| 成人免费黄色在线| 久久久国产综合精品女国产盗摄| 九色porny丨国产精品| 91精品国产欧美一区二区18| 国内国产精品久久| 久久久影院官网| www.日韩大片| 日韩美女视频一区二区| 97se亚洲国产综合自在线不卡| 日韩国产高清在线| 91精品国产综合久久精品性色| 裸体在线国模精品偷拍| 欧美成人伊人久久综合网| 久久se精品一区精品二区| 国产区在线观看成人精品| 国产成人在线免费观看| 一区二区三区在线视频播放| 91久久精品网| 成人激情电影免费在线观看| 亚洲精品视频免费看| 在线免费一区三区| 一区二区三区久久久| 精品视频1区2区| 蜜芽一区二区三区| wwwwww.欧美系列| 91浏览器在线视频| 五月激情综合色| 日本一区二区三区电影| 色婷婷综合中文久久一本| 午夜天堂影视香蕉久久| 国产色一区二区| 在线视频欧美精品| 国产一区二区影院| 樱桃视频在线观看一区| 欧美日韩一区二区三区四区五区| 国产综合色产在线精品| 亚洲欧洲国产日韩| 精品国产91乱码一区二区三区 | 久草中文综合在线| 中文字幕中文在线不卡住| 欧美怡红院视频| 日韩国产一二三区| 中文字幕久久午夜不卡| 欧美日韩视频一区二区| aaa亚洲精品| 全部av―极品视觉盛宴亚洲| 成人一区二区三区中文字幕| 午夜精品一区在线观看| 日本一区二区三级电影在线观看| 一本久久综合亚洲鲁鲁五月天 | 国产精品一区二区三区四区| 亚洲乱码中文字幕| 精品福利视频一区二区三区| 一本大道久久a久久综合婷婷| 国内精品国产成人国产三级粉色| 一区二区三区中文免费| 国产精品久久久99| 精品国产一区二区三区不卡 | 成人app在线观看| 蓝色福利精品导航| 夜夜精品浪潮av一区二区三区| 欧美理论在线播放| 欧美日韩在线一区二区| 国产+成+人+亚洲欧洲自线| 国产精品系列在线播放| 日韩精品欧美精品| 国产精品乱码久久久久久| 国产网站一区二区| 欧美xxxx老人做受| 欧美成人r级一区二区三区| 欧美亚洲高清一区二区三区不卡| 91色视频在线| 91在线精品一区二区三区| 不卡在线视频中文字幕| 韩国女主播一区| 久久99国内精品| 国产精品综合视频| 久久精品国产一区二区三| 久久av资源站| 免费在线看成人av| 亚洲乱码国产乱码精品精可以看| 一区二区三区在线不卡| 中文字幕中文字幕在线一区 | 国产精品福利一区二区| 欧美一个色资源| 777精品伊人久久久久大香线蕉| 欧洲视频一区二区| 678五月天丁香亚洲综合网| 91麻豆精品国产91久久久久久久久| 欧美一区二区性放荡片| 91精品国产麻豆| 色综合色综合色综合色综合色综合| 在线这里只有精品| 日本道精品一区二区三区| 欧美人与禽zozo性伦| 欧美在线免费视屏| 欧美久久久久久久久久| 欧美成人vr18sexvr| 久久婷婷一区二区三区| 亚洲嫩草精品久久| 亚洲自拍偷拍网站| 国产在线一区观看| 成人一区二区在线观看| 欧美性色黄大片手机版| 欧美电影一区二区三区| 欧美色图一区二区三区| 欧美xxxxxxxxx| 国产三级久久久| 午夜国产精品一区| 九九视频精品免费| 色综合久久66| 欧美精品tushy高清| 国产精品乱码妇女bbbb| 一区二区三区美女视频| 亚洲高清一区二区三区| 日本成人在线视频网站| 国产精品一区二区91| 欧美三级日韩三级| 2022国产精品视频| 国产精品美女一区二区| 同产精品九九九| 久久精品噜噜噜成人av农村| 欧美肥大bbwbbw高潮| 日韩欧美国产三级电影视频| 日韩理论在线观看| 偷拍与自拍一区| 色综合久久88色综合天天免费| 欧美一区二区视频在线观看2020 | 欧美一区二区三区免费在线看| 精品欧美久久久| 伊人婷婷欧美激情| 国产夫妻精品视频| 91精品国产综合久久久久久| 亚洲日本在线看| 国产精品亚洲人在线观看| 国产成人在线观看| 亚洲精品一区二区在线观看| 亚洲综合无码一区二区| av一区二区三区| 日韩欧美卡一卡二| 亚洲男帅同性gay1069| 国产经典欧美精品| 在线日韩国产精品| 中文字幕av一区二区三区高| 日本欧美大码aⅴ在线播放| 欧美日韩你懂得| 亚洲柠檬福利资源导航| 99国产精品视频免费观看| 欧美不卡一区二区三区四区| 午夜欧美大尺度福利影院在线看| www.性欧美| 国产欧美在线观看一区| 国产99久久久国产精品免费看| 日韩免费看的电影| 美日韩一区二区| 91精品国产91久久久久久一区二区|