ADC Temp error handling, rename temps
This commit is contained in:
@ -35,7 +35,6 @@
|
||||
// Drivers
|
||||
#include "SPID_SpiDriver.h"
|
||||
#include "DIPO_DigitalPorts.h"
|
||||
//#include "EXTI_ExtiHandler.h"
|
||||
|
||||
// Application
|
||||
//#include "../Application/ELOG_ErrorLogger.h"
|
||||
@ -80,13 +79,6 @@
|
||||
#define CONFIG_FILT50HZ (1<<0)
|
||||
#define CONFIG_FILT60HZ (0<<0)
|
||||
|
||||
#define FAULT_HIGHTHRESH 0x80
|
||||
#define FAULT_LOWTHRESH 0x40
|
||||
#define FAULT_REFINLOW 0x20
|
||||
#define FAULT_REFINHIGH 0x10
|
||||
#define FAULT_RTDINLOW 0x08
|
||||
#define FAULT_OVUV 0x04
|
||||
|
||||
#define CONFIG (U8)(CONFIG_VBIAS_ON | CONFIG_MODE_OFF | CONFIG_24WIRE | CONFIG_FILT60HZ) // enable Vbias; autoconvert off; 4-wire; 60Hz;
|
||||
|
||||
#define EVENT_ENABLE ((U32)(1<<0))
|
||||
@ -204,30 +196,14 @@ BOOL ADCD_boInitializeModule( VOID )
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever );
|
||||
|
||||
// Conifg ADC Cold
|
||||
DIPO_vSetOutput( DIPO_eCS_C );
|
||||
DIPO_vSetOutput( DIPO_eCS_Module );
|
||||
boOK &= boWriteReg( REG_CONFIG, (U16) CONFIG | CONFIG_FAULTSTATCLEAR, FALSE );
|
||||
DIPO_vResetOutput( DIPO_eCS_C );
|
||||
|
||||
DIPO_vSetOutput( DIPO_eCS_C );
|
||||
boOK &= boWriteReg( REG_HIGH_FAULT_MSB, (U16)0x5b12 , TRUE );
|
||||
DIPO_vResetOutput( DIPO_eCS_C );
|
||||
|
||||
DIPO_vSetOutput( DIPO_eCS_C );
|
||||
boOK &= boWriteReg( REG_LOW_FAULT_MSB, (U16)0x2690 , TRUE );
|
||||
DIPO_vResetOutput( DIPO_eCS_C );
|
||||
DIPO_vResetOutput( DIPO_eCS_Module );
|
||||
|
||||
// Config ADC Hot
|
||||
DIPO_vSetOutput( DIPO_eCS_H );
|
||||
DIPO_vSetOutput( DIPO_eCS_Water );
|
||||
boOK &= boWriteReg( REG_CONFIG, (U16) CONFIG | CONFIG_FAULTSTATCLEAR, FALSE );
|
||||
DIPO_vResetOutput( DIPO_eCS_H );
|
||||
|
||||
DIPO_vSetOutput( DIPO_eCS_H );
|
||||
boOK &= boWriteReg( REG_HIGH_FAULT_MSB, (U16)0x5b12 , TRUE );
|
||||
DIPO_vResetOutput( DIPO_eCS_H );
|
||||
|
||||
DIPO_vSetOutput( DIPO_eCS_H );
|
||||
boOK &= boWriteReg( REG_LOW_FAULT_MSB, (U16)0x2690 , TRUE );
|
||||
DIPO_vResetOutput( DIPO_eCS_H );
|
||||
DIPO_vResetOutput( DIPO_eCS_Water );
|
||||
|
||||
osMutexRelease( m_pstMutexID );
|
||||
|
||||
@ -246,10 +222,10 @@ BOOL ADCD_boReadData( ADCD_EnTemps eChannel, PU8 pu8Error, PU16 pu16Data )
|
||||
*pu8Error = 0; // reset error state
|
||||
U16 u16Data = 0;
|
||||
|
||||
DIPO_EnDigitalOutput CS = DIPO_eCS_H;
|
||||
DIPO_EnDigitalOutput CS = DIPO_eCS_Water;
|
||||
|
||||
if( eChannel == ADCD_eHot ) CS = DIPO_eCS_H;
|
||||
else if ( eChannel == ADCD_eCold ) CS = DIPO_eCS_C;
|
||||
if( eChannel == ADCD_eWater ) CS = DIPO_eCS_Water;
|
||||
else if ( eChannel == ADCD_eModule ) CS = DIPO_eCS_Module;
|
||||
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever );
|
||||
DIPO_vSetOutput( CS );
|
||||
@ -257,7 +233,7 @@ BOOL ADCD_boReadData( ADCD_EnTemps eChannel, PU8 pu8Error, PU16 pu16Data )
|
||||
DIPO_vResetOutput( CS );
|
||||
osMutexRelease( m_pstMutexID );
|
||||
|
||||
osDelay(55);
|
||||
osDelay(100);
|
||||
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever );
|
||||
DIPO_vSetOutput( CS );
|
||||
@ -268,31 +244,27 @@ BOOL ADCD_boReadData( ADCD_EnTemps eChannel, PU8 pu8Error, PU16 pu16Data )
|
||||
if( !boOK )
|
||||
{
|
||||
*pu8Error |= ADCD_SPI_FAILURE;
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( ( u16Data & 0x00 ) == 0x01 )
|
||||
if( ( u16Data & 0x0001 ) == 0x0001 )
|
||||
{
|
||||
*pu8Error |= ADCD_STATUS_DATA_ERROR;
|
||||
|
||||
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever );
|
||||
|
||||
DIPO_vSetOutput( CS );
|
||||
boOK &= boReadReg( REG_FAULT_STATUS, &u16Data, FALSE );
|
||||
boOK &= boReadReg( REG_FAULT_STATUS, (PU16)pu8Error, FALSE );
|
||||
DIPO_vResetOutput( CS );
|
||||
|
||||
DIPO_vSetOutput( CS );
|
||||
boOK &= boWriteReg( REG_CONFIG, (U16) CONFIG | CONFIG_FAULTSTATCLEAR, FALSE );
|
||||
DIPO_vResetOutput( CS );
|
||||
|
||||
DIPO_vSetOutput( CS );
|
||||
boOK &= boReadReg( REG_HIGH_FAULT_MSB, &u16Data, TRUE );
|
||||
DIPO_vResetOutput( CS );
|
||||
|
||||
osMutexRelease( m_pstMutexID );
|
||||
|
||||
*pu8Error |= u16Data & 0xFC;
|
||||
return 0;
|
||||
*pu8Error |= ADCD_STATUS_DATA_ERROR;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u16Data = u16Data >> 1;
|
||||
|
Reference in New Issue
Block a user