1 /*
2  *  Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
3  *
4  *  Redistribution and use in source and binary forms, with or without
5  *  modification, are permitted provided that the following conditions
6  *  are met:
7  *
8  *    Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *
11  *    Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the
14  *    distribution.
15  *
16  *    Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 //*****************************************************************************
34 //
35 //  adc.c
36 //
37 //  Driver for the ADC module.
38 //
39 //*****************************************************************************
40 
41 //*****************************************************************************
42 //
43 //! \addtogroup ADC_Analog_to_Digital_Converter_api
44 //! @{
45 //
46 //*****************************************************************************
47 #include "inc/hw_types.h"
48 #include "inc/hw_memmap.h"
49 #include "inc/hw_ints.h"
50 #include "inc/hw_adc.h"
51 #include "inc/hw_apps_config.h"
52 #include "interrupt.h"
53 #include "adc.h"
54 
55 
56 //*****************************************************************************
57 //
58 //! Enables the ADC
59 //!
60 //! \param ulBase is the base address of the ADC
61 //!
62 //! This function sets the ADC global enable
63 //!
64 //! \return None.
65 //
66 //*****************************************************************************
ADCEnable(unsigned long ulBase)67 void ADCEnable(unsigned long ulBase)
68 {
69   //
70   // Set the global enable bit in the control register.
71   //
72   HWREG(ulBase + ADC_O_ADC_CTRL) |= 0x1;
73 }
74 
75 //*****************************************************************************
76 //
77 //! Disable the ADC
78 //!
79 //! \param ulBase is the base address of the ADC
80 //!
81 //! This function clears the ADC global enable
82 //!
83 //! \return None.
84 //
85 //*****************************************************************************
ADCDisable(unsigned long ulBase)86 void ADCDisable(unsigned long ulBase)
87 {
88   //
89   // Clear the global enable bit in the control register.
90   //
91   HWREG(ulBase + ADC_O_ADC_CTRL) &= ~0x1 ;
92 }
93 
94 //*****************************************************************************
95 //
96 //! Enables specified ADC channel
97 //!
98 //! \param ulBase is the base address of the ADC
99 //! \param ulChannel is one of the valid ADC channels
100 //!
101 //! This function enables specified ADC channel and configures the
102 //! pin as analog pin.
103 //!
104 //! \return None.
105 //
106 //*****************************************************************************
ADCChannelEnable(unsigned long ulBase,unsigned long ulChannel)107 void ADCChannelEnable(unsigned long ulBase, unsigned long ulChannel)
108 {
109   unsigned long ulCh;
110 
111   ulCh =  (ulChannel == ADC_CH_0)? 0x02 :
112           (ulChannel == ADC_CH_1)? 0x04 :
113           (ulChannel == ADC_CH_2)? 0x08 : 0x10;
114 
115   HWREG(ulBase + ADC_O_ADC_CH_ENABLE) |= ulCh;
116 }
117 
118 //*****************************************************************************
119 //
120 //! Disables specified ADC channel
121 //!
122 //! \param ulBase is the base address of the ADC
123 //! \param ulChannel is one of the valid ADC channelsber
124 //!
125 //! This function disables specified ADC channel.
126 //!
127 //! \return None.
128 //
129 //*****************************************************************************
ADCChannelDisable(unsigned long ulBase,unsigned long ulChannel)130 void ADCChannelDisable(unsigned long ulBase, unsigned long ulChannel)
131 {
132   unsigned long ulCh;
133 
134   ulCh =  (ulChannel == ADC_CH_0)? 0x02 :
135           (ulChannel == ADC_CH_1)? 0x04 :
136           (ulChannel == ADC_CH_2)? 0x08 : 0x10;
137 
138   HWREG(ulBase + ADC_O_ADC_CH_ENABLE) &= ~ulCh;
139 }
140 
141 //*****************************************************************************
142 //
143 //! Enables and registers ADC interrupt handler for specified channel
144 //!
145 //! \param ulBase is the base address of the ADC
146 //! \param ulChannel is one of the valid ADC channels
147 //! \param pfnHandler is a pointer to the function to be called when the
148 //! ADC channel interrupt occurs.
149 //!
150 //! This function enables and registers ADC interrupt handler for specified
151 //! channel. Individual interrupt for each channel should be enabled using
152 //! \sa ADCIntEnable(). It is the interrupt handler's responsibility to clear
153 //! the interrupt source.
154 //!
155 //! The parameter \e ulChannel should be one of the following
156 //!
157 //! - \b ADC_CH_0 for channel 0
158 //! - \b ADC_CH_1 for channel 1
159 //! - \b ADC_CH_2 for channel 2
160 //! - \b ADC_CH_3 for channel 3
161 //!
162 //! \return None.
163 //
164 //*****************************************************************************
ADCIntRegister(unsigned long ulBase,unsigned long ulChannel,void (* pfnHandler)(void))165 void ADCIntRegister(unsigned long ulBase, unsigned long ulChannel,
166                     void (*pfnHandler)(void))
167 {
168   unsigned long ulIntNo;
169 
170   //
171   // Get the interrupt number associted with the specified channel
172   //
173   ulIntNo = (ulChannel == ADC_CH_0)? INT_ADCCH0 :
174             (ulChannel == ADC_CH_1)? INT_ADCCH1 :
175             (ulChannel == ADC_CH_2)? INT_ADCCH2 : INT_ADCCH3;
176 
177   //
178   // Register the interrupt handler
179   //
180   IntRegister(ulIntNo,pfnHandler);
181 
182   //
183   // Enable ADC interrupt
184   //
185   IntEnable(ulIntNo);
186 }
187 
188 
189 //*****************************************************************************
190 //
191 //! Disables and unregisters ADC interrupt handler for specified channel
192 //!
193 //! \param ulBase is the base address of the ADC
194 //! \param ulChannel is one of the valid ADC channels
195 //!
196 //! This function disables and unregisters ADC interrupt handler for specified
197 //! channel. This function also masks off the interrupt in the interrupt
198 //! controller so that the interrupt handler no longer is called.
199 //!
200 //! The parameter \e ulChannel should be one of the following
201 //!
202 //! - \b ADC_CH_0 for channel 0
203 //! - \b ADC_CH_1 for channel 1
204 //! - \b ADC_CH_2 for channel 2
205 //! - \b ADC_CH_3 for channel 3
206 //!
207 //! \return None.
208 //
209 //*****************************************************************************
ADCIntUnregister(unsigned long ulBase,unsigned long ulChannel)210 void ADCIntUnregister(unsigned long ulBase, unsigned long ulChannel)
211 {
212   unsigned long ulIntNo;
213 
214   //
215   // Get the interrupt number associted with the specified channel
216   //
217   ulIntNo = (ulChannel == ADC_CH_0)? INT_ADCCH0 :
218             (ulChannel == ADC_CH_1)? INT_ADCCH1 :
219             (ulChannel == ADC_CH_2)? INT_ADCCH2 : INT_ADCCH3;
220 
221   //
222   // Disable ADC interrupt
223   //
224   IntDisable(ulIntNo);
225 
226   //
227   // Unregister the interrupt handler
228   //
229   IntUnregister(ulIntNo);
230 }
231 
232 //*****************************************************************************
233 //
234 //! Enables individual interrupt sources for specified channel
235 //!
236 //!
237 //! \param ulBase is the base address of the ADC
238 //! \param ulChannel is one of the valid ADC channels
239 //! \param ulIntFlags is the bit mask of the interrupt sources to be enabled.
240 //!
241 //! This function enables the indicated ADC interrupt sources.  Only the
242 //! sources that are enabled can be reflected to the processor interrupt;
243 //! disabled sources have no effect on the processor.
244 //!
245 //! The parameter \e ulChannel should be one of the following
246 //!
247 //! - \b ADC_CH_0 for channel 0
248 //! - \b ADC_CH_1 for channel 1
249 //! - \b ADC_CH_2 for channel 2
250 //! - \b ADC_CH_3 for channel 3
251 //!
252 //! The \e ulIntFlags parameter is the logical OR of any of the following:
253 //! - \b ADC_DMA_DONE for DMA done
254 //! - \b ADC_FIFO_OVERFLOW for FIFO over flow
255 //! - \b ADC_FIFO_UNDERFLOW for FIFO under flow
256 //! - \b ADC_FIFO_EMPTY for FIFO empty
257 //! - \b ADC_FIFO_FULL for FIFO full
258 //!
259 //! \return None.
260 //
261 //*****************************************************************************
ADCIntEnable(unsigned long ulBase,unsigned long ulChannel,unsigned long ulIntFlags)262 void ADCIntEnable(unsigned long ulBase, unsigned long ulChannel,
263                   unsigned long ulIntFlags)
264 {
265   unsigned long ulOffset;
266   unsigned long ulDmaMsk;
267 
268   //
269   // Enable DMA Done interrupt
270   //
271   if(ulIntFlags & ADC_DMA_DONE)
272   {
273      ulDmaMsk = (ulChannel == ADC_CH_0)?0x00001000:
274                 (ulChannel == ADC_CH_1)?0x00002000:
275                 (ulChannel == ADC_CH_2)?0x00004000:0x00008000;
276 
277      HWREG(APPS_CONFIG_BASE + APPS_CONFIG_O_DMA_DONE_INT_MASK_CLR) = ulDmaMsk;
278   }
279 
280   ulIntFlags = ulIntFlags &  0x0F;
281   //
282   // Get the interrupt enable register offset for specified channel
283   //
284   ulOffset = ADC_O_adc_ch0_irq_en + ulChannel;
285 
286   //
287   // Unmask the specified interrupts
288   //
289   HWREG(ulBase + ulOffset) |= (ulIntFlags & 0xf);
290 }
291 
292 
293 //*****************************************************************************
294 //
295 //! Disables individual interrupt sources for specified channel
296 //!
297 //!
298 //! \param ulBase is the base address of the ADC.
299 //! \param ulChannel is one of the valid ADC channels
300 //! \param ulIntFlags is the bit mask of the interrupt sources to be enabled.
301 //!
302 //! This function disables the indicated ADC interrupt sources.  Only the
303 //! sources that are enabled can be reflected to the processor interrupt;
304 //! disabled sources have no effect on the processor.
305 //!
306 //! The parameters\e ulIntFlags and \e ulChannel should be as explained in
307 //! ADCIntEnable().
308 //!
309 //! \return None.
310 //
311 //*****************************************************************************
ADCIntDisable(unsigned long ulBase,unsigned long ulChannel,unsigned long ulIntFlags)312 void ADCIntDisable(unsigned long ulBase, unsigned long ulChannel,
313                   unsigned long ulIntFlags)
314 {
315   unsigned long ulOffset;
316   unsigned long ulDmaMsk;
317 
318   //
319   // Disable DMA Done interrupt
320   //
321   if(ulIntFlags & ADC_DMA_DONE)
322   {
323      ulDmaMsk = (ulChannel == ADC_CH_0)?0x00001000:
324                 (ulChannel == ADC_CH_1)?0x00002000:
325                 (ulChannel == ADC_CH_2)?0x00004000:0x00008000;
326 
327      HWREG(APPS_CONFIG_BASE + APPS_CONFIG_O_DMA_DONE_INT_MASK_SET) = ulDmaMsk;
328   }
329 
330   //
331   // Get the interrupt enable register offset for specified channel
332   //
333   ulOffset = ADC_O_adc_ch0_irq_en + ulChannel;
334 
335   //
336   // Unmask the specified interrupts
337   //
338   HWREG(ulBase + ulOffset) &= ~ulIntFlags;
339 }
340 
341 
342 //*****************************************************************************
343 //
344 //! Gets the current channel interrupt status
345 //!
346 //! \param ulBase is the base address of the ADC
347 //! \param ulChannel is one of the valid ADC channels
348 //!
349 //! This function returns the interrupt status of the specified ADC channel.
350 //!
351 //! The parameter \e ulChannel should be as explained in \sa ADCIntEnable().
352 //!
353 //! \return Return the ADC channel interrupt status,  enumerated as a bit
354 //! field of values described in ADCIntEnable()
355 //
356 //*****************************************************************************
ADCIntStatus(unsigned long ulBase,unsigned long ulChannel)357 unsigned long ADCIntStatus(unsigned long ulBase, unsigned long ulChannel)
358 {
359   unsigned long ulOffset;
360   unsigned long ulDmaMsk;
361   unsigned long ulIntStatus;
362 
363   //
364   // Get DMA Done interrupt status
365   //
366   ulDmaMsk = (ulChannel == ADC_CH_0)?0x00001000:
367             (ulChannel == ADC_CH_1)?0x00002000:
368             (ulChannel == ADC_CH_2)?0x00004000:0x00008000;
369 
370   ulIntStatus = HWREG(APPS_CONFIG_BASE +
371                      APPS_CONFIG_O_DMA_DONE_INT_STS_MASKED)& ulDmaMsk;
372 
373 
374   //
375   // Get the interrupt enable register offset for specified channel
376   //
377   ulOffset = ADC_O_adc_ch0_irq_status + ulChannel;
378 
379   //
380   // Read ADC interrupt status
381   //
382   ulIntStatus |= HWREG(ulBase + ulOffset) & 0xf;
383 
384   //
385   // Return the current interrupt status
386   //
387   return(ulIntStatus);
388 }
389 
390 
391 //*****************************************************************************
392 //
393 //! Clears the current channel interrupt sources
394 //!
395 //! \param ulBase is the base address of the ADC
396 //! \param ulChannel is one of the valid ADC channels
397 //! \param ulIntFlags is the bit mask of the interrupt sources to be cleared.
398 //!
399 //! This function clears individual interrupt source for the specified
400 //! ADC channel.
401 //!
402 //! The parameter \e ulChannel should be as explained in \sa ADCIntEnable().
403 //!
404 //! \return None.
405 //
406 //*****************************************************************************
ADCIntClear(unsigned long ulBase,unsigned long ulChannel,unsigned long ulIntFlags)407 void ADCIntClear(unsigned long ulBase, unsigned long ulChannel,
408                   unsigned long ulIntFlags)
409 {
410   unsigned long ulOffset;
411   unsigned long ulDmaMsk;
412 
413   //
414   // Clear DMA Done interrupt
415   //
416   if(ulIntFlags & ADC_DMA_DONE)
417   {
418      ulDmaMsk = (ulChannel == ADC_CH_0)?0x00001000:
419                 (ulChannel == ADC_CH_1)?0x00002000:
420                 (ulChannel == ADC_CH_2)?0x00004000:0x00008000;
421 
422      HWREG(APPS_CONFIG_BASE + APPS_CONFIG_O_DMA_DONE_INT_ACK) = ulDmaMsk;
423   }
424 
425   //
426   // Get the interrupt enable register offset for specified channel
427   //
428   ulOffset = ADC_O_adc_ch0_irq_status + ulChannel;
429 
430   //
431   // Clear the specified interrupts
432   //
433   HWREG(ulBase + ulOffset) = (ulIntFlags & ~(ADC_DMA_DONE));
434 }
435 
436 //*****************************************************************************
437 //
438 //! Enables the ADC DMA operation for specified channel
439 //!
440 //! \param ulBase is the base address of the ADC
441 //! \param ulChannel is one of the valid ADC channels
442 //!
443 //! This function enables the DMA operation for specified ADC channel
444 //!
445 //! The parameter \e ulChannel should be one of the following
446 //!
447 //! - \b ADC_CH_0 for channel 0
448 //! - \b ADC_CH_1 for channel 1
449 //! - \b ADC_CH_2 for channel 2
450 //! - \b ADC_CH_3 for channel 3
451 //!
452 //! \return None.
453 //
454 //*****************************************************************************
ADCDMAEnable(unsigned long ulBase,unsigned long ulChannel)455 void ADCDMAEnable(unsigned long ulBase, unsigned long ulChannel)
456 {
457   unsigned long ulBitMask;
458 
459   //
460   // Get the bit mask for enabling DMA for specified channel
461   //
462   ulBitMask = (ulChannel == ADC_CH_0)?0x01:
463               (ulChannel == ADC_CH_1)?0x04:
464               (ulChannel == ADC_CH_2)?0x10:0x40;
465 
466   //
467   // Enable DMA request for the specified channel
468   //
469   HWREG(ulBase + ADC_O_adc_dma_mode_en) |= ulBitMask;
470 }
471 
472 //*****************************************************************************
473 //
474 //! Disables the ADC DMA operation for specified channel
475 //!
476 //! \param ulBase is the base address of the ADC
477 //! \param ulChannel is one of the valid ADC channels
478 //!
479 //! This function disables the DMA operation for specified ADC channel
480 //!
481 //! The parameter \e ulChannel should be one of the following
482 //!
483 //! - \b ADC_CH_0 for channel 0
484 //! - \b ADC_CH_1 for channel 1
485 //! - \b ADC_CH_2 for channel 2
486 //! - \b ADC_CH_3 for channel 3
487 //!
488 //! \return None.
489 //
490 //*****************************************************************************
ADCDMADisable(unsigned long ulBase,unsigned long ulChannel)491 void ADCDMADisable(unsigned long ulBase, unsigned long ulChannel)
492 {
493   unsigned long ulBitMask;
494 
495   //
496   // Get the bit mask for disabling DMA for specified channel
497   //
498   ulBitMask = (ulChannel == ADC_CH_0)?0x01:
499               (ulChannel == ADC_CH_1)?0x04:
500               (ulChannel == ADC_CH_2)?0x10:0x40;
501 
502   //
503   // Disable DMA request for the specified channel
504   //
505   HWREG(ulBase + ADC_O_adc_dma_mode_en) &= ~ulBitMask;
506 }
507 
508 //*****************************************************************************
509 //
510 //! Configures the ADC internal timer
511 //!
512 //! \param ulBase is the base address of the ADC
513 //! \param ulValue is wrap arround value of the timer
514 //!
515 //! This function Configures the ADC internal timer. The ADC timer is a 17 bit
516 //! used to timestamp the ADC data samples internally.
517 //! User can read the timestamp along with the sample from the FIFO register(s).
518 //! Each sample in the FIFO contains 14 bit actual data and 18 bit timestamp
519 //!
520 //! The parameter \e ulValue can take any value between 0 - 2^17
521 //!
522 //! \returns None.
523 //
524 //*****************************************************************************
ADCTimerConfig(unsigned long ulBase,unsigned long ulValue)525 void ADCTimerConfig(unsigned long ulBase, unsigned long ulValue)
526 {
527   unsigned long ulReg;
528 
529   //
530   // Read the currrent config
531   //
532   ulReg =  HWREG(ulBase + ADC_O_adc_timer_configuration);
533 
534   //
535   // Mask and set timer count field
536   //
537   ulReg = ((ulReg & ~0x1FFFF) | (ulValue & 0x1FFFF));
538 
539   //
540   // Set the timer count value
541   //
542   HWREG(ulBase + ADC_O_adc_timer_configuration) = ulReg;
543 }
544 
545 //*****************************************************************************
546 //
547 //! Resets ADC internal timer
548 //!
549 //! \param ulBase is the base address of the ADC
550 //!
551 //! This function resets 17-bit ADC internal timer
552 //!
553 //! \returns None.
554 //
555 //*****************************************************************************
ADCTimerReset(unsigned long ulBase)556 void ADCTimerReset(unsigned long ulBase)
557 {
558   //
559   // Reset the timer
560   //
561   HWREG(ulBase + ADC_O_adc_timer_configuration) |= (1 << 24);
562 }
563 
564 //*****************************************************************************
565 //
566 //! Enables ADC internal timer
567 //!
568 //! \param ulBase is the base address of the ADC
569 //!
570 //! This function enables 17-bit ADC internal timer
571 //!
572 //! \returns None.
573 //
574 //*****************************************************************************
ADCTimerEnable(unsigned long ulBase)575 void ADCTimerEnable(unsigned long ulBase)
576 {
577   //
578   // Enable the timer
579   //
580   HWREG(ulBase + ADC_O_adc_timer_configuration) |= (1 << 25);
581 }
582 
583 //*****************************************************************************
584 //
585 //! Disables ADC internal timer
586 //!
587 //! \param ulBase is the base address of the ADC
588 //!
589 //! This function disables 17-bit ADC internal timer
590 //!
591 //! \returns None.
592 //
593 //*****************************************************************************
ADCTimerDisable(unsigned long ulBase)594 void ADCTimerDisable(unsigned long ulBase)
595 {
596   //
597   // Disable the timer
598   //
599   HWREG(ulBase + ADC_O_adc_timer_configuration) &= ~(1 << 25);
600 }
601 
602 //*****************************************************************************
603 //
604 //! Gets the current value of ADC internal timer
605 //!
606 //! \param ulBase is the base address of the ADC
607 //!
608 //! This function the current value of 17-bit ADC internal timer
609 //!
610 //! \returns Return the current value of ADC internal timer.
611 //
612 //*****************************************************************************
ADCTimerValueGet(unsigned long ulBase)613 unsigned long ADCTimerValueGet(unsigned long ulBase)
614 {
615   return(HWREG(ulBase + ADC_O_adc_timer_current_count));
616 }
617 
618 //*****************************************************************************
619 //
620 //! Gets the current FIFO level for specified ADC channel
621 //!
622 //! \param ulBase is the base address of the ADC
623 //! \param ulChannel is one of the valid ADC channels.
624 //!
625 //! This function returns the current FIFO level for specified ADC channel.
626 //!
627 //! The parameter \e ulChannel should be one of the following
628 //!
629 //! - \b ADC_CH_0 for channel 0
630 //! - \b ADC_CH_1 for channel 1
631 //! - \b ADC_CH_2 for channel 2
632 //! - \b ADC_CH_3 for channel 3
633 //!
634 //! \returns Return the current FIFO level for specified channel
635 //
636 //*****************************************************************************
ADCFIFOLvlGet(unsigned long ulBase,unsigned long ulChannel)637 unsigned char ADCFIFOLvlGet(unsigned long ulBase, unsigned long ulChannel)
638 {
639   unsigned long ulOffset;
640 
641   //
642   // Get the fifo level register offset for specified channel
643   //
644   ulOffset = ADC_O_adc_ch0_fifo_lvl + ulChannel;
645 
646   //
647   // Return FIFO level
648   //
649   return(HWREG(ulBase + ulOffset) & 0x7);
650 }
651 
652 //*****************************************************************************
653 //
654 //! Reads FIFO for specified ADC channel
655 //!
656 //! \param ulBase is the base address of the ADC
657 //! \param ulChannel is one of the valid ADC channels.
658 //!
659 //! This function returns one data sample from the channel fifo as specified by
660 //! \e ulChannel parameter.
661 //!
662 //! The parameter \e ulChannel should be one of the following
663 //!
664 //! - \b ADC_CH_0 for channel 0
665 //! - \b ADC_CH_1 for channel 1
666 //! - \b ADC_CH_2 for channel 2
667 //! - \b ADC_CH_3 for channel 3
668 //!
669 //! \returns Return one data sample from the channel fifo.
670 //
671 //*****************************************************************************
ADCFIFORead(unsigned long ulBase,unsigned long ulChannel)672 unsigned long ADCFIFORead(unsigned long ulBase, unsigned long ulChannel)
673 {
674   unsigned long ulOffset;
675 
676   //
677   // Get the fifo register offset for specified channel
678   //
679   ulOffset = ADC_O_channel0FIFODATA + ulChannel;
680 
681   //
682   // Return FIFO level
683   //
684   return(HWREG(ulBase + ulOffset));
685 }
686 
687 
688 //*****************************************************************************
689 //
690 // Close the Doxygen group.
691 //! @}
692 //
693 //*****************************************************************************
694