1 /*! 2 * \file adc.c 3 * 4 * \brief Generic ADC driver implementation 5 * 6 * \copyright Revised BSD License, see section \ref LICENSE. 7 * 8 * \code 9 * ______ _ 10 * / _____) _ | | 11 * ( (____ _____ ____ _| |_ _____ ____| |__ 12 * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 * _____) ) ____| | | || |_| ____( (___| | | | 14 * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 * (C)2013-2017 Semtech 16 * 17 * \endcode 18 * 19 * \author Miguel Luis ( Semtech ) 20 * 21 * \author Gregory Cristian ( Semtech ) 22 */ 23 #include <stdbool.h> 24 #include "adc-board.h" 25 26 /*! 27 * Flag to indicates if the ADC is initialized 28 */ 29 static bool AdcInitialized = false; 30 AdcInit(Adc_t * obj,PinNames adcInput)31void AdcInit( Adc_t *obj, PinNames adcInput ) 32 { 33 if( AdcInitialized == false ) 34 { 35 AdcInitialized = true; 36 37 AdcMcuInit( obj, adcInput ); 38 AdcMcuConfig( ); 39 } 40 } 41 AdcDeInit(Adc_t * obj)42void AdcDeInit( Adc_t *obj ) 43 { 44 AdcInitialized = false; 45 } 46 AdcReadChannel(Adc_t * obj,uint32_t channel)47uint16_t AdcReadChannel( Adc_t *obj, uint32_t channel ) 48 { 49 if( AdcInitialized == true ) 50 { 51 return AdcMcuReadChannel( obj, channel ); 52 } 53 else 54 { 55 return 0; 56 } 57 } 58