]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/LPCOpen/lpc_core/lpc_ip/dac_001.h
Update LPC18xx FreeRTOS+UDP demo to use LPCOpen USB and Ethernet drivers.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / LPCOpen / lpc_core / lpc_ip / dac_001.h
1 /*\r
2  * @brief DAC Registers and control functions\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * All rights reserved.\r
7  *\r
8  * @par\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
22  *\r
23  * @par\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
29  * this code.\r
30  */\r
31 \r
32 #ifndef __DAC_001_H_\r
33 #define __DAC_001_H_\r
34 \r
35 #include "sys_config.h"\r
36 #include "cmsis.h"\r
37 \r
38 #ifdef __cplusplus\r
39 extern "C" {\r
40 #endif\r
41 \r
42 /** @defgroup IP_DAC_001 IP: DAC register block and driver\r
43  * @ingroup IP_Drivers\r
44  * @{\r
45  */\r
46 \r
47 /**\r
48  * @brief DAC register block structure\r
49  */\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
54 } IP_DAC_001_T;\r
55 \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
64  */\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
68 \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
77 \r
78 /**\r
79  * @brief Current option in DAC configuration option\r
80  */\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
87 \r
88 /**\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
93  * @return      Nothing\r
94  */\r
95 void IP_DAC_Init(IP_DAC_001_T *pDAC);\r
96 \r
97 /**\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
101  * @return      Nothing\r
102  */\r
103 void IP_DAC_UpdateValue (IP_DAC_001_T *pDAC, uint32_t dac_value);\r
104 \r
105 /**\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
109  *              - 0 is 1MHz\r
110  *              - 1 is 400kHz\r
111  * @return      Nothing\r
112  */\r
113 void IP_DAC_SetBias (IP_DAC_001_T *pDAC, uint32_t bias);\r
114 \r
115 /**\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
122  * @return      Nothing\r
123  * @note        Pass an Or'ed value of the DAC flags to enable those options.\r
124  */\r
125 STATIC INLINE void IP_DAC_ConfigDAConverterControl(IP_DAC_001_T *pDAC, uint32_t dacFlags)\r
126 {\r
127         uint32_t temp;\r
128 \r
129         temp = pDAC->CTRL & ~DAC_DACCTRL_MASK;\r
130         pDAC->CTRL = temp | dacFlags;\r
131 }\r
132 \r
133 /**\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
137  * @return      Nothing\r
138  */\r
139 void IP_DAC_SetDMATimeOut(IP_DAC_001_T *pDAC, uint32_t time_out);\r
140 \r
141 /**\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
145  */\r
146 IntStatus IP_DAC_GetIntStatus(IP_DAC_001_T *pDAC);\r
147 \r
148 /**\r
149  * @}\r
150  */\r
151 \r
152 #ifdef __cplusplus\r
153 }\r
154 #endif\r
155 \r
156 #endif /* __DAC_001_H_ */\r