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

📄 stm32f10x_dac.lst

📁 编译环境是 iar EWARM ,STM32 下的UCOSII
💻 LST
📖 第 1 页 / 共 2 页
字号:
    169          * Input            - DAC_Channel: the selected DAC channel. 
    170          *                    This parameter can be one of the following values:
    171          *                       - DAC_Channel_1: DAC Channel1 selected
    172          *                       - DAC_Channel_2: DAC Channel2 selected
    173          *                  - NewState: new state of the selected DAC channel DMA request.
    174          *                    This parameter can be: ENABLE or DISABLE.
    175          * Output         : None
    176          * Return         : None
    177          *******************************************************************************/
    178          void DAC_DMACmd(u32 DAC_Channel, FunctionalState NewState)
    179          {
    180            /* Check the parameters */
    181            assert_param(IS_DAC_CHANNEL(DAC_Channel));
    182            assert_param(IS_FUNCTIONAL_STATE(NewState));
    183          
    184            if (NewState != DISABLE)
    185            {
    186              /* Enable the selected DAC channel DMA request */
    187              DAC->CR |= CR_DMAEN_Set << DAC_Channel;
    188            }
    189            else
    190            {
    191              /* Disable the selected DAC channel DMA request */
    192              DAC->CR &= ~(CR_DMAEN_Set << DAC_Channel);
    193            }
    194          }
    195          
    196          /*******************************************************************************
    197          * Function Name  : DAC_SoftwareTriggerCmd
    198          * Description    : Enables or disables the selected DAC channel software trigger.
    199          * Input            - DAC_Channel: the selected DAC channel. 
    200          *                    This parameter can be one of the following values:
    201          *                       - DAC_Channel_1: DAC Channel1 selected
    202          *                       - DAC_Channel_2: DAC Channel2 selected
    203          *                  - NewState: new state of the selected DAC channel software trigger.
    204          *                    This parameter can be: ENABLE or DISABLE.
    205          * Output         : None
    206          * Return         : None
    207          *******************************************************************************/
    208          void DAC_SoftwareTriggerCmd(u32 DAC_Channel, FunctionalState NewState)
    209          {
    210            /* Check the parameters */
    211            assert_param(IS_DAC_CHANNEL(DAC_Channel));
    212            assert_param(IS_FUNCTIONAL_STATE(NewState));
    213          
    214            if (NewState != DISABLE)
    215            {
    216              /* Enable software trigger for the selected DAC channel */
    217              DAC->SWTRIGR |= SWTRIGR_SWTRIG_Set << (DAC_Channel >> 4);
    218            }
    219            else
    220            {
    221              /* Disable software trigger for the selected DAC channel */
    222              DAC->SWTRIGR &= ~(SWTRIGR_SWTRIG_Set << (DAC_Channel >> 4));
    223            }
    224          }
    225          
    226          /*******************************************************************************
    227          * Function Name  : DAC_DualSoftwareTriggerCmd
    228          * Description    : Enables or disables simultaneously the two DAC channels software
    229          *                  triggers.
    230          * Input            - NewState: new state of the DAC channels software triggers.
    231          *                    This parameter can be: ENABLE or DISABLE.
    232          * Output         : None
    233          * Return         : None
    234          *******************************************************************************/
    235          void DAC_DualSoftwareTriggerCmd(FunctionalState NewState)
    236          {
    237            /* Check the parameters */
    238            assert_param(IS_FUNCTIONAL_STATE(NewState));
    239          
    240            if (NewState != DISABLE)
    241            {
    242              /* Enable software trigger for both DAC channels */
    243              DAC->SWTRIGR |= DUAL_SWTRIG_Set ;
    244            }
    245            else
    246            {
    247              /* Disable software trigger for both DAC channels */
    248              DAC->SWTRIGR &= DUAL_SWTRIG_Reset;
    249            }
    250          }
    251          
    252          /*******************************************************************************
    253          * Function Name  : DAC_WaveGenerationCmd
    254          * Description    : Enables or disables the selected DAC channel wave generation.
    255          * Input            - DAC_Channel: the selected DAC channel. 
    256          *                    This parameter can be one of the following values:
    257          *                       - DAC_Channel_1: DAC Channel1 selected
    258          *                       - DAC_Channel_2: DAC Channel2 selected
    259          *                  - DAC_Wave: Specifies the wave type to enable or disable.
    260          *                    This parameter can be one of the following values:
    261          *                       - DAC_Wave_Noise: noise wave generation
    262          *                       - DAC_Wave_Triangle: triangle wave generation
    263          *                  - NewState: new state of the selected DAC channel wave generation.
    264          *                    This parameter can be: ENABLE or DISABLE.
    265          * Output         : None
    266          * Return         : None
    267          *******************************************************************************/
    268          void DAC_WaveGenerationCmd(u32 DAC_Channel, u32 DAC_Wave, FunctionalState NewState)
    269          {
    270            /* Check the parameters */
    271            assert_param(IS_DAC_CHANNEL(DAC_Channel));
    272            assert_param(IS_DAC_WAVE(DAC_Wave)); 
    273            assert_param(IS_FUNCTIONAL_STATE(NewState));
    274          
    275            if (NewState != DISABLE)
    276            {
    277              /* Enable the selected wave generation for the selected DAC channel */
    278              DAC->CR |= DAC_Wave << DAC_Channel;
    279            }
    280            else
    281            {
    282              /* Disable the selected wave generation for the selected DAC channel */
    283              DAC->CR &= ~(DAC_Wave << DAC_Channel);
    284            }
    285          }
    286          
    287          /*******************************************************************************
    288          * Function Name  : DAC_SetChannel1Data
    289          * Description    : Set the specified data holding register value for DAC channel1.
    290          * Input          : - DAC_Align: Specifies the data alignement for DAC channel1.
    291          *                    This parameter can be one of the following values:
    292          *                       - DAC_Align_8b_R: 8bit right data alignement selected
    293          *                       - DAC_Align_12b_L: 12bit left data alignement selected
    294          *                       - DAC_Align_12b_R: 12bit right data alignement selected
    295          *                  - Data : Data to be loaded in the selected data holding 
    296          *                    register.
    297          * Output         : None
    298          * Return         : None
    299          *******************************************************************************/
    300          void DAC_SetChannel1Data(u32 DAC_Align, u16 Data)
    301          {
    302            /* Check the parameters */
    303            assert_param(IS_DAC_ALIGN(DAC_Align));
    304            assert_param(IS_DAC_DATA(Data));
    305          
    306            /* Set the DAC channel1 selected data holding register */
    307            *((vu32 *)(DAC_BASE + DHR12R1_Offset + DAC_Align)) = (u32)Data;
    308          }
    309          
    310          /*******************************************************************************
    311          * Function Name  : DAC_SetChannel2Data
    312          * Description    : Set the specified data holding register value for DAC channel2.
    313          * Input          : - DAC_Align: Specifies the data alignement for DAC channel2.
    314          *                    This parameter can be one of the following values:
    315          *                       - DAC_Align_8b_R: 8bit right data alignement selected
    316          *                       - DAC_Align_12b_L: 12bit left data alignement selected
    317          *                       - DAC_Align_12b_R: 12bit right data alignement selected
    318          *                  - Data : Data to be loaded in the selected data holding 
    319          *                    register.
    320          * Output         : None
    321          * Return         : None
    322          *******************************************************************************/
    323          void DAC_SetChannel2Data(u32 DAC_Align, u16 Data)
    324          {
    325            /* Check the parameters */
    326            assert_param(IS_DAC_ALIGN(DAC_Align));
    327            assert_param(IS_DAC_DATA(Data));
    328          
    329            /* Set the DAC channel2 selected data holding register */
    330            *((vu32 *)(DAC_BASE + DHR12R2_Offset + DAC_Align)) = (u32)Data;
    331          }
    332          
    333          /*******************************************************************************
    334          * Function Name  : DAC_SetDualChannelData
    335          * Description    : Set the specified data holding register value for dual channel
    336          *                  DAC.
    337          * Input          : - DAC_Align: Specifies the data alignement for dual channel DAC.
    338          *                    This parameter can be one of the following values:
    339          *                       - DAC_Align_8b_R: 8bit right data alignement selected
    340          *                       - DAC_Align_12b_L: 12bit left data alignement selected
    341          *                       - DAC_Align_12b_R: 12bit right data alignement selected
    342          *                  - Data2: Data for DAC Channel2 to be loaded in the selected data 
    343          *                    holding register.
    344          *                  - Data1: Data for DAC Channel1 to be loaded in the selected data 
    345          *                    holding register.
    346          * Output         : None
    347          * Return         : None
    348          *******************************************************************************/
    349          void DAC_SetDualChannelData(u32 DAC_Align, u16 Data2, u16 Data1)
    350          {
    351            u32 Data = 0;
    352          
    353            /* Check the parameters */
    354            assert_param(IS_DAC_ALIGN(DAC_Align));
    355            assert_param(IS_DAC_DATA(Data1));
    356            assert_param(IS_DAC_DATA(Data2));
    357            
    358            /* Calculate and set dual DAC data holding register value */
    359            if (DAC_Align == DAC_Align_8b_R)
    360            {
    361              Data = ((u32)Data2 << 8) | Data1; 
    362            }
    363            else
    364            {
    365              Data = ((u32)Data2 << 16) | Data1;
    366            }
    367          
    368            /* Set the dual DAC selected data holding register */
    369            *((vu32 *)(DAC_BASE + DHR12RD_Offset + DAC_Align)) = Data;
    370          }
    371          
    372          /*******************************************************************************
    373          * Function Name  : DAC_GetDataOutputValue
    374          * Description    : Returns the last data output value of the selected DAC cahnnel.
    375          * Input            - DAC_Channel: the selected DAC channel. 
    376          *                    This parameter can be one of the following values:
    377          *                       - DAC_Channel_1: DAC Channel1 selected
    378          *                       - DAC_Channel_2: DAC Channel2 selected
    379          * Output         : None
    380          * Return         : The selected DAC channel data output value.
    381          *******************************************************************************/
    382          u16 DAC_GetDataOutputValue(u32 DAC_Channel)
    383          {
    384            /* Check the parameters */
    385            assert_param(IS_DAC_CHANNEL(DAC_Channel));
    386          
    387            /* Returns the DAC channel data output register value */
    388            return (u16) (*(vu32*)(DAC_BASE + DOR_Offset + ((u32)DAC_Channel >> 2)));
    389          }
    390          
    391          /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/

Errors: 11
Warnings: none

⌨️ 快捷键说明

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