⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm32f10x_dac.lst

📁 编译环境是 iar EWARM ,STM32 下的UCOSII
💻 LST
📖 第 1 页 / 共 2 页
字号:
##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32 KICKSTART     26/Dec/2008  18:23:37 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  thumb                                                #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  F:\PROJECT\STM32_UCOSII\CPU\ST\STM32\src\stm32f10x_d #
#                       ac.c                                                 #
#    Command line    =  F:\PROJECT\STM32_UCOSII\CPU\ST\STM32\src\stm32f10x_d #
#                       ac.c -lCN F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3 #
#                       210E-EVAL\IAR\OS-Probe\Flash\List\ -o                #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\Flash\Obj\ -z6 --no_unroll --no_inline  #
#                       --no_tbaa --no_scheduling --debug --cpu_mode thumb   #
#                       --endian little --cpu cortex-M3 --stack_align 4 -e   #
#                       --fpu None --dlib_config "E:\Program Files\IAR       #
#                       Systems\Embedded Workbench 4.0                       #
#                       Kickstart\arm\LIB\dl7mptnnl8n.h" -I                  #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\ -I F:\PROJECT\STM32_UCOSII\EvalBoards\ #
#                       ST\STM3210E-EVAL\IAR\OS-Probe\..\BSP\ -I             #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\CPU\ST\STM32\inc\ -I     #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-CPU\ -I               #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-CPU\ARM-Cortex-M3\IAR #
#                       \ -I F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E- #
#                       EVAL\IAR\OS-Probe\..\..\..\..\..\uC-LCD\Source\ -I   #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-LIB\ -I               #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uCOS-II\Ports\ARM-Cortex #
#                       -M3\Generic\IAR\ -I F:\PROJECT\STM32_UCOSII\EvalBoar #
#                       ds\ST\STM3210E-EVAL\IAR\OS-Probe\..\..\..\..\..\uCOS #
#                       -II\Source\ -I F:\PROJECT\STM32_UCOSII\EvalBoards\ST #
#                       \STM3210E-EVAL\IAR\OS-Probe\..\..\..\..\..\uC-Probe\ #
#                       Target\Communication\Generic\RS-232\Source\ -I       #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-Probe\Target\Communic #
#                       ation\Generic\RS-232\Ports\ST\STM32\ -I              #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-Probe\Target\Communic #
#                       ation\Generic\Source\ -I F:\PROJECT\STM32_UCOSII\Eva #
#                       lBoards\ST\STM3210E-EVAL\IAR\OS-Probe\..\..\..\..\.. #
#                       \uC-Probe\Target\Plugins\uCOS-II\ -I "E:\Program     #
#                       Files\IAR Systems\Embedded Workbench 4.0             #
#                       Kickstart\arm\INC\"                                  #
#    List file       =  F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\Flash\List\stm32f10x_dac.lst            #
#    Object file     =  F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\Flash\Obj\stm32f10x_dac.r79             #
#                                                                            #
#                                                                            #
##############################################################################

