src/occ_405/amec/amec_sensors_centaur.c
// Function Specification
//
// Name: amec_update_centaur_dts_sensors
//
// Description: Updates sensors that have data grabbed by the fast core data
//
// Thread: RealTime Loop
//
// End Function Specification
Function Specification
Name: amec_update_centaur_dts_sensors

Updates sensors that have data grabbed by the fast core data



End Function Specification
Function Specification Name : amec_update_centaur_dts_sensors Updates sensors that have data grabbed by the fast core data End Function Specification
void amec_update_centaur_dts_sensors(CentaurMemData * i_sensor_cache, uint8_t i_centaur)
{
#define MIN_VALID_CENT_TEMP 1
#define MAX_VALID_CENT_TEMP 125 //according to Mike Pardiek
#define CENT_SENSOR_STATUS_VALID 0x0001
#define CENT_SENSOR_TEMP_MASK    0xfff0
    uint16_t l_dts, l_sens_value0, l_sens_value1;
    uint16_t l_sens_status0, l_sens_status1, l_sens_status;
    uint16_t l_sens_temp0, l_sens_temp1, l_cent_temp;
    int32_t  l_prev_temp;
    static uint8_t L_ran_once[MAX_NUM_CENTAURS] = {FALSE};
    l_sens_value0 = i_sensor_cache->scache.centaur_thermal_sensor[0].value;
    l_sens_value1 = i_sensor_cache->scache.centaur_thermal_sensor[1].value;
    l_sens_status0 = l_sens_value0 & CENT_SENSOR_STATUS_VALID;
    l_sens_status1 = l_sens_value1 & CENT_SENSOR_STATUS_VALID;
    l_sens_temp0 = (l_sens_status0)? (l_sens_value0 & CENT_SENSOR_TEMP_MASK) >>  4:
                   0;
    l_sens_temp1 = (l_sens_status1)? (l_sens_value1 & CENT_SENSOR_TEMP_MASK) >>  4:
                   0;
    l_sens_status = l_sens_status0 | l_sens_status1;
    l_cent_temp = (l_sens_temp0 > l_sens_temp1)? l_sens_temp0: l_sens_temp1;
    fru_temp_t* l_fru = &g_amec->proc[0].memctl[i_centaur].centaur.centaur_hottest;
    l_prev_temp = l_fru->cur_temp;
    if(!l_prev_temp)
    {
        l_prev_temp = l_cent_temp;
    }
    if(l_sens_status == CENT_SENSOR_STATUS_VALID &&
       !(G_centaur_nest_lfir6 & (CENTAUR0_PRESENT_MASK >> i_centaur)))
    {
        if(l_cent_temp < MIN_VALID_CENT_TEMP ||
           l_cent_temp > MAX_VALID_CENT_TEMP)
        {
            l_fru->flags |= FRU_TEMP_OUT_OF_RANGE;
            l_dts = l_prev_temp;
        }
        else
        {
            if(l_cent_temp > (l_prev_temp + MAX_MEM_TEMP_CHANGE))
            {
                l_dts = l_prev_temp + MAX_MEM_TEMP_CHANGE;
                if(!l_fru->flags)
                {
                    TRAC_INFO("centaur temp rose faster than reasonable: cent[%d] prev[%d] cur[%d]",
                              i_centaur, l_prev_temp, l_cent_temp);
                    l_fru->flags |= FRU_TEMP_FAST_CHANGE;
                }
            }
            else if (l_cent_temp < (l_prev_temp - MAX_MEM_TEMP_CHANGE))
            {
                l_dts = l_prev_temp - MAX_MEM_TEMP_CHANGE;
                if(!l_fru->flags)
                {
                    TRAC_INFO("centaur temp fell faster than reasonable: cent[%d] prev[%d] cur[%d]",
                                  i_centaur, l_prev_temp, l_cent_temp);
                    l_fru->flags |= FRU_TEMP_FAST_CHANGE;
                }
            }
            else 
            {
                l_dts = l_cent_temp;
                l_fru->flags &= ~FRU_TEMP_FAST_CHANGE;
            }
            G_cent_temp_updated_bitmap |= CENTAUR0_PRESENT_MASK >> i_centaur;
            l_fru->flags &= FRU_TEMP_FAST_CHANGE;
        }
    }
    else 
    {
        if(L_ran_once[i_centaur])
        {
            if(!(l_fru->flags & FRU_SENSOR_STATUS_INVALID) &&
               !(l_sens_status == CENT_SENSOR_STATUS_VALID))
            {
                TRAC_INFO("Centaur%d temp invalid. nest_lfir6=0x%02x", i_centaur, G_centaur_nest_lfir6);
            }
            l_fru->flags |= FRU_SENSOR_STATUS_INVALID;
            if(G_centaur_nest_lfir6 & (CENTAUR0_PRESENT_MASK >> i_centaur))
            {
                l_fru->flags |= FRU_SENSOR_CENT_NEST_FIR6;
            }
        }
        l_dts = l_prev_temp;
    }
    L_ran_once[i_centaur] = TRUE;
    if(l_dts >= g_amec->thermalcent.ot_error)
    {
        G_cent_overtemp_bitmap |= (CENTAUR0_PRESENT_MASK >> i_centaur);
    }
    g_amec->proc[0].memctl[i_centaur].centaur.centaur_hottest.cur_temp = l_dts;
    AMEC_DBG("Centaur[%d]: HotCentaur=%d\n",i_centaur,l_dts);
}
void amec_update_centaur_dts_sensors ( CentaurMemData * i_sensor_cache , uint8_t i_centaur ) { #define MIN_VALID_CENT_TEMP  1 #define MAX_VALID_CENT_TEMP  125 //according to Mike Pardiek #define CENT_SENSOR_STATUS_VALID  0x0001 #define CENT_SENSOR_TEMP_MASK     0xfff0 uint16_t l_dts , l_sens_value0 , l_sens_value1 ; uint16_t l_sens_status0 , l_sens_status1 , l_sens_status ; uint16_t l_sens_temp0 , l_sens_temp1 , l_cent_temp ; int32_t l_prev_temp ; static uint8_t L_ran_once [ MAX_NUM_CENTAURS ] = { FALSE } ; l_sens_value0 = i_sensor_cache -> scache . centaur_thermal_sensor [ 0 ] . value ; l_sens_value1 = i_sensor_cache -> scache . centaur_thermal_sensor [ 1 ] . value ; l_sens_status0 = l_sens_value0 & CENT_SENSOR_STATUS_VALID ; l_sens_status1 = l_sens_value1 & CENT_SENSOR_STATUS_VALID ; l_sens_temp0 = ( l_sens_status0 ) ? ( l_sens_value0 & CENT_SENSOR_TEMP_MASK ) >> 4 : 0 ; l_sens_temp1 = ( l_sens_status1 ) ? ( l_sens_value1 & CENT_SENSOR_TEMP_MASK ) >> 4 : 0 ; l_sens_status = l_sens_status0 | l_sens_status1 ; l_cent_temp = ( l_sens_temp0 > l_sens_temp1 ) ? l_sens_temp0 : l_sens_temp1 ; fru_temp_t * l_fru = & g_amec -> proc [ 0 ] . memctl [ i_centaur ] . centaur . centaur_hottest ; l_prev_temp = l_fru -> cur_temp ; if ( ! l_prev_temp ) { l_prev_temp = l_cent_temp ; } if ( l_sens_status == CENT_SENSOR_STATUS_VALID && ! ( G_centaur_nest_lfir6 & ( CENTAUR0_PRESENT_MASK >> i_centaur ) ) ) { if ( l_cent_temp < MIN_VALID_CENT_TEMP || l_cent_temp > MAX_VALID_CENT_TEMP ) { l_fru -> flags |= FRU_TEMP_OUT_OF_RANGE ; l_dts = l_prev_temp ; } else { if ( l_cent_temp > ( l_prev_temp + MAX_MEM_TEMP_CHANGE ) ) { l_dts = l_prev_temp + MAX_MEM_TEMP_CHANGE ; if ( ! l_fru -> flags ) { TRAC_INFO ( " " , i_centaur , l_prev_temp , l_cent_temp ) ; l_fru -> flags |= FRU_TEMP_FAST_CHANGE ; } } else if ( l_cent_temp < ( l_prev_temp - MAX_MEM_TEMP_CHANGE ) ) { l_dts = l_prev_temp - MAX_MEM_TEMP_CHANGE ; if ( ! l_fru -> flags ) { TRAC_INFO ( " " , i_centaur , l_prev_temp , l_cent_temp ) ; l_fru -> flags |= FRU_TEMP_FAST_CHANGE ; } } else { l_dts = l_cent_temp ; l_fru -> flags &= ~ FRU_TEMP_FAST_CHANGE ; } G_cent_temp_updated_bitmap |= CENTAUR0_PRESENT_MASK >> i_centaur ; l_fru -> flags &= FRU_TEMP_FAST_CHANGE ; } } else { if ( L_ran_once [ i_centaur ] ) { if ( ! ( l_fru -> flags & FRU_SENSOR_STATUS_INVALID ) && ! ( l_sens_status == CENT_SENSOR_STATUS_VALID ) ) { TRAC_INFO ( " " , i_centaur , G_centaur_nest_lfir6 ) ; } l_fru -> flags |= FRU_SENSOR_STATUS_INVALID ; if ( G_centaur_nest_lfir6 & ( CENTAUR0_PRESENT_MASK >> i_centaur ) ) { l_fru -> flags |= FRU_SENSOR_CENT_NEST_FIR6 ; } } l_dts = l_prev_temp ; } L_ran_once [ i_centaur ] = TRUE ; if ( l_dts >= g_amec -> thermalcent . ot_error ) { G_cent_overtemp_bitmap |= ( CENTAUR0_PRESENT_MASK >> i_centaur ) ; } g_amec -> proc [ 0 ] . memctl [ i_centaur ] . centaur . centaur_hottest . cur_temp = l_dts ; AMEC_DBG ( " \n " , i_centaur , l_dts ) ; }
Function Specification
Name: amec_update_centaur_dts_sensors
Function Specification Name : amec_update_centaur_dts_sensors
//Check DTS status bits and NEST LFIR bit 6 for a valid temperature. //make sure temperature is within a 'reasonable' range. //set a flag so that if we end up logging an error we have something to debug why //don't allow temp to change more than is reasonable for 2ms //reasonable amount of change occurred //Notify thermal thread that temperature has been updated //clear error flags //status was INVALID //Trace the error if we haven't traced it already for this sensor //and this wasn't only caused by LFIR[6] (which is traced elsewhere). //use last temperature //Check if at or above the error temperature //Set a bit so that this dimm can be called out by the thermal thread // Update Interim Data - later this will get picked up to form centaur sensor