with hardware oversampling
This commit is contained in:
@ -38,6 +38,7 @@
|
||||
|
||||
// Toolbox
|
||||
#include "../Toolbox/UTIL_Utility.h"
|
||||
#include "DIPO_DigitalPorts.h"
|
||||
|
||||
// include STM32 drivers
|
||||
#include "stm32l4xx_hal.h"
|
||||
@ -49,11 +50,11 @@
|
||||
// Description: Definition of local constants (visible by this module only).
|
||||
//=================================================================================================
|
||||
|
||||
#define ADC_RES (4096) // ADC resolution: 12 bits
|
||||
#define ADC_RES (4096) // ADC resolution: 12 bits
|
||||
#define NR_OF_ADCS 5 // number of internal adc channels
|
||||
|
||||
// definitions of internal adc
|
||||
#define INT_ADC_REF_HI (3.28f) // HI int. reference voltage for conversion
|
||||
#define INT_ADC_REF_HI (3.3f) // HI int. reference voltage for conversion
|
||||
#define INT_ADC_REF_LO (0.0f) // LO int. reference voltage for conversion
|
||||
#define INT_ADC_REF (INT_ADC_REF_HI-INT_ADC_REF_LO)// int. reference voltage for conversion
|
||||
|
||||
@ -269,6 +270,8 @@ VOID ANPI_vTask( PVOID arg )
|
||||
{
|
||||
u32Flags = osEventFlagsWait( m_pstEventID, ANPI_FLAGS_ALL, osFlagsWaitAny, osWaitForever );
|
||||
|
||||
DIPO_vSetOutput(DIPO_eLED);
|
||||
|
||||
if( u32Flags & ANPI_ADC_FULL_COMPLETE )
|
||||
{
|
||||
u16Offset = BUFFER_HALF_SIZE;
|
||||
@ -288,6 +291,7 @@ VOID ANPI_vTask( PVOID arg )
|
||||
for(U16 u16Cnt = 0; u16Cnt < BUFFER_HALF_SIZE; u16Cnt++ )
|
||||
{
|
||||
m_au32ADCRawData[ u16Cnt % NR_OF_ADCS ] += m_au16ADCDataBuffer[eADC1][u16Cnt + u16Offset];
|
||||
//m_au32ADCRawData[ u16Cnt % NR_OF_ADCS ] = m_au16ADCDataBuffer[eADC1][u16Cnt + u16Offset];
|
||||
}
|
||||
|
||||
// ... multiply by the conversion factor and add the offset
|
||||
@ -297,9 +301,12 @@ VOID ANPI_vTask( PVOID arg )
|
||||
{
|
||||
m_aflValues[u16Cnt] = ((((FLOAT)m_au32ADCRawData[u16Cnt] / (FLOAT)ANPI_OVERSAMPLING_FACTOR * OFFSET) - (FLOAT)m_aflOffset1[u16Cnt] ) *
|
||||
(FLOAT)m_aflConversionFactor[u16Cnt]) - (FLOAT)m_aflOffset2[u16Cnt];
|
||||
//m_aflValues[u16Cnt] = (FLOAT)m_au32ADCRawData[u16Cnt];
|
||||
}
|
||||
|
||||
osMutexRelease( m_pstMutexID ); // release mutex
|
||||
|
||||
DIPO_vResetOutput(DIPO_eLED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,6 +330,7 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
|
||||
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc)
|
||||
{
|
||||
osEventFlagsSet( m_pstEventID, ANPI_ADC_HALF_COMPLETE );
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user