1 /**********************************************************************
\r
2 * $Id$ lpc18xx_dac.h 2011-06-02
\r
4 * @file lpc18xx_dac.h
\r
5 * @brief Contains all macro definitions and function prototypes
\r
6 * support for DAC firmware library on LPC18xx
\r
8 * @date 02. June. 2011
\r
9 * @author NXP MCU SW Application Team
\r
11 * Copyright(C) 2011, NXP Semiconductor
\r
12 * All rights reserved.
\r
14 ***********************************************************************
\r
15 * Software that is described herein is for illustrative purposes only
\r
16 * which provides customers with programming information regarding the
\r
17 * products. This software is supplied "AS IS" without any warranties.
\r
18 * NXP Semiconductors assumes no responsibility or liability for the
\r
19 * use of the software, conveys no license or title under any patent,
\r
20 * copyright, or mask work right to the product. NXP Semiconductors
\r
21 * reserves the right to make changes in the software without
\r
22 * notification. NXP Semiconductors also make no representation or
\r
23 * warranty that such application will be suitable for the specified
\r
24 * use without further testing or modification.
\r
25 **********************************************************************/
\r
27 /* Peripheral group ----------------------------------------------------------- */
\r
28 /** @defgroup DAC DAC (Digital to Analog Converter)
\r
29 * @ingroup LPC1800CMSIS_FwLib_Drivers
\r
33 #ifndef LPC18XX_DAC_H_
\r
34 #define LPC18XX_DAC_H_
\r
36 /* Includes ------------------------------------------------------------------- */
\r
37 #include "LPC18xx.h"
\r
38 #include "lpc_types.h"
\r
46 /* Public Macros -------------------------------------------------------------- */
\r
47 /** @defgroup DAC_Private_Macros DAC Private Macros
\r
51 /** After the selected settling time after this field is written with a
\r
52 new VALUE, the voltage on the AOUT pin (with respect to VSSA)
\r
53 is VALUE/1024 × VREF */
\r
54 #define DAC_VALUE(n) ((uint32_t)((n&0x3FF)<<6))
\r
55 /** If this bit = 0: The settling time of the DAC is 1 microsecond max,
\r
56 * and the maximum current is 700 microAmpere
\r
57 * If this bit = 1: The settling time of the DAC is 2.5 microsecond
\r
58 * and the maximum current is 350 microAmpere */
\r
59 #define DAC_BIAS_EN ((uint32_t)(1<<16))
\r
60 /** Value to reload interrupt DMA counter */
\r
61 #define DAC_CCNT_VALUE(n) ((uint32_t)(n&0xffff))
\r
63 /** DCAR double buffering */
\r
64 #define DAC_DBLBUF_ENA ((uint32_t)(1<<1))
\r
65 /** DCAR Time out count enable */
\r
66 #define DAC_CNT_ENA ((uint32_t)(1<<2))
\r
67 /** DCAR DMA access */
\r
68 #define DAC_DMA_ENA ((uint32_t)(1<<3))
\r
69 /** DCAR DACCTRL mask bit */
\r
70 #define DAC_DACCTRL_MASK ((uint32_t)(0x0F))
\r
72 /** Macro to determine if it is valid DAC peripheral */
\r
73 #define PARAM_DACx(n) (((uint32_t *)n)==((uint32_t *)LPC_DAC))
\r
75 /** Macro to check DAC current optional parameter */
\r
76 #define PARAM_DAC_CURRENT_OPT(OPTION) ((OPTION == DAC_MAX_CURRENT_700uA)\
\r
77 ||(OPTION == DAC_MAX_CURRENT_350uA))
\r
82 /* Public Types --------------------------------------------------------------- */
\r
83 /** @defgroup DAC_Public_Types DAC Public Types
\r
88 * @brief Current option in DAC configuration option */
\r
91 DAC_MAX_CURRENT_700uA = 0, /*!< The settling time of the DAC is 1 us max,
\r
92 and the maximum current is 700 uA */
\r
93 DAC_MAX_CURRENT_350uA /*!< The settling time of the DAC is 2.5 us
\r
94 and the maximum current is 350 uA */
\r
98 * @brief Configuration for DAC converter control register */
\r
102 uint8_t DBLBUF_ENA; /**<
\r
103 -0: Disable DACR double buffering
\r
104 -1: when bit CNT_ENA, enable DACR double buffering feature
\r
106 uint8_t CNT_ENA; /*!<
\r
107 -0: Time out counter is disable
\r
108 -1: Time out conter is enable
\r
110 uint8_t DMA_ENA; /*!<
\r
111 -0: DMA access is disable
\r
112 -1: DMA burst request
\r
116 } DAC_CONVERTER_CFG_Type;
\r
122 /* Public Functions ----------------------------------------------------------- */
\r
123 /** @defgroup DAC_Public_Functions DAC Public Functions
\r
127 void DAC_Init(LPC_DAC_Type *DACx);
\r
128 void DAC_UpdateValue (LPC_DAC_Type *DACx, uint32_t dac_value);
\r
129 void DAC_SetBias (LPC_DAC_Type *DACx,uint32_t bias);
\r
130 void DAC_ConfigDAConverterControl (LPC_DAC_Type *DACx,DAC_CONVERTER_CFG_Type *DAC_ConverterConfigStruct);
\r
131 void DAC_SetDMATimeOut(LPC_DAC_Type *DACx,uint32_t time_out);
\r
142 #endif /* LPC18XX_DAC_H_ */
\r
148 /* --------------------------------- End Of File ------------------------------ */
\r