added Variablehandler for Temp
This commit is contained in:
@ -30,7 +30,7 @@
|
||||
// Description: List of required include files.
|
||||
//=================================================================================================
|
||||
|
||||
//#include "../Application/VARH_VariableHandler.h"
|
||||
#include "../Application/VARH_VariableHandler.h"
|
||||
#include "../PDEF_ProjectDefinitions.h"
|
||||
#include "TEMP_Temperature.h"
|
||||
|
||||
@ -62,26 +62,16 @@
|
||||
|
||||
#define REFRESH_MS 100
|
||||
|
||||
// Konstanten f<>r Temperaturberechung
|
||||
#define RTD_A 3.9083e-3
|
||||
#define RTD_B -5.775e-7
|
||||
|
||||
#define R_REF 4000
|
||||
#define R_NOMINAL 1000
|
||||
|
||||
//=================================================================================================
|
||||
// Section: MACROS
|
||||
// Description: Definition of local macros (visible by this module only).
|
||||
//=================================================================================================
|
||||
|
||||
|
||||
|
||||
//=================================================================================================
|
||||
// Section: ENUMERATIONS
|
||||
// Description: Definition of local enumerations (visible by this module only).
|
||||
//=================================================================================================
|
||||
|
||||
|
||||
//=================================================================================================
|
||||
// Section: STRUCTURES
|
||||
// Description: Definition of local Structures (visible by this module only).
|
||||
@ -100,13 +90,6 @@ PRIVATE VOID vTempTask( PVOID arg );
|
||||
// Description: Definition of local constants (visible by this module only).
|
||||
//=================================================================================================
|
||||
|
||||
LOCAL CONST osMutexAttr_t m_stMutexAttr =
|
||||
{
|
||||
"TEMP_Mutex", // human readable mutex name
|
||||
osMutexRecursive | osMutexPrioInherit, // attr_bits
|
||||
NULL, // memory for control block
|
||||
0U // size for control block
|
||||
};
|
||||
|
||||
LOCAL CONST osThreadAttr_t stTaskAttribute =
|
||||
{
|
||||
@ -127,9 +110,6 @@ LOCAL CONST osThreadAttr_t stTaskAttribute =
|
||||
//=================================================================================================
|
||||
|
||||
LOCAL osThreadId_t m_pstThreadID = NULL;
|
||||
LOCAL osMutexId_t m_pstMutexID = NULL;
|
||||
|
||||
LOCAL FLOAT m_flTempData[ADCD_eNumberOfTemps];
|
||||
|
||||
//=================================================================================================
|
||||
// Section: EXTERNAL FUNCTIONS
|
||||
@ -162,52 +142,10 @@ BOOL TEMP_boInitializeModule( VOID )
|
||||
BOOL boOK = TRUE;
|
||||
|
||||
boOK &= ((m_pstThreadID = osThreadNew( vTempTask, NULL, &stTaskAttribute )) == NULL ) ? FALSE : TRUE;
|
||||
boOK &= ((m_pstMutexID = osMutexNew( &m_stMutexAttr )) == NULL) ? FALSE : TRUE;
|
||||
|
||||
return( boOK );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: TEMP_dGetValue
|
||||
// Description: Gets the desired temperature
|
||||
// Parameters: ATEMP_EnTemperature enInput
|
||||
// Returns: DOUBLE DValue Value from ADC
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
FLOAT TEMP_dGetValue( ADCD_EnTemps enTemp )
|
||||
{
|
||||
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever );
|
||||
DOUBLE dValue = m_flTempData[enTemp];
|
||||
osMutexRelease( m_pstMutexID );
|
||||
|
||||
return( dValue );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: TEMP_boRegisterEventNotification
|
||||
// Description: Register for a notification when there are new values
|
||||
// Parameters: TEMP_pfnEventCallback pfnCallback
|
||||
// PVOID pvCallbackArgument
|
||||
// Returns: TRUE, if successfull, otherwise FALSE
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
//BOOL TEMP_boRegisterEventNotification( TEMP_pfnEventCallback pfnCallback, PVOID pvCallbackArgument )
|
||||
//{
|
||||
// BOOL boRet = FALSE;
|
||||
// osMutexAcquire( m_pstMutexID, osWaitForever );
|
||||
// for( U16 u16Cnt = 0; u16Cnt < NUMBER_OF_EVENT_CALLBACKS; u16Cnt++ )
|
||||
// {
|
||||
// if( m_apfnEventCallback[u16Cnt] == NULL )
|
||||
// {
|
||||
// m_apfnEventCallback[u16Cnt] = pfnCallback;
|
||||
// m_apvCallbackArgument[u16Cnt] = pvCallbackArgument;
|
||||
// boRet = TRUE;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// osMutexRelease( m_pstMutexID );
|
||||
// return( boRet );
|
||||
//}
|
||||
|
||||
//=================================================================================================
|
||||
// Section: LOCAL FUNCTIONS
|
||||
// Descriptionn: Definition (implementation) of local functions.
|
||||
@ -227,7 +165,7 @@ PRIVATE VOID vTempTask( PVOID arg )
|
||||
BOOL boOK = TRUE;
|
||||
U8 error;
|
||||
U16 u16ADC_data[ADCD_eNumberOfTemps];
|
||||
U8 u8Channel;
|
||||
FLOAT flTempData[ADCD_eNumberOfTemps];
|
||||
|
||||
osDelay(10);
|
||||
|
||||
@ -240,24 +178,15 @@ PRIVATE VOID vTempTask( PVOID arg )
|
||||
//if( u32Flags & EVENT_REFRESH )
|
||||
//{
|
||||
boOK &= ADCD_dReadData(ADCD_eHot, &error, &u16ADC_data[ADCD_eHot]);
|
||||
boOK &= ADCD_dReadData(ADCD_eCold, &error, &u16ADC_data[ADCD_eCold]);
|
||||
if( boOK )
|
||||
{
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever );
|
||||
m_flTempData[ADCD_eHot] = flConvertADCData( u16ADC_data[ADCD_eHot] );
|
||||
//VARH_vSetVariableData( VARH_eTempHeatSink + u8Channel, (VARH_UVariable)(FLOAT)m_dbTempData[u8Channel] );
|
||||
osMutexRelease( m_pstMutexID );
|
||||
} else {
|
||||
boOK = TRUE;
|
||||
}
|
||||
boOK &= ADCD_dReadData(ADCD_eCold, &error, &u16ADC_data[ADCD_eCold]);
|
||||
if( boOK )
|
||||
{
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever );
|
||||
m_flTempData[ADCD_eCold] = flConvertADCData( u16ADC_data[ADCD_eCold] );
|
||||
//VARH_vSetVariableData( VARH_eTempHeatSink + u8Channel, (VARH_UVariable)(FLOAT)m_dbTempData[u8Channel] );
|
||||
osMutexRelease( m_pstMutexID );
|
||||
} else {
|
||||
boOK = TRUE;
|
||||
flTempData[ADCD_eHot] = flConvertADCData( u16ADC_data[ADCD_eHot] );
|
||||
flTempData[ADCD_eCold] = flConvertADCData( u16ADC_data[ADCD_eCold] );
|
||||
VARH_vSetVariableData( VARH_eTemp_H, (VARH_UVariable)flTempData[ADCD_eHot] );
|
||||
VARH_vSetVariableData( VARH_eTemp_C, (VARH_UVariable)flTempData[ADCD_eCold] );
|
||||
VARH_vSetVariableData( VARH_eTemp_Diff, (VARH_UVariable)(flTempData[ADCD_eHot] - flTempData[ADCD_eCold]) );
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
|
Reference in New Issue
Block a user