1 /** 2 ****************************************************************************** 3 * @file ft32f0xx_dac.c 4 * @author FMD AE 5 * @brief This file provides firmware functions to manage the following 6 * functionalities of DAC peripheral 7 * @version V1.0.0 8 * @data 2021-07-01 9 ****************************************************************************** 10 */ 11 /* Includes ------------------------------------------------------------------*/ 12 #include "ft32f0xx_dac.h" 13 14 /** 15 * 16 */ DAC_Ref_Config(uint32_t DAC_RefSel)17void DAC_Ref_Config(uint32_t DAC_RefSel) 18 { 19 uint32_t tmpreg = 0; 20 21 assert_param(IS_DAC_REF_SEL(DAC_RefSel)); 22 23 tmpreg = DAC->CTRL; 24 tmpreg &= ~DAC_CTRL_REF_SEL; 25 tmpreg |= DAC_RefSel; 26 27 DAC->CTRL |= tmpreg; 28 } 29 /** 30 * @Parame 31 */ DAC_Cmd(FunctionalState NewState)32void DAC_Cmd(FunctionalState NewState) 33 { 34 if(NewState != DISABLE) 35 { 36 DAC->CTRL |= DAC_CTRL_EN; 37 } 38 else 39 { 40 DAC->CTRL &= ~DAC_CTRL_EN; 41 } 42 } 43 44 45 /** 46 * @brief Set the specified data holding register value for DAC channel1. 47 * @param DAC_Align: no use. 48 * @param Data: Data to be loaded in the selected data DAC1DATA register. 7BIT 49 * @retval None 50 */ DAC_SetChannel1Data(uint32_t DAC_Align,uint8_t Data)51void DAC_SetChannel1Data(uint32_t DAC_Align, uint8_t Data) 52 { 53 /* Check the parameters */ 54 assert_param(IS_DAC_DATA(Data)); 55 56 DAC->DATA1 = (uint32_t)Data; 57 } 58 DAC_SetChannel2Data(uint32_t DAC_Align,uint8_t Data)59void DAC_SetChannel2Data(uint32_t DAC_Align, uint8_t Data) 60 { 61 /* Check the parameters */ 62 assert_param(IS_DAC_DATA(Data)); 63 64 DAC->DATA2 = (uint32_t)Data; 65 } 66 67 68 69 /** 70 * @Parame 71 * 72 */ DAC_Read_Reg(uint8_t DAC_Register)73uint8_t DAC_Read_Reg(uint8_t DAC_Register) 74 { 75 __IO uint32_t tmp = 0; 76 77 tmp = (uint32_t)DAC_BASE; 78 tmp += DAC_Register; 79 80 /* Return the selected register value */ 81 return (uint8_t)(*(__IO uint32_t *) tmp); 82 } 83