C:/nxpdrv/LPC1700CMSIS/Drivers/source/lpc17xx_dac.c
Go to the documentation of this file.00001 00020 /* Peripheral group ----------------------------------------------------------- */ 00025 /* Includes ------------------------------------------------------------------- */ 00026 #include "lpc17xx_dac.h" 00027 #include "lpc17xx_clkpwr.h" 00028 00029 /* If this source file built with example, the LPC17xx FW library configuration 00030 * file in each example directory ("lpc17xx_libcfg.h") must be included, 00031 * otherwise the default FW library configuration file must be included instead 00032 */ 00033 #ifdef __BUILD_WITH_EXAMPLE__ 00034 #include "lpc17xx_libcfg.h" 00035 #else 00036 #include "lpc17xx_libcfg_default.h" 00037 #endif /* __BUILD_WITH_EXAMPLE__ */ 00038 00039 00040 #ifdef _DAC 00041 00042 /* Public Functions ----------------------------------------------------------- */ 00047 /*********************************************************************/ 00054 void DAC_Init(LPC_DAC_TypeDef *DACx) 00055 { 00056 CHECK_PARAM(PARAM_DACx(DACx)); 00057 /* Set default clock divider for DAC */ 00058 // CLKPWR_SetPCLKDiv (CLKPWR_PCLKSEL_DAC, CLKPWR_PCLKSEL_CCLK_DIV_4); 00059 //Set maximum current output 00060 DAC_SetBias(LPC_DAC,DAC_MAX_CURRENT_700uA); 00061 00062 00063 } 00064 00065 /*********************************************************************/ 00071 void DAC_UpdateValue (LPC_DAC_TypeDef *DACx,uint32_t dac_value) 00072 { 00073 uint32_t tmp; 00074 CHECK_PARAM(PARAM_DACx(DACx)); 00075 tmp = DACx->DACR & DAC_BIAS_EN; 00076 tmp |= DAC_VALUE(dac_value); 00077 //DACx->DACR &= ~DAC_VALUE(0x3FF); 00078 //DACx->DACR |= DAC_VALUE(dac_value); 00079 // Update value 00080 DACx->DACR = tmp; 00081 } 00082 00083 /*********************************************************************/ 00090 void DAC_SetBias (LPC_DAC_TypeDef *DACx,uint32_t bias) 00091 { 00092 CHECK_PARAM(PARAM_DAC_CURRENT_OPT(bias)); 00093 DACx->DACR &=~DAC_BIAS_EN; 00094 if (bias == DAC_MAX_CURRENT_350uA) 00095 { 00096 DACx->DACR |= DAC_BIAS_EN; 00097 } 00098 } 00099 /*********************************************************************/ 00108 void DAC_ConfigDAConverterControl (LPC_DAC_TypeDef *DACx,DAC_CONVERTER_CFG_Type *DAC_ConverterConfigStruct) 00109 { 00110 CHECK_PARAM(PARAM_DACx(DACx)); 00111 DACx->DACCTRL &= ~DAC_DACCTRL_MASK; 00112 if (DAC_ConverterConfigStruct->DBLBUF_ENA) 00113 DACx->DACCTRL |= DAC_DBLBUF_ENA; 00114 if (DAC_ConverterConfigStruct->CNT_ENA) 00115 DACx->DACCTRL |= DAC_CNT_ENA; 00116 if (DAC_ConverterConfigStruct->DMA_ENA) 00117 DACx->DACCTRL |= DAC_DMA_ENA; 00118 } 00119 /*********************************************************************/ 00125 void DAC_SetDMATimeOut(LPC_DAC_TypeDef *DACx, uint32_t time_out) 00126 { 00127 CHECK_PARAM(PARAM_DACx(DACx)); 00128 DACx->DACCNTVAL = DAC_CCNT_VALUE(time_out); 00129 } 00130 00135 #endif /* _DAC */ 00136 00141 /* --------------------------------- End Of File ------------------------------ */
Generated on Mon Feb 8 10:01:37 2010 for LPC1700CMSIS Standard Peripheral Firmware Library by 1.5.9