F:\PROJECT\STM32_UCOSII\CPU\ST\STM32\src\stm32f10x_dac.c
      1          /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
      2          * File Name          : stm32f10x_dac.c
      3          * Author             : MCD Application Team
      4          * Version            : V2.0
      5          * Date               : 05/23/2008
      6          * Description        : This file provides all the DAC firmware functions.
      7          ********************************************************************************
      8          * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
      9          * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
     10          * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
     11          * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
     12          * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
     13          * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
     14          * FOR MORE INFORMATION PLEASE CAREFULLY READ THE LICENSE AGREEMENT FILE LOCATED 
     15          * IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE.
     16          *******************************************************************************/
     17          
     18          /* Includes ------------------------------------------------------------------*/
     19          #include "stm32f10x_dac.h"
     20          #include "stm32f10x_rcc.h"
     21          
     22          /* Private typedef -----------------------------------------------------------*/
     23          /* Private define ------------------------------------------------------------*/
     24          /* DAC EN mask */
     25          #define CR_EN_Set                  ((u32)0x00000001)
     26          
     27          /* DAC DMAEN mask */
     28          #define CR_DMAEN_Set               ((u32)0x00001000)
     29          
     30          /* CR register Mask */
     31          #define CR_CLEAR_Mask              ((u32)0x00000FFE)
     32          
     33          /* DAC SWTRIG mask */
     34          #define SWTRIGR_SWTRIG_Set         ((u32)0x00000001)
     35          
     36          /* DAC Dual Channels SWTRIG masks */
     37          #define DUAL_SWTRIG_Set            ((u32)0x00000003)
     38          #define DUAL_SWTRIG_Reset          ((u32)0xFFFFFFFC)
     39          
     40          /* DHR registers offsets */
     41          #define DHR12R1_Offset             ((u32)0x00000008)
     42          #define DHR12R2_Offset             ((u32)0x00000014)
     43          #define DHR12RD_Offset             ((u32)0x00000020)
     44          
     45          /* DOR register offset */
     46          #define DOR_Offset                 ((u32)0x0000002C)
     47          
     48          /* Private macro -------------------------------------------------------------*/
     49          /* Private variables ---------------------------------------------------------*/
     50          /* Private function prototypes -----------------------------------------------*/
     51          /* Private functions ---------------------------------------------------------*/
     52          
     53          /*******************************************************************************
     54          * Function Name  : DAC_DeInit
     55          * Description    : Deinitializes the DAC peripheral registers to their default
     56          *                  reset values.
     57          * Input          : None.
     58          * Output         : None
     59          * Return         : None
     60          *******************************************************************************/
     61          void DAC_DeInit(void)
     62          {
     63            /* Enable DAC reset state */
     64            RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, ENABLE);
     65            /* Release DAC from reset state */
     66            RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, DISABLE);
     67          }
     68          
     69          /*******************************************************************************
     70          * Function Name  : DAC_Init
     71          * Description    : Initializes the DAC peripheral according to the specified 
     72          *                  parameters in the DAC_InitStruct.
     73          * Input          : - DAC_Channel: the selected DAC channel. 
     74          *                    This parameter can be one of the following values:
     75          *                       - DAC_Channel_1: DAC Channel1 selected
     76          *                       - DAC_Channel_2: DAC Channel2 selected
     77          *                  - DAC_InitStruct: pointer to a DAC_InitTypeDef structure that
     78          *                    contains the configuration information for the specified
     79          *                    DAC channel.
     80          * Output         : None
     81          * Return         : None
     82          *******************************************************************************/
     83          void DAC_Init(u32 DAC_Channel, DAC_InitTypeDef* DAC_InitStruct)
     84          {
     85            u32 tmpreg1 = 0, tmpreg2 = 0;
     86          
     87            /* Check the DAC parameters */
     88            assert_param(IS_DAC_TRIGGER(DAC_InitStruct->DAC_Trigger));
     89            assert_param(IS_DAC_GENERATE_WAVE(DAC_InitStruct->DAC_WaveGeneration));
     90            assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude));
     91            assert_param(IS_DAC_OUTPUT_BUFFER_STATE(DAC_InitStruct->DAC_OutputBuffer));
     92          
     93          /*---------------------------- DAC CR Configuration --------------------------*/
     94            /* Get the DAC CR value */
     95            tmpreg1 = DAC->CR;
     96            /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */
     97            tmpreg1 &= ~(CR_CLEAR_Mask << DAC_Channel);
     98            /* Configure for the selected DAC channel: buffer output, trigger, wave genration,
     99               mask/amplitude for wave genration */
    100            /* Set TSELx and TENx bits according to DAC_Trigger value */
    101            /* Set WAVEx bits according to DAC_WaveGeneration value */
    102            /* Set MAMPx bits according to DAC_LFSRUnmask_TriangleAmplitude value */ 
    103            /* Set BOFFx bit according to DAC_OutputBuffer value */   
    104            tmpreg2 = (DAC_InitStruct->DAC_Trigger | DAC_InitStruct->DAC_WaveGeneration |
    105                       DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude | DAC_InitStruct->DAC_OutputBuffer);
    106            /* Calculate CR register value depending on DAC_Channel */
    107            tmpreg1 |= tmpreg2 << DAC_Channel;
    108            /* Write to DAC CR */
    109            DAC->CR = tmpreg1;
    110          }
    111          
    112          /*******************************************************************************
    113          * Function Name  : DAC_StructInit
    114          * Description    : Fills each DAC_InitStruct member with its default value.
    115          * Input          : - DAC_InitStruct : pointer to a DAC_InitTypeDef structure
    116          *                    which will be initialized.
    117          * Output         : None
    118          * Return         : None
    119          *******************************************************************************/
    120          void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct)
    121          {
    122          /*--------------- Reset DAC init structure parameters values -----------------*/
    123            /* Initialize the DAC_Trigger member */
    124            DAC_InitStruct->DAC_Trigger = DAC_Trigger_None;
    125          
    126            /* Initialize the DAC_WaveGeneration member */
    127            DAC_InitStruct->DAC_WaveGeneration = DAC_WaveGeneration_None;
    128          
    129            /* Initialize the DAC_LFSRUnmask_TriangleAmplitude member */
    130            DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bit0;
    131          
    132            /* Initialize the DAC_OutputBuffer member */
    133            DAC_InitStruct->DAC_OutputBuffer = DAC_OutputBuffer_Enable;
    134          }
    135          
    136          /*******************************************************************************
    137          * Function Name  : DAC_Cmd
    138          * Description    : Enables or disables the specified DAC channel.
    139          * Input            - DAC_Channel: the selected DAC channel. 
    140          *                    This parameter can be one of the following values:
    141          *                       - DAC_Channel_1: DAC Channel1 selected
    142          *                       - DAC_Channel_2: DAC Channel2 selected
    143          *                  - NewState: new state of the DAC channel. 
    144          *                    This parameter can be: ENABLE or DISABLE.
    145          * Output         : None
    146          * Return         : None
    147          *******************************************************************************/
    148          void DAC_Cmd(u32 DAC_Channel, FunctionalState NewState)
    149          {
    150            /* Check the parameters */
    151            assert_param(IS_DAC_CHANNEL(DAC_Channel));
    152            assert_param(IS_FUNCTIONAL_STATE(NewState));
    153          
    154            if (NewState != DISABLE)
    155            {
    156              /* Enable the selected DAC channel */
    157              DAC->CR |= CR_EN_Set << DAC_Channel;
    158            }
    159            else
    160            {
    161              /* Disable the selected DAC channel */
    162              DAC->CR &= ~(CR_EN_Set << DAC_Channel);
    163            }
    164          }
    165          
    166          /*******************************************************************************
    167          * Function Name  : DAC_DMACmd
    168          * Description    : Enables or disables the specified DAC channel DMA request.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -