?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik  
2 /*****************************************************************************
3 * FileName: mTouchCap_Adc.c
4 * Dependencies:
5 * Processor: PIC18, PIC24
6 * Compiler: C18, C30
7 * Linker: MPLINK,MPLAB LINK30
8 * Company: Microchip Technology Incorporated
9 *
10 * Software License Agreement
11 *
12 * Copyright © 2009 Microchip Technology Inc.
13 * Microchip licenses this software to you solely for use with Microchip products, according to the terms of the
14 * accompanying click-wrap software license. Microchip and its licensors retain all right, title and interest in
15 * and to the software. All rights reserved. This software and any accompanying information is for suggestion only.
16 * It shall not be deemed to modify Microchip’s standard warranty for its products. It is your responsibility to ensure
17 * that this software meets your requirements.
18  
19 * SOFTWARE IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
20 * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT
21 * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP OR ITS LICENSORS BE LIABLE
22 * FOR ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO INCIDENTAL,
23 * SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
24 * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, OR ANY CLAIMS BY THIRD PARTIES
25 * (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
26 * The aggregate and cumulative liability of Microchip and its licensors for damages related to the use of the software
27 * will in no event exceed $1000 or the amount you paid Microchip for the software, whichever is greater.
28  
29 * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS AND
30 * THE TERMS OF THE ACCOMPANYING CLICK-WRAP SOFTWARE LICENSE.
31 *
32 *
33 * Author Date Comment
34 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35 * Naveen. M 14 Apr 2009 Version 0.1 Initial Draft
36 * Sasha. M / Naveen. M 4 May 2009 Version 0.2 Updates
37 * Sasha. M / Naveen. M 11 Nov 2009 Version 1.0 Release
38 * Sasha. M / Nithin. 10 April 2010 Version 1.20 Release
39 *****************************************************************************/
40  
41 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
42 /* ~~~~~~~~~~~~~~~~~~~~~ Includes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
43 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
44  
45 #ifdef __PIC24F__
46 #include "mTouchCap_PIC24_CTMU_Physical.h"
47 #else
48 #include "mTouchCap_PIC18_CTMU_Physical.h"
49 #endif
50  
51 #include "mTouchCap_Adc.h"
52 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
53 /* ~~~~~~~~~~~~~~~~~~~~~ Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
54 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
55  
56  
57  
58 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
59 /* ~~~~~~~~~~~~~~~~~~~~~ Declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
60 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
61  
62  
63  
64 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
65 /* ~~~~~~~~~~~~~~~~~~~~~ Function Prototypes ~~~~~~~~~~~~~~~~~~~~~~~~~~ */
66 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
67  
68  
69  
70 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
71 /* ~~~~~~~~~~~~~~~~~~~~~ Function Definitions ~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
72 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
73  
74 /********************************************************************
75 * Function : void mTouchCapADC_SetChannelADC(WORD chan_param)
76 *
77 * PreCondition : None
78 *
79 * Input : channel_select - This contains the input select parameter to be
80 configured into the ADCHS register as defined below
81 *
82 * Output : None
83 *
84 * Side Effects : None
85 *
86 * Overview : This function sets the positive and negative inputs for
87 the sample multiplexers A and B.
88 *
89 * Note :
90 *******************************************************************/
91 void mTouchCapADC_SetChannelADC(WORD channel_select)
92 {
93 ADC_CHANNEL_SELECT = channel_select;
94 }
95  
96  
97  
98 /********* End of Function *********************/
99  
100  
101 /********************************************************************
102 * Function : WORD mTouchCapADC_ReadADCBuff(BYTE bufIndex)
103 *
104 * PreCondition : None
105 *
106 * Input : bufIndex - This is the ADC buffer number which is to be read.
107 *
108 * Output : Returns the contents of the ADC Buffer register (ADCBUF0 to ADCBUFF)
109 *
110 * Side Effects : None
111 *
112 * Overview : This function reads the ADC Buffer register which contains
113 * the conversion value.
114 *
115 * Note : User should provide bufIndex value between ‘0’ to ‘15’ to
116 ensure correct read of the ADCBUF0 to ADCBUFF.
117 *******************************************************************/
118  
119 WORD mTouchCapADC_ReadADCBuff(BYTE BufIndex)
120 {
121 #ifdef __PIC24F__
122 return(*(&ADCBUF+BufIndex));
123 #else
124 return(*(&ADRES+BufIndex)); //PIC18
125 #endif
126 }
127  
128  
129 /********* End of Function *********************/
130  
131 /********************************************************************
132 * Function : void mTouchCapADC_InitializeInterrupt(WORD config)
133 *
134 * PreCondition : None
135 *
136 * Input : config - ADC interrupt priority and enable/disable information
137 *
138 * Output : None
139 *
140 * Side Effects : None
141 *
142 * Overview : This function clears the Interrupt Flag (ADIF) bit and then
143 * sets the interrupt priority and enables/disables the interrupt.
144 *
145 * Note :
146 *******************************************************************/
147  
148  
149  
150 void mTouchCapADC_InitializeInterrupt(BYTE Interrupt_State)
151 {
152  
153 //************************************
154 //*Clearing the Interrupt Flag bit
155 //************************************/
156 ADC1_Clear_Intr_Status_Bit;
157  
158 //************************************
159 //*Setting Priority
160 //************************************/
161 SetPriorityIntADC1(ADC_PRIORITY);
162  
163 //************************************
164 //*Configure the Interrupt enable/disable bit
165 //************************************/
166 Set_Adc_Enable_State(Interrupt_State);
167  
168 }
169 /********* End of Function *********************/
170  
171  
172 /********************************************************************
173 * Function : BYTE mTouchCapADC_BusyADC(void)
174 *
175 * PreCondition : None
176 *
177 * Input : None
178 *
179 * Output : If the value of DONE is ‘0’, then ‘1’ is returned,indicating that the
180 * ADC is busy in conversion.If the value of DONE is ‘1’, then ‘0’ is
181 * returned, indicating that the ADC has completed conversion.
182 *
183 * Side Effects : None
184 *
185 * Overview : This function returns the complement of the ADCON1 <DONE> bit
186 * status which indicates whether the ADC is busy in conversion.
187 *
188 * Note :
189 *******************************************************************/
190  
191 BYTE mTouchCapADC_BusyADC(void)
192 {
193 return !(ADC_Done_Bit); /* returns the DONE bit status */
194 }
195  
196 /********* End of Function *********************/
197  
198  
199 /********************************************************************
200 * Function : void mTouchCapADC_CloseADC(void)
201 *
202 * PreCondition : None
203 *
204 * Input : None
205 *
206 * Output : None
207 *
208 * Side Effects : None
209 *
210 * Overview : This function first disables the ADC interrupt and then turns off the ADC
211 * module.The Interrupt Flag bit (ADIF) is also cleared.
212 *
213 * Note :
214 *******************************************************************/
215  
216 void mTouchCapADC_CloseADC(void)
217 {
218  
219 //************************************
220 //*disable ADC interrupt
221 //************************************/
222 DisableIntADC1;
223  
224  
225 //************************************
226 //*turn off ADC
227 //************************************/
228 DisableADC1;
229  
230  
231 //************************************
232 //*Clearing the Interrupt Flag bit
233 //************************************/
234 ADC1_Clear_Intr_Status_Bit;
235 }
236  
237 /********* End of Function *********************/
238  
239  
240 /********************************************************************
241 * Function : void mTouchCapADC_OpenADC(void)
242 *
243 * PreCondition : None
244 *
245 * Input : None
246 *
247 * Output : None
248 *
249 * Side Effects : None
250 *
251 * Overview : This function first disables the ADC interrupt and then turns off the ADC
252 * module.The Interrupt Flag bit (ADIF) is also cleared.
253 *
254 * Note :
255 *******************************************************************/
256 void mTouchCapADC_OpenADC(void)
257 {
258 //************************************
259 //*digital/analog mode selection on the port bits
260 //************************************/
261  
262 #ifdef __PIC24F__
263 #ifdef ADC_LEGACY
264 Adc_Port_Configuration(ADC_PORT_CONFIG_DEFAULT_VALUE); // A/D mux must connect to channel for CTMU to drain charge
265 #endif
266  
267 #ifdef ADC_NEW
268 Adc_PortA_Configuration(ADC_PORTA_CONFIG_DEFAULT_VALUE); // A/D mux must connect to channel for CTMU to drain charge
269 Adc_PortB_Configuration(ADC_PORTB_CONFIG_DEFAULT_VALUE); // A/D mux must connect to channel for CTMU to drain charge
270 Adc_PortC_Configuration(ADC_PORTC_CONFIG_DEFAULT_VALUE); // A/D mux must connect to channel for CTMU to drain charge
271 Adc_PortE_Configuration(ADC_PORTE_CONFIG_DEFAULT_VALUE); // A/D mux must connect to channel for CTMU to drain charge
272 Adc_PortG_Configuration(ADC_PORTG_CONFIG_DEFAULT_VALUE); // A/D mux must connect to channel for CTMU to drain charge
273 #endif
274 #else
275 AD_CON_REG0 = ADC_CONFIG_ADCON0;
276 AD_CON_REG1 = ADC_CONFIG_ADCON1;
277 Adc_Port_Configuration1(ADC_PORT_CONFIG_DEFAULT_VALUE); // A/D mux must connect to channel for CTMU to drain charge
278 Adc_Port_Configuration2(ADC_PORT_CONFIG_DEFAULT_VALUE); // A/D mux must connect to channel for CTMU to drain charge
279  
280  
281 #endif
282 }
283  
284 /********* End of Function *********************/
285  
286  
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3