src/occ_405/pss/avsbus.c
// Read the status from AVS Bus and apply Vdd current roll over workaround if needed
// Error history counters will be incremented for any over-current condition.
Read the status from AVS Bus and apply Vdd current roll over workaround if needed
Error history counters will be incremented for any over-current condition.
Read the status from AVS Bus and apply Vdd current roll over workaround if needed Error history counters will be incremented for any over - current condition .
void process_avsbus_status()
{
    uint16_t vdd_status = 0;
    uint16_t vdn_status = 0;
    static bool L_vdd_oc_found = FALSE;
    static bool L_vdn_oc_found = FALSE;
    if (G_avsbus_vdd_monitoring)
    {
        vdd_status = avsbus_read_status(AVSBUS_VDD);
        if (vdd_status != AVSBUS_STATUS_READ_ERROR)
        {
            if ((vdd_status & AVSBUS_STATUS_OVER_CURRENT_MASK) == 0)
            {
                if (L_vdd_oc_found)
                {
                    L_vdd_oc_found = FALSE;
                    if(G_allow_trace_flags & ALLOW_AVSBUS_TRACE)
                        TRAC_INFO("process_avsbus_status: Vdd OC cleared");
                }
            }
            else 
            {
                INCREMENT_ERR_HISTORY(ERRH_AVSBUS_VDD_OVER_CURRENT);
                L_vdd_oc_found = TRUE;
            }
            if (G_check_vdd_current_10mA_for_rollover)
            {
                uint32_t l_current = G_check_vdd_current_10mA_for_rollover;
                if (L_vdd_oc_found)
                {
                   l_current += G_sysConfigData.vdd_current_rollover_10mA;
                   if(l_current > G_sysConfigData.vdd_max_current_10mA)
                   {
                        INCREMENT_ERR_HISTORY(ERRH_VDD_CURRENT_ROLLOVER_MAX);
                        if(G_allow_trace_flags & ALLOW_AVSBUS_TRACE)
                        {
                            TRAC_INFO("process_avsbus_status: Current with rollover %d > %d max",
                                        l_current, G_sysConfigData.vdd_max_current_10mA);
                        }
                        l_current = G_check_vdd_current_10mA_for_rollover;
                   }
                }
                sensor_update(AMECSENSOR_PTR(CURVDD), (uint16_t)l_current);
                update_avsbus_power_sensors(AVSBUS_VDD);
                G_check_vdd_current_10mA_for_rollover = 0;
            }
        }
        else
        {
            INCREMENT_ERR_HISTORY(ERRH_AVSBUS_VDD_STATUS_READ_FAIL);
        }
    }
    if (G_avsbus_vdn_monitoring)
    {
        vdn_status = avsbus_read_status(AVSBUS_VDN);
        if (vdn_status != AVSBUS_STATUS_READ_ERROR)
        {
            if ((vdn_status & AVSBUS_STATUS_OVER_CURRENT_MASK) == 0)
            {
                if (L_vdn_oc_found) TRAC_INFO("process_avsbus_status: Vdn OC cleared");
                L_vdn_oc_found = FALSE;
            }
            else 
            {
                INCREMENT_ERR_HISTORY(ERRH_AVSBUS_VDN_OVER_CURRENT);
                L_vdn_oc_found = TRUE;
                clear_status_errors(G_sysConfigData.avsbus_vdn.bus, AVSBUS_STATUS_OVER_CURRENT_MASK);
            }
        }
        else
        {
            INCREMENT_ERR_HISTORY(ERRH_AVSBUS_VDN_STATUS_READ_FAIL);
        }
    }
    return;
}
void process_avsbus_status ( ) { uint16_t vdd_status = 0 ; uint16_t vdn_status = 0 ; static bool L_vdd_oc_found = FALSE ; static bool L_vdn_oc_found = FALSE ; if ( G_avsbus_vdd_monitoring ) { vdd_status = avsbus_read_status ( AVSBUS_VDD ) ; if ( vdd_status != AVSBUS_STATUS_READ_ERROR ) { if ( ( vdd_status & AVSBUS_STATUS_OVER_CURRENT_MASK ) == 0 ) { if ( L_vdd_oc_found ) { L_vdd_oc_found = FALSE ; if ( G_allow_trace_flags & ALLOW_AVSBUS_TRACE ) TRAC_INFO ( " " ) ; } } else { INCREMENT_ERR_HISTORY ( ERRH_AVSBUS_VDD_OVER_CURRENT ) ; L_vdd_oc_found = TRUE ; } if ( G_check_vdd_current_10mA_for_rollover ) { uint32_t l_current = G_check_vdd_current_10mA_for_rollover ; if ( L_vdd_oc_found ) { l_current += G_sysConfigData . vdd_current_rollover_10mA ; if ( l_current > G_sysConfigData . vdd_max_current_10mA ) { INCREMENT_ERR_HISTORY ( ERRH_VDD_CURRENT_ROLLOVER_MAX ) ; if ( G_allow_trace_flags & ALLOW_AVSBUS_TRACE ) { TRAC_INFO ( " " , l_current , G_sysConfigData . vdd_max_current_10mA ) ; } l_current = G_check_vdd_current_10mA_for_rollover ; } } sensor_update ( AMECSENSOR_PTR ( CURVDD ) , ( uint16_t ) l_current ) ; update_avsbus_power_sensors ( AVSBUS_VDD ) ; G_check_vdd_current_10mA_for_rollover = 0 ; } } else { INCREMENT_ERR_HISTORY ( ERRH_AVSBUS_VDD_STATUS_READ_FAIL ) ; } } if ( G_avsbus_vdn_monitoring ) { vdn_status = avsbus_read_status ( AVSBUS_VDN ) ; if ( vdn_status != AVSBUS_STATUS_READ_ERROR ) { if ( ( vdn_status & AVSBUS_STATUS_OVER_CURRENT_MASK ) == 0 ) { if ( L_vdn_oc_found ) TRAC_INFO ( " " ) ; L_vdn_oc_found = FALSE ; } else { INCREMENT_ERR_HISTORY ( ERRH_AVSBUS_VDN_OVER_CURRENT ) ; L_vdn_oc_found = TRUE ; clear_status_errors ( G_sysConfigData . avsbus_vdn . bus , AVSBUS_STATUS_OVER_CURRENT_MASK ) ; } } else { INCREMENT_ERR_HISTORY ( ERRH_AVSBUS_VDN_STATUS_READ_FAIL ) ; } } return ; }
Read the status from AVS Bus and apply Vdd current roll over workaround if needed
Error history counters will be incremented for any over-current condition.
Read the status from AVS Bus and apply Vdd current roll over workaround if needed Error history counters will be incremented for any over - current condition .
// No OC errors found // Over current warning bit is set // Was updating Vdd Current sensor on hold to check if the reading rolled over? // over current bit gets set when there is a roll over // add the rollover point (from AVSbus config data) to the Current reading // sanity check for valid rollover, make sure it isn't over the theoretical max (from AVSbus config data) // went over the theoretical max don't apply the roll over // Now it is ok to update the sensor with Current value in unit 10mA // Update the chip voltage and power sensors after every current reading // clear so we know we have a new reading next time // error reading status // No OC errors found // Over current warning bit is set // Clear the over current error bit so we get a new read next time // error reading status