uc-sdk
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
lpc17xx_dac.c
Go to the documentation of this file.
1
20
/* Peripheral group ----------------------------------------------------------- */
25
/* Includes ------------------------------------------------------------------- */
26
#include "
lpc17xx_dac.h
"
27
#include "
lpc17xx_clkpwr.h
"
28
29
/* If this source file built with example, the LPC17xx FW library configuration
30
* file in each example directory ("lpc17xx_libcfg.h") must be included,
31
* otherwise the default FW library configuration file must be included instead
32
*/
33
#ifdef __BUILD_WITH_EXAMPLE__
34
#include "lpc17xx_libcfg.h"
35
#else
36
#include "
lpc17xx_libcfg_default.h
"
37
#endif
/* __BUILD_WITH_EXAMPLE__ */
38
39
40
#ifdef _DAC
41
42
/* Public Functions ----------------------------------------------------------- */
47
/*********************************************************************/
54
void
DAC_Init
(
LPC_DAC_TypeDef
*DACx)
55
{
56
CHECK_PARAM
(
PARAM_DACx
(DACx));
57
/* Set default clock divider for DAC */
58
// CLKPWR_SetPCLKDiv (CLKPWR_PCLKSEL_DAC, CLKPWR_PCLKSEL_CCLK_DIV_4);
59
//Set maximum current output
60
DAC_SetBias
(
LPC_DAC
,
DAC_MAX_CURRENT_700uA
);
61
}
62
63
/*********************************************************************/
69
void
DAC_UpdateValue
(
LPC_DAC_TypeDef
*DACx,uint32_t dac_value)
70
{
71
uint32_t tmp;
72
CHECK_PARAM
(
PARAM_DACx
(DACx));
73
tmp = DACx->
DACR
&
DAC_BIAS_EN
;
74
tmp |=
DAC_VALUE
(dac_value);
75
// Update value
76
DACx->
DACR
= tmp;
77
}
78
79
/*********************************************************************/
86
void
DAC_SetBias
(
LPC_DAC_TypeDef
*DACx,uint32_t bias)
87
{
88
CHECK_PARAM
(
PARAM_DAC_CURRENT_OPT
(bias));
89
DACx->
DACR
&=~
DAC_BIAS_EN
;
90
if
(bias ==
DAC_MAX_CURRENT_350uA
)
91
{
92
DACx->
DACR
|=
DAC_BIAS_EN
;
93
}
94
}
95
96
/*********************************************************************/
105
void
DAC_ConfigDAConverterControl
(
LPC_DAC_TypeDef
*DACx,
DAC_CONVERTER_CFG_Type
*DAC_ConverterConfigStruct)
106
{
107
CHECK_PARAM
(
PARAM_DACx
(DACx));
108
DACx->
DACCTRL
&= ~
DAC_DACCTRL_MASK
;
109
if
(DAC_ConverterConfigStruct->
DBLBUF_ENA
)
110
DACx->
DACCTRL
|=
DAC_DBLBUF_ENA
;
111
if
(DAC_ConverterConfigStruct->
CNT_ENA
)
112
DACx->
DACCTRL
|=
DAC_CNT_ENA
;
113
if
(DAC_ConverterConfigStruct->
DMA_ENA
)
114
DACx->
DACCTRL
|=
DAC_DMA_ENA
;
115
}
116
117
/*********************************************************************/
123
void
DAC_SetDMATimeOut
(
LPC_DAC_TypeDef
*DACx, uint32_t time_out)
124
{
125
CHECK_PARAM
(
PARAM_DACx
(DACx));
126
DACx->
DACCNTVAL
=
DAC_CCNT_VALUE
(time_out);
127
}
128
133
#endif
/* _DAC */
134
139
/* --------------------------------- End Of File ------------------------------ */
arch
arm
lpc17xx
Drivers
source
lpc17xx_dac.c
Generated on Fri Nov 15 2013 05:00:16 for uc-sdk by
1.8.4