2 * @brief DAC Registers and control functions
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
32 #ifndef __DAC_001_H_
\r
33 #define __DAC_001_H_
\r
35 #include "sys_config.h"
\r
42 /** @defgroup IP_DAC_001 IP: DAC register block and driver
\r
43 * @ingroup IP_Drivers
\r
48 * @brief DAC register block structure
\r
50 typedef struct { /*!< DAC Structure */
\r
51 __IO uint32_t CR; /*!< DAC register. Holds the conversion data. */
\r
52 __IO uint32_t CTRL; /*!< DAC control register. */
\r
53 __IO uint32_t CNTVAL; /*!< DAC counter value register. */
\r
56 /** After the selected settling time after this field is written with a
\r
57 new VALUE, the voltage on the AOUT pin (with respect to VSSA)
\r
58 is VALUE/1024 � VREF */
\r
59 #define DAC_VALUE(n) ((uint32_t) ((n & 0x3FF) << 6))
\r
60 /** If this bit = 0: The settling time of the DAC is 1 microsecond max,
\r
61 * and the maximum current is 700 microAmpere
\r
62 * If this bit = 1: The settling time of the DAC is 2.5 microsecond
\r
63 * and the maximum current is 350 microAmpere
\r
65 #define DAC_BIAS_EN ((uint32_t) (1 << 16))
\r
66 /** Value to reload interrupt DMA counter */
\r
67 #define DAC_CCNT_VALUE(n) ((uint32_t) (n & 0xffff))
\r
69 /** DCAR double buffering */
\r
70 #define DAC_DBLBUF_ENA ((uint32_t) (1 << 1))
\r
71 /** DCAR Time out count enable */
\r
72 #define DAC_CNT_ENA ((uint32_t) (1 << 2))
\r
73 /** DCAR DMA access */
\r
74 #define DAC_DMA_ENA ((uint32_t) (1 << 3))
\r
75 /** DCAR DACCTRL mask bit */
\r
76 #define DAC_DACCTRL_MASK ((uint32_t) (0x0F))
\r
79 * @brief Current option in DAC configuration option
\r
81 typedef enum IP_DAC_CURRENT_OPT {
\r
82 DAC_MAX_UPDATE_RATE_1MHz = 0, /*!< Shorter settling times and higher power consumption;
\r
83 allows for a maximum update rate of 1 MHz */
\r
84 DAC_MAX_UPDATE_RATE_400kHz /*!< Longer settling times and lower power consumption;
\r
85 allows for a maximum update rate of 400 kHz */
\r
86 } IP_DAC_CURRENT_OPT_T;
\r
89 * @brief Initial DAC configuration
\r
90 * - Maximum update rate is 1MHz
\r
91 * - Value to AOUT is 0
\r
92 * @param pDAC : pointer to the DAC peripheral block
\r
95 void IP_DAC_Init(IP_DAC_001_T *pDAC);
\r
98 * @brief Update value to DAC buffer
\r
99 * @param pDAC : pointer to the DAC peripheral block
\r
100 * @param dac_value : value 10 bit to be converted to output
\r
103 void IP_DAC_UpdateValue (IP_DAC_001_T *pDAC, uint32_t dac_value);
\r
106 * @brief Set maximum update rate for DAC
\r
107 * @param pDAC : pointer to the DAC peripheral block
\r
108 * @param bias : Using Bias value, should be:
\r
113 void IP_DAC_SetBias (IP_DAC_001_T *pDAC, uint32_t bias);
\r
116 * @brief Enables the DMA operation and controls DMA timer
\r
117 * @param pDAC : pointer to the DAC peripheral block
\r
118 * @param dacFlags : An Or'ed value of the following DAC values:
\r
119 * - DAC_DBLBUF_ENA :enable/disable DACR double buffering feature
\r
120 * - DAC_CNT_ENA :enable/disable timer out counter
\r
121 * - DAC_DMA_ENA :enable/disable DMA access
\r
123 * @note Pass an Or'ed value of the DAC flags to enable those options.
\r
125 STATIC INLINE void IP_DAC_ConfigDAConverterControl(IP_DAC_001_T *pDAC, uint32_t dacFlags)
\r
129 temp = pDAC->CTRL & ~DAC_DACCTRL_MASK;
\r
130 pDAC->CTRL = temp | dacFlags;
\r
134 * @brief Set reload value for interrupt/DMA counter
\r
135 * @param pDAC : pointer to the DAC peripheral block
\r
136 * @param time_out : time out to reload for interrupt/DMA counter
\r
139 void IP_DAC_SetDMATimeOut(IP_DAC_001_T *pDAC, uint32_t time_out);
\r
142 * @brief Get status for interrupt/DMA time out
\r
143 * @param pDAC : pointer to the DAC peripheral block
\r
144 * @return interrupt/DMA time out status, should be SET or RESET
\r
146 IntStatus IP_DAC_GetIntStatus(IP_DAC_001_T *pDAC);
\r
156 #endif /* __DAC_001_H_ */
\r