Index: firmware/App/Drivers/InternalADC.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -ra1daba982e3117ce45437384e770b50cfda7b7a7 --- firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision a1daba982e3117ce45437384e770b50cfda7b7a7) @@ -15,16 +15,23 @@ * ***************************************************************************/ -#include "adc.h" - +#include "adc.h" + +#include "CPLD.h" #include "InternalADC.h" +/** + * @addtogroup InternalADC + * @{ + */ + // ********** private definitions ********** -#define MAX_ADC_CHANNELS 24 // ADC supports up to 24 channels -#define SIZE_OF_ROLLING_AVG 16 // samples in rolling average calculations -#define ROLLING_AVG_SHIFT_DIVIDER 4 // rolling average shift divider - +#define MAX_ADC_CHANNELS 24 ///< ADC supports up to 24 channels. +#define SIZE_OF_ROLLING_AVG 16 ///< samples in rolling average calculations. +#define ROLLING_AVG_SHIFT_DIVIDER 4 ///< rolling average shift divider. + +/// Mapping from enumerated used ADC channel to processor channel ID. const INT_ADC_CHANNEL_T adcChannelNum2ChannelId[ MAX_ADC_CHANNELS ] = { INT_ADC_DIAL_IN_PUMP_SPEED, // 0 @@ -55,25 +62,22 @@ // ********** private data ********** -static adcData_t adcRawReadings[ NUM_OF_INT_ADC_CHANNELS ]; // buffer holds latest adc channel readings -static U32 adcRawReadingsCount = 0; // readings count for raw readings buffer +static adcData_t adcRawReadings[ NUM_OF_INT_ADC_CHANNELS ]; ///< Buffer holds latest adc channel readings. +static U32 adcRawReadingsCount = 0; ///< Readings count for raw readings buffer. -static U16 adcReadings[ NUM_OF_INT_ADC_CHANNELS ][ SIZE_OF_ROLLING_AVG ]; // holds samples for each channel for a rolling average -static U32 adcReadingsIdx[ NUM_OF_INT_ADC_CHANNELS ]; // index for next reading in each rolling average array -static U32 adcReadingsTotals[ NUM_OF_INT_ADC_CHANNELS ]; // rolling total for each channel - used to calc average -static U32 adcReadingsAvgs[ NUM_OF_INT_ADC_CHANNELS ]; // rolling average for each channel +static U16 adcReadings[ NUM_OF_INT_ADC_CHANNELS ][ SIZE_OF_ROLLING_AVG ]; ///< Holds samples for each channel for a rolling average. +static U32 adcReadingsIdx[ NUM_OF_INT_ADC_CHANNELS ]; ///< Index for next reading in each rolling average array. +static U32 adcReadingsTotals[ NUM_OF_INT_ADC_CHANNELS ]; ///< Rolling total for each channel - used to calc average. +static U32 adcReadingsAvgs[ NUM_OF_INT_ADC_CHANNELS ]; ///< Rolling average for each channel. // ********** private function prototypes ********** - - -/************************************************************************* - * @brief initInternalADC +/*********************************************************************//** + * @brief * The initInternalADC function initializes the InternalADC module. * @details * Inputs : none * Outputs : InternalADC module is initialized. - * @param none * @return none *************************************************************************/ void initInternalADC( void ) @@ -99,15 +103,15 @@ adcEnableNotification( adcREG1, adcGROUP1 ); } -/************************************************************************* - * @brief adcNotification - * The adcNotification function handles an ADC conversion complete interrupt. \n +/*********************************************************************//** + * @brief + * The adcNotification function handles an ADC conversion complete interrupt. * All channel readings in the FIFO are retrieved. * @details * Inputs : ADC FIFO * Outputs : adcRawReadingsCount, adcRawReadings[] - * @param adc : pointer to the ADC1 controller - * @param group : ADC channel group ID + * @param adc pointer to the ADC1 controller + * @param group ADC channel group ID * @return none *************************************************************************/ void adcNotification( adcBASE_t *adc, uint32 group ) @@ -118,15 +122,13 @@ } } -/************************************************************************* - * @brief execInternalADC - * The execInternalADC function processes the last set of raw ADC channel \n +/*********************************************************************//** + * @brief + * The execInternalADC function processes the last set of raw ADC channel * readings and kicks off the next conversion of ADC channels. * @details * Inputs : adcRawReadingsCount, adcRawReadings[] * Outputs : adcReadings[][], adcReadingsIdx[], adcReadingsTotals[], adcReadingsAvgs[] - * @param adc : pointer to the ADC1 controller - * @param group : ADC channel group ID * @return none *************************************************************************/ void execInternalADC( void ) @@ -149,21 +151,21 @@ } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_INT_ADC_DATA_OVERRUN, adcRawReadingsCount ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INT_ADC_DATA_OVERRUN, adcRawReadingsCount ) } // start an adc channel group conversion adcStartConversion( adcREG1, adcGROUP1 ); } -/************************************************************************* - * @brief getIntADCReading - * The getIntADCReading function gets the latest average reading for a given \n +/*********************************************************************//** + * @brief + * The getIntADCReading function gets the latest average reading for a given * channel. * @details * Inputs : adcReadingsAvgs[] * Outputs : none - * @param channel : adc channel to retrieve a reading for + * @param channel adc channel to retrieve a reading for * @return average reading for the given channel *************************************************************************/ U16 getIntADCReading( INT_ADC_CHANNEL_T channel ) @@ -176,9 +178,10 @@ } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_INT_ADC_INVALID_CHANNEL_REQUESTED, channel ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INT_ADC_INVALID_CHANNEL_REQUESTED, channel ) } return result; } +/**@}*/