Index: firmware/App/Drivers/InternalADC.c =================================================================== diff -u -ra49bd0780d97bb4ce04a9d7b128a6e3c2df044e1 -r0dec8744af40d0c87a6d7cd1923920c1c2bd1d2f --- firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision a49bd0780d97bb4ce04a9d7b128a6e3c2df044e1) +++ firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision 0dec8744af40d0c87a6d7cd1923920c1c2bd1d2f) @@ -1,29 +1,36 @@ -/**********************************************************************//** - * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN - * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * @file InternalADC.c - * - * @date 08-Nov-2019 - * @author S. Nash - * - * @brief Driver for the internal ADC peripheral. - * - **************************************************************************/ +/************************************************************************** +* +* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file InternalADC.c +* +* @author (last) Quang Nguyen +* @date (last) 21-Jul-2020 +* +* @author (original) Sean +* @date (original) 04-Feb-2020 +* +***************************************************************************/ #include "adc.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 ///< DG internal ADC supports up to 24 channels. +#define SIZE_OF_ROLLING_AVG 16 ///< Number of DG internal ADC samples in rolling average calculations for each channel. +#define ROLLING_AVG_SHIFT_DIVIDER 4 ///< Rolling average shift divider for DG internal ADC readings. +/// ADC channel # to ADC channel ID (enumeration) look-up table. const INT_ADC_CHANNEL_T adcChannelNum2ChannelId[ MAX_ADC_CHANNELS ] = { INT_ADC_RO_PUMP_INLET_PRESSURE, // 0 @@ -54,13 +61,13 @@ // ********** 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 ]; ///< buffer 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 buffer. +static U32 adcReadingsTotals[ NUM_OF_INT_ADC_CHANNELS ]; ///< rolling sum for each ADC channel - used to calc average. +static U32 adcReadingsAvgs[ NUM_OF_INT_ADC_CHANNELS ]; ///< rolling average for each ADC channel. // ********** private function prototypes ********** @@ -99,7 +106,7 @@ } /*********************************************************************//** - * @brief adcNotification + * @brief * The adcNotification function handles an ADC conversion complete interrupt. \n * All channel readings in the FIFO are retrieved. * @details @@ -148,7 +155,7 @@ } 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_DG_SOFTWARE_FAULT, SW_FAULT_ID_INT_ADC_DATA_OVERRUN, adcRawReadingsCount ) } // start an adc channel group conversion @@ -175,9 +182,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_DG_SOFTWARE_FAULT, SW_FAULT_ID_INT_ADC_INVALID_CHANNEL_REQUESTED, channel ) } return result; } +/**@}*/