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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 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);
  }
}

/**

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
丁香婷婷综合网| 美国欧美日韩国产在线播放| 国产一区在线不卡| 久久久九九九九| 国产精品资源在线观看| 中文字幕亚洲一区二区va在线| 91视频在线观看免费| 一区二区三区电影在线播| 欧美日韩一级片网站| 蓝色福利精品导航| 亚洲国产精品成人综合| 日本高清无吗v一区| 日韩国产高清影视| 国产欧美日韩综合| 91丨九色丨国产丨porny| 午夜久久久久久久久久一区二区| 日韩视频免费直播| 成人avav影音| 视频一区国产视频| 国产欧美日韩精品在线| 在线观看免费视频综合| 六月丁香婷婷久久| 国产精品电影一区二区三区| 91久久免费观看| 久久99久久99| 一区二区国产盗摄色噜噜| 欧美一二三在线| 91在线视频18| 精品在线视频一区| 亚洲精品成人在线| 久久综合一区二区| 欧美在线不卡一区| 国产精品亚洲一区二区三区在线 | 高清shemale亚洲人妖| 亚洲女与黑人做爰| 久久综合久久综合亚洲| 在线观看欧美日本| 国产99久久久国产精品潘金网站| 亚洲午夜在线观看视频在线| 国产亚洲婷婷免费| 欧美日韩电影一区| 91女人视频在线观看| 六月丁香综合在线视频| 亚洲国产视频一区| 中文字幕一区视频| 久久久久久久久久久久久女国产乱| 欧美午夜视频网站| gogo大胆日本视频一区| 国产一区二三区好的| 亚洲大型综合色站| 亚洲欧美日韩国产另类专区| 久久精品一区蜜桃臀影院| 欧美一区二区在线免费播放| 一本在线高清不卡dvd| 国产成人免费视频网站高清观看视频| 日韩影院精彩在线| 一区二区三区欧美| 亚洲欧美日韩成人高清在线一区| 久久久精品国产99久久精品芒果 | 日韩一级黄色大片| 欧美性大战久久久久久久蜜臀| 高清视频一区二区| 国产乱理伦片在线观看夜一区| 蜜臀久久99精品久久久久久9| 亚洲第一在线综合网站| 亚洲人成在线播放网站岛国| 中文无字幕一区二区三区| 欧美精品一区二区三区在线播放 | 欧美一区二区三区免费在线看| 色婷婷av一区二区三区软件| 成人性视频网站| 国产激情91久久精品导航| 久久精品国产**网站演员| 首页国产丝袜综合| 天堂成人国产精品一区| 爽好多水快深点欧美视频| 午夜激情综合网| 午夜精品久久久久久不卡8050| 亚洲成人精品一区二区| 亚洲最新在线观看| 亚洲国产cao| 日韩中文字幕区一区有砖一区| 午夜视频在线观看一区二区三区| 亚洲一区二区高清| 五月天亚洲婷婷| 毛片av一区二区| 韩国女主播一区二区三区| 国产一区二区三区精品欧美日韩一区二区三区 | 精品国产自在久精品国产| 精品国产91洋老外米糕| 国产丝袜在线精品| 自拍偷拍亚洲综合| 有码一区二区三区| 日韩电影在线免费| 国产伦精品一区二区三区在线观看| 国产精品系列在线播放| 99久久久无码国产精品| 欧美羞羞免费网站| 日韩一级欧美一级| 国产精品乱人伦| 亚洲国产欧美一区二区三区丁香婷| 日韩av高清在线观看| 精东粉嫩av免费一区二区三区| 粉嫩av亚洲一区二区图片| 色噜噜狠狠成人中文综合 | 欧美成人欧美edvon| 国产日韩亚洲欧美综合| 一区二区三区日韩在线观看| 日本中文一区二区三区| 国产成人亚洲综合a∨婷婷图片| 99国产精品99久久久久久| 欧美精品99久久久**| 久久婷婷久久一区二区三区| 亚洲三级视频在线观看| 免费看精品久久片| 成人毛片老司机大片| 欧美精品一级二级三级| 国产人成亚洲第一网站在线播放 | 精品国产99国产精品| 亚洲日本乱码在线观看| 麻豆一区二区99久久久久| av不卡免费电影| 欧美va亚洲va| 亚洲综合一二三区| 国产一区不卡视频| 欧美日韩国产123区| 欧美韩日一区二区三区四区| 亚洲v日本v欧美v久久精品| 国产成人久久精品77777最新版本| 欧美性大战久久| 国产精品视频yy9299一区| 视频一区在线播放| 91视频国产资源| 久久精品一二三| 美腿丝袜亚洲一区| 欧美色手机在线观看| 日本一区二区视频在线观看| 日韩精品久久理论片| 91黄色免费观看| 国产精品每日更新在线播放网址| 欧美aaa在线| 欧美色网站导航| 中文字幕一区二区视频| 国产精品99久| 精品成人免费观看| 日本成人在线看| 欧美美女一区二区在线观看| 亚洲欧美日韩系列| 成人一区二区三区中文字幕| 精品国产乱码久久久久久图片| 亚洲国产精品久久久久婷婷884 | 午夜精品视频一区| 在线观看视频一区二区欧美日韩| 国产精品人妖ts系列视频| 韩国欧美国产一区| 精品免费国产一区二区三区四区| 午夜欧美2019年伦理| 精品视频全国免费看| 亚洲免费视频成人| 色哟哟亚洲精品| 亚洲人成网站精品片在线观看| a在线欧美一区| 日韩美女精品在线| 91视频精品在这里| 亚洲精品乱码久久久久| 91激情五月电影| 亚洲一二三区在线观看| 欧美亚洲综合在线| 亚洲一区二区三区中文字幕| 欧日韩精品视频| 亚州成人在线电影| 这里只有精品电影| 久久精品久久99精品久久| 欧美成va人片在线观看| 国模娜娜一区二区三区| 国产日韩精品久久久| av欧美精品.com| 一区二区三区成人在线视频| 欧美日韩在线播| 免费亚洲电影在线| 精品国产99国产精品| 国产jizzjizz一区二区| 国产精品久久久久久久岛一牛影视| 成人av免费网站| 亚洲一卡二卡三卡四卡无卡久久| 欧美日韩一区二区三区高清| 日本不卡一区二区| 久久看人人爽人人| 91蝌蚪porny九色| 亚洲成人在线免费| 日韩女优制服丝袜电影| 国产v综合v亚洲欧| 夜夜操天天操亚洲| 日韩精品一区二区三区中文不卡| 国产精品一区二区久久不卡| 国产精品情趣视频| 欧美日韩中文字幕一区| 精品中文字幕一区二区小辣椒| 国产视频一区二区在线观看| 色婷婷av一区二区|