Beispiel #1
0
// ============================================================================
// hal_TimSetExpirationTime
// ----------------------------------------------------------------------------
/// Set the next time when the OS timer will wrap.
/// @param nextPeriod The next period before the new wrap.
// ============================================================================
PUBLIC VOID hal_TimSetExpirationTime(UINT32 nextPeriod)
{
    HAL_PROFILE_FUNCTION_ENTER(hal_TimSetExpirationTime);
    UINT32 status;
    UINT32 period = nextPeriod;

    status=hal_SysEnterCriticalSection();
#ifdef TIM_VERBOSE
        HAL_TRACE(_PAL|TSTDOUT,0,"TickNotify: Next_Period %d, TickError %d",Next_Period,TickError);
#endif

    if (period>HAL_TIM_MAX_PER)
    {
        g_halTickOverflow = period-HAL_TIM_MAX_PER;
        g_halTickLastPeriod = HAL_TIM_MAX_PER;
    }
    else
    {
        g_halTickOverflow = 0;
        g_halTickLastPeriod = period;

    }

#ifdef TIM_VERBOSE
        HAL_TRACE(_PAL|TSTDOUT,0, "TickNotify: g_halTickLastPeriod %d",g_halTickLastPeriod);
#endif

    hal_TimTickStart(g_halTickLastPeriod);
   
    hal_SysExitCriticalSection(status);
    HAL_PROFILE_FUNCTION_EXIT(hal_TimSetExpirationTime);
}
Beispiel #2
0
// ============================================================================
// hal_TimGetReminderTime
// ----------------------------------------------------------------------------
/// Return the remaining time to count before the previously programmed period
/// expires.
/// @return Time before the previously programmed period expires.
// ============================================================================
PUBLIC UINT32 hal_TimGetReminderTime(VOID)
{
    HAL_PROFILE_FUNCTION_ENTER(hal_TimGetReminderTime);
    UINT32 status;
    UINT32 timVal;


    status=hal_SysEnterCriticalSection();

//   // the timer counts negatively once wrapped, so ...
//     // overflow + wrap time = remaining time to count
//     if ((hwp_timer->irq_cause & TIMER_STATUS(OSTIM_IRQ)))
//     {
//         // The counter wrapped and the irq is pending or under treatment
//         tim_val=g_halTickOverflow;
// #ifdef TIM_VERBOSE
//         hal_Printf((_PAL | TSTDOUT,"TickGetVal : Irq Pending"));
// #endif
//     }
//     else 
        timVal = hal_TimTickGetVal() + g_halTickOverflow;
    
#ifdef TIM_VERBOSE
    HAL_TRACE(_PAL | TSTDOUT, 0, "TickGetVal: %d",timVal);
#endif

    hal_SysExitCriticalSection(status);
    HAL_PROFILE_FUNCTION_EXIT(hal_TimGetReminderTime);
    return (timVal);
}
Beispiel #3
0
// ============================================================================
// hal_TickIrqHandler
// ----------------------------------------------------------------------------
/// IRQ handler for the OS timer, called when this timer wrap.
// ============================================================================
PRIVATE VOID hal_TickIrqHandler(VOID)
{
    
    UINT32 scStatus;
    INT32 tickError=0;
    UINT32 reportedPeriod;

    scStatus=hal_SysEnterCriticalSection();
    
    // save error
    tickError = (INT32) hal_TimTickGetVal();

    // disable timer
    hal_TimTickStop();

    reportedPeriod = g_halTickLastPeriod-tickError;

    hal_SysExitCriticalSection(scStatus);

#ifdef TIM_VERBOSE
    HAL_TRACE(_PAL | TSTDOUT, 0, "TickIRQ: Tampax %d, Error %d", reportedPeriod, tickError);
#endif

    sxr_Tampax(reportedPeriod, 0);
}
Beispiel #4
0
// =============================================================================
// hal_MapEnginePrintModuleVersion
// -----------------------------------------------------------------------------
/// Print a module version's string on the Trace, if the module has been
/// registered.
/// @param id Number of the Module whose version is to be put
/// on the Trace.
// =============================================================================
PUBLIC VOID hal_MapEnginePrintModuleVersion(HAL_MAP_ID_T id)
{
    HAL_ASSERT((id >= 0 && id < HAL_MAP_ID_COUNT),
                "Bad Hal Engine Module Number");
    if (g_halMapTable.modules[id].version != NULL)
    {
        HAL_TRACE(TSTDOUT, 1, "%s\n number: %d - date: %d - revision: %d.",
                            g_halMapTable.modules[id].version->string,
                            g_halMapTable.modules[id].version->number,
                            g_halMapTable.modules[id].version->date,
                            g_halMapTable.modules[id].version->revision
                            );
    }
    else
    {
        HAL_TRACE(TSTDOUT, 0, "Module %d not registered !", id);
    }

}
Beispiel #5
0
// =============================================================================
// hal_KeyRemoteHandler
// -----------------------------------------------------------------------------
/// Simulate the press or release of a key. This function is aimed at being
/// executed remotely, by a keyboard emulator integrated in CoolWatcher.
///
/// @param keyCode Key code of the key, as defined in key_defs.h, to press and
/// release.
/// @param state State to set the key to: #HAL_KEY_DOWN, #HAL_KEY_UP, ...
// =============================================================================
PUBLIC VOID hal_KeyRemoteHandler(UINT32 keyCode, HAL_KEY_STATE_T state)
{
    UINT32  keyId = 0;
    BOOL    found = FALSE;

    while (keyId<=HAL_KEY_ON_OFF && !found)
    {
        if (keyCode == tgt_GetKeyCode(keyId))
        {
            // Id of the key found, exit the loop
            found = TRUE;
        }
        else
        {
            // Try next Id.
            keyId += 1;
        }
    }
    
    if (!found)
    {
        HAL_TRACE(HAL_IO_TRC, 0, "Pulsely pressed unknown key");
        return;
    }


    if (g_keyIrqHandler)
    {
        // Send the key state. taking mask into account.
        if ((g_eventOnUp        && (state == HAL_KEY_UP))
         || (g_eventOnPressed   && (state == HAL_KEY_PRESSED))
         || (g_eventOnDown      && (state == HAL_KEY_DOWN)))
        {
            g_keyIrqHandler(keyId, state);
            HAL_TRACE(HAL_IO_TRC, 0, "Remotely %ded key %c.", state, keyCode);
        }
    }
}
Beispiel #6
0
PUBLIC VOID hal_PerfMeterOpen(HAL_PERFMETER_CFG_T *cfg)
{
    g_hal_PerfMeterTarget = cfg->target;
    g_hal_PerfMeterSingleShot = cfg->singleShot;

    switch (g_hal_PerfMeterTarget)
    {
        case HAL_PERF_AHB_BUS_USAGE:
            hwp_sysAhbMonitor->Control=
                SYS_AHB_MONITOR_TIME_WINDOW_TW_16MC | SYS_AHB_MONITOR_ACCUMULATION_MODE_MAX |
                SYS_AHB_MONITOR_TARGET_SYS_BUS;
            break;
        case HAL_PERF_EBC_USAGE:
            hwp_sysAhbMonitor->Control=
                SYS_AHB_MONITOR_TIME_WINDOW_TW_16MC | 
                SYS_AHB_MONITOR_TARGET_SIGNAL_SELECT0;
            // Select nb cycles of EBC state machine not idle
            hwp_debugPort->Signal_Spy_Cfg=DEBUG_PORT_DBG_BUS_SIG_SEL1_DBG_BB_EBC_BUSY | 
                DEBUG_PORT_DBG_BUS_SIG_SEL0_DBG_SYS_EBC_BUSY;
            hwp_memBridge->Monitor_Ctrl=MEM_BRIDGE_MONITOR_SEL_DATA_VS_EXTERNAL;
            break;
        case HAL_PERF_INT_RAMROM:
            hwp_sysAhbMonitor->Control=
                SYS_AHB_MONITOR_TIME_WINDOW_TW_16MC | SYS_AHB_MONITOR_ACCUMULATION_MODE_MAX |
                SYS_AHB_MONITOR_TARGET_SYS_MEM_INT;
            break;
        case HAL_PERF_ICACHE_MISS:
            hwp_debugPort->Signal_Spy_Cfg=DEBUG_PORT_DBG_BUS_SIG_SEL0_DBG_XCPU_I_MISS;
            hwp_sysAhbMonitor->Control=
                SYS_AHB_MONITOR_TIME_WINDOW_TW_16MC | SYS_AHB_MONITOR_ACCUMULATION_MODE_MAX |
                SYS_AHB_MONITOR_TARGET_SIGNAL_SELECT0;
            break;
        case HAL_PERF_DCACHE_MISS:
            hwp_debugPort->Signal_Spy_Cfg=DEBUG_PORT_DBG_BUS_SIG_SEL0_DBG_XCPU_D_MISS;
            hwp_sysAhbMonitor->Control=
                SYS_AHB_MONITOR_TIME_WINDOW_TW_16MC | SYS_AHB_MONITOR_ACCUMULATION_MODE_MAX |
                SYS_AHB_MONITOR_TARGET_SIGNAL_SELECT0;
            break;
        case HAL_PERF_I_FETCH:
            hwp_debugPort->Signal_Spy_Cfg=DEBUG_PORT_DBG_BUS_SIG_SEL0_DBG_XCPU_I_FETCH;
            hwp_sysAhbMonitor->Control=
                SYS_AHB_MONITOR_TIME_WINDOW_TW_16MC | SYS_AHB_MONITOR_ACCUMULATION_MODE_MAX |
                SYS_AHB_MONITOR_TARGET_SIGNAL_SELECT0;
            break;
        case HAL_PERF_D_FETCH:
            hwp_debugPort->Signal_Spy_Cfg=DEBUG_PORT_DBG_BUS_SIG_SEL0_DBG_XCPU_D_FETCH;
            hwp_sysAhbMonitor->Control=
                SYS_AHB_MONITOR_TIME_WINDOW_TW_16MC | SYS_AHB_MONITOR_ACCUMULATION_MODE_MAX |
                SYS_AHB_MONITOR_TARGET_SIGNAL_SELECT0;
            break;
        default:
            // Invalid choice
            HAL_TRACE(HAL_DBG_TRC,0,"Hal perfmeter: Invalid target %d",g_hal_PerfMeterTarget);
            hwp_sysAhbMonitor->Control=0;
            g_hal_PerfMeterTarget=HAL_PERF_NOT_PROGRAMMED;
            return;
    }
    if (cfg->singleShot)
    {
        hwp_sysAhbMonitor->Control|=SYS_AHB_MONITOR_ENABLE | SYS_AHB_MONITOR_RECORD_SINGLE_SHOT;
    }
    else
    {
        hwp_sysAhbMonitor->Control|=SYS_AHB_MONITOR_ENABLE | SYS_AHB_MONITOR_RECORD_MULTI_SHOT;
    }
}
Beispiel #7
0
PUBLIC UINT32 hal_PerfMeterGetStatistics(VOID)
{
    HAL_TRACE(HAL_DBG_TRC,0,"hal_perfGetStatistics: Perfmeter not supported on this platform");
    return PERFMETER_NOT_READY; 
}
Beispiel #8
0
PUBLIC VOID hal_PerfMeterClose(VOID)
{
    HAL_TRACE(HAL_DBG_TRC,0,"hal_perfMeterClose: Perfmeter not supported on this platform");
}
Beispiel #9
0
PUBLIC VOID hal_PerfMeterOpen(HAL_PERFMETER_CFG_T *cfg)
{
    HAL_TRACE(HAL_DBG_TRC,0,"hal_perfMeterOpen: Perfmeter not supported on this platform");
}
Beispiel #10
0
PUBLIC UINT32 hal_PerfMeterGetStatistics(VOID)
{
    UINT32 usage = hwp_sysAhbMonitor->Use;
    UINT32 HAL_POSSIBLY_UNUSED accessCount = hwp_sysAhbMonitor->Access_Count;
    UINT32 HAL_POSSIBLY_UNUSED latency = hwp_sysAhbMonitor->Latency;
    UINT32 stat;
    
    if (g_hal_PerfMeterTarget!=HAL_PERF_NOT_PROGRAMMED)
    {
        stat=usage*100/16777216;
        if ((hwp_sysAhbMonitor->Control & SYS_AHB_MONITOR_ENABLE) && (g_hal_PerfMeterSingleShot))
        {
            // Result not ready
            return PERFMETER_NOT_READY;
        }
        else
        {
            // Result is ready
            switch (g_hal_PerfMeterTarget)
            {
                case HAL_PERF_AHB_BUS_USAGE:
                    HAL_TRACE(HAL_DBG_TRC,0,"Bus is used %d%% of the time",stat);
                    break;
                case HAL_PERF_EBC_USAGE:
                    HAL_TRACE(HAL_DBG_TRC,0,"External Memory Bus is used %d%% of the time",stat);
                    break;
                case HAL_PERF_INT_RAMROM:
                    HAL_TRACE(HAL_DBG_TRC,0,"Internal Ram/Rom is used %d%% of the time",stat);
                    // TODO missing mask and shift in XML description
                    // Use it when available
                    HAL_TRACE(HAL_DBG_TRC,0,"Internal Ram/Rom max access time %d cycles over %d accesses",
                            latency & 0xffffff, accessCount);
                    break;
                case HAL_PERF_ICACHE_MISS:
                    HAL_TRACE(HAL_DBG_TRC,0,"XCPU is in Icache miss %d%% of the time",stat);
                    HAL_TRACE(HAL_DBG_TRC,0,"XCPU ICache miss max access time %d cycles over %d accesses",
                            latency & 0xffffff, accessCount);
                    break;
                case HAL_PERF_DCACHE_MISS:
                    HAL_TRACE(HAL_DBG_TRC,0,"XCPU is in Dcache miss %d%% of the time",stat);
                    HAL_TRACE(HAL_DBG_TRC,0,"XCPU DCache miss max access time %d cycles over %d accesses",
                            latency & 0xffffff, accessCount);
                    break;
                case HAL_PERF_I_FETCH:
                    HAL_TRACE(HAL_DBG_TRC,0,"XCPU is Fetching Instructions %d%% of the time",stat);
                    HAL_TRACE(HAL_DBG_TRC,0,"XCPU Instruction fetch max access time %d cycles over %d accesses",
                            latency & 0xffffff, accessCount);
                    break;
                case HAL_PERF_D_FETCH:
                    HAL_TRACE(HAL_DBG_TRC,0,"XCPU is Fetching Datas %d%% of the time",stat);
                    HAL_TRACE(HAL_DBG_TRC,0,"XCPU Data fetch max access time %d cycles over %d accesses",
                            latency & 0xffffff, accessCount);
                    break;
                default:
                    stat=PERFMETER_NOT_READY;
                    HAL_TRACE(HAL_DBG_TRC,0,"Unsupported perfmeter target");
                    break;
        
            }
            // Relaunch
            hwp_sysAhbMonitor->Control|=SYS_AHB_MONITOR_ENABLE;
        
            return stat;
        }
    }
    else
    {
        return PERFMETER_NOT_READY;
    }
}
Beispiel #11
0
// ***  hal_LpsCalibrate() ***
// This function must be called at every frame interrupt to keep the calibration up to date
PUBLIC VOID HAL_FUNC_INTERNAL hal_LpsCalibrate()
{
    if (g_halLpsCtx.lpsState == HAL_LPS_IDLE)
    {
        g_halLpsCtx.lpsInvalidateCalib = FALSE;
    }
    if (g_halLpsCtx.lpsInvalidateCalib == TRUE)
    {
        // Need to invalidate
        g_halLpsCtx.lpsState = HAL_LPS_IDLE;
        g_halLpsCtx.lpsRate = HAL_LPS_UNDEF_VALUE;
        g_halLpsCtx.lpsInvalidateCalib = FALSE;
        // disable LPS SM - Keep the SF_ENABLE bit on if it was already enabled
        hwp_tcu->LPS_SF_Ctrl &= ~TCU_LPS_SF_LOWPOWER_MASK;
        HAL_PROFILE_WINDOW_EXIT(CALIB_VALID);
        return;
    }

    switch (g_halLpsCtx.lpsState)
    {
        case HAL_LPS_CALIBRATED:
        {
            // we are already calibrated - do nothing
            break;
        }
        case HAL_LPS_CALIB_RUNNING:
        {
            // A calibration is currently running
            // Check if it is done
            if (hwp_tcu->LPS_SF_Status & TCU_LPS_SF_CALIBRATIONDONE)
            {
                // The previously requested calibration has finished
                UINT32 lpsRate;
                UINT32 lpsRateAdjust;
                UINT32 NbSysClocks = hwp_tcu->LPS_SF_Sys_Count;

                // Get the measured rate
                if (LP_FRAC_NB_BITS < g_halLpsCtx.lpsAccuracy)
                {
                    lpsRate = NbSysClocks >> (g_halLpsCtx.lpsAccuracy - LP_FRAC_NB_BITS);
                }
                else 
                {
                    lpsRate = NbSysClocks << (LP_FRAC_NB_BITS - g_halLpsCtx.lpsAccuracy);
                }


                // adjust rate to the clock frequency of last calibration
                if (g_halLpsCtx.calibFreq == g_halLpsCtx.calibFreqLast)
                {
                    lpsRateAdjust = lpsRate;
                }
                else if (g_halLpsCtx.calibFreqLast != 0)
                {
                    UINT32 factor = hal_LpsClockToFactor(g_halLpsCtx.calibFreq);
                    UINT32 factorLast = hal_LpsClockToFactor(g_halLpsCtx.calibFreqLast);
                    lpsRateAdjust = (lpsRate * factor) / factorLast;
                }
                else
                {
                    // will be different as last rate is HAL_LPS_UNDEF_VALUE
                    lpsRateAdjust = lpsRate;
                }

                
                // only validate calibration when 2 measures returns the same value
                // allow measure error of 4 clocks (at g_halLpsCtx.calibFreqLast)
                if ( (lpsRateAdjust<g_halLpsCtx.lpsRateLast)
                    ?((g_halLpsCtx.lpsRateLast-lpsRateAdjust)<=4)
                    :((lpsRateAdjust-g_halLpsCtx.lpsRateLast)<=4) ) 
                {
                    // We measured comparable values 2 times in a row, save the result
                    // this makes the calibrated value legal
                    g_halLpsCtx.lpsRate = lpsRate;
                    g_halLpsCtx.lpsRateLast = lpsRate;
                    g_halLpsCtx.calibFreqLast = g_halLpsCtx.calibFreq;
                    
   
                    HAL_TRACE(HAL_LPS_TRC, 0, g__hal_LpsCalibrate__TRACE_STABLE , g_halLpsCtx.lpsRate);
    
                    // disable LPS SM - Keep the SF_ENABLE bit on if it was already enabled
                    hwp_tcu->LPS_SF_Ctrl &= ~TCU_LPS_SF_LOWPOWER_MASK;
                    g_halLpsCtx.lpsState=HAL_LPS_CALIBRATED;
                    // Exit the CALIB RUNNING Window
                    HAL_PROFILE_WINDOW_EXIT(CALIB_RUNNING);
                    // As the calib value is now valid - enter the CALIB_VALID window
                    HAL_PROFILE_WINDOW_ENTER(CALIB_VALID);
            
                } else 
                {
                    // The value is different from previous measurments - we can not consider it valid yet
                    HAL_TRACE(HAL_LPS_TRC, 0, g__hal_LpsCalibrate__TRACE_END, lpsRate);
                    // save the last measured rate
                    g_halLpsCtx.lpsRateLast = lpsRate;
                    g_halLpsCtx.calibFreqLast = g_halLpsCtx.calibFreq;
                    // disable LPS SM - Keep the SF_ENABLE bit on if it was already enabled
                    hwp_tcu->LPS_SF_Ctrl &= ~TCU_LPS_SF_LOWPOWER_MASK;
                    g_halLpsCtx.lpsState=HAL_LPS_IDLE;
                    // Exit the CALIB RUNNING Window
                    HAL_PROFILE_WINDOW_EXIT(CALIB_RUNNING);
                }
            } else
Beispiel #12
0
PROTECTED VOID hal_KeyIrqHandler(UINT8 interruptId)
{
    // interrupt status
    UINT32 status;
    // Keys pressed a the time of the interrupt
    HAL_KEY_MATRIX_T scannedKeys;
    // On-Off key state at the time of the interrupt
    BOOL scannedOnOff;
    
    // Variables to store the state of the different keys
    HAL_KEY_MATRIX_T downKeys;
    HAL_KEY_MATRIX_T upKeys;
    HAL_KEY_MATRIX_T pressedKeys;
    BOOL ExpKeyDet = FALSE;

    status = hwp_keypad->KP_IRQ_CAUSE &
        (KEYPAD_KP_EVT0_IRQ_CAUSE|KEYPAD_KP_EVT1_IRQ_CAUSE|KEYPAD_KP_ITV_IRQ_CAUSE) ;

    // Clear IRQ
    hwp_keypad->KP_IRQ_CLR = KEYPAD_KP_IRQ_CLR;


    if ((status & KEYPAD_KP_EVT0_IRQ_CAUSE) || (status & KEYPAD_KP_ITV_IRQ_CAUSE))
    {
        hal_KeySingleScan(scannedKeys);
        if (scannedKeys[0] == COL0_PATTERN)
        {
            g_expKey[0] = 0;
            ExpKeyDet = TRUE;
        }
        else if (scannedKeys[0] == COL1_PATTERN)
        {
            g_expKey[0] = 1;
            ExpKeyDet = TRUE;
        }
        else if (scannedKeys[0] == COL2_PATTERN)
        {
            g_expKey[0] = 2;
            ExpKeyDet = TRUE;
        }
        else if (scannedKeys[0] == COL3_PATTERN)
        {
            g_expKey[0] = 3;
            ExpKeyDet = TRUE;
        }
        else if (scannedKeys[0] == COL4_PATTERN)
        {
            g_expKey[0] = 4;
            ExpKeyDet = TRUE;
        }
        else if (scannedKeys[0] == COL5_PATTERN)
        {
            g_expKey[0] = 5;
            ExpKeyDet = TRUE;
        }
        else
        {
            ExpKeyDet = FALSE;
        }
    }
    if (status & KEYPAD_KP_EVT1_IRQ_CAUSE)
    {
        if (g_ExpKeyPressed)
        {
            HAL_TRACE(HAL_IO_TRC, 0, "HAL_KEY: Key Up -> Finish Exp Key config");
            hwp_keypad->KP_CTRL = g_kpCtrlReg | KEYPAD_KP_ITV_TIME(g_kpItvReg) | KEYPAD_KP_DBN_TIME(g_kpdbReg);
            g_ItvTimeShort = FALSE;
            g_ExpKeyPressed = FALSE;
            g_kpItvCnt = 0;

            if (g_RowToDisable == 6)
            {
                g_RowToDisable = 7;
            }
            else
            {
                g_RowToDisable = 6;
            }

            hal_ExpKeyCallHandler(g_expKey, HAL_KEY_UP);
            // Reset KeyOut6 & 7 to '1'
            hal_GpioSet(g_keyOut6);
            hal_GpioSet(g_keyOut7);
        }
    }
    if (!ExpKeyDet)
    {
        // All keys are released
        if ((status & KEYPAD_KP_EVT1_IRQ_CAUSE) && g_eventOnUp)
        {
            pressedKeys[0] = 0;
            pressedKeys[1] = 0;
            scannedOnOff = FALSE;

            // All previously pressed keys are released
            hal_KeyCallHandler(g_previousKeys, HAL_KEY_UP);

            // on-off button
            if (g_previousOnOff)
            {
                g_keyIrqHandler(255, HAL_KEY_UP);
            }
            
            // Keep track of the pressed buttons.
            g_previousKeys[0] = pressedKeys[0];
            g_previousKeys[1] = pressedKeys[1];
            g_previousOnOff   = scannedOnOff;
        }

        else
        
        {
        // Key up or down
            if (status &  KEYPAD_KP_EVT0_IRQ_CAUSE)
            {
                
                hal_KeySingleScan(scannedKeys);
                scannedOnOff = hal_KeyOnOffStateGet();

                // Send the ***pressed events*** only if user requested it.
                if (g_eventOnPressed && NULL != g_keyIrqHandler)
                {
                    // Pressed key detection
                    // Those are the one previously pressed and still pressed now
                    pressedKeys[0] = (scannedKeys[0] & g_previousKeys[0]);
                    pressedKeys[1] = (scannedKeys[1] & g_previousKeys[1]);
                
                    hal_KeyCallHandler(pressedKeys, HAL_KEY_PRESSED);
                    // on-off button
                    if (g_previousOnOff & scannedOnOff)
                    {
                        g_keyIrqHandler(255, HAL_KEY_PRESSED);
                    }

                }
                
                // If the pressed buttons changed.
                if (scannedKeys[0] != g_previousKeys[0] ||
                    scannedKeys[1] != g_previousKeys[1] ||
                    scannedOnOff   != g_previousOnOff)
                {
                    // Send the ***down events*** only if user requested it.
                    if (g_eventOnDown && NULL != g_keyIrqHandler)
                    {
                        // Key that are now pressed but weren't before
                        downKeys[0] = scannedKeys[0] & ~g_previousKeys[0];
                        downKeys[1] = scannedKeys[1] & ~g_previousKeys[1];

                        // low and high keys
                        hal_KeyCallHandler(downKeys, HAL_KEY_DOWN);
                        
                        // on-off button
                        if (~g_previousOnOff & scannedOnOff)
                        {
                            g_keyIrqHandler(255, HAL_KEY_DOWN);
                        }
                    }

                    // Send the ***up events*** only if user requested it.
                    if (g_eventOnUp && NULL != g_keyIrqHandler)
                    {
                        // Keys that are now unpressed but were pressed before
                        upKeys[0] = ~scannedKeys[0] & g_previousKeys[0];
                        upKeys[1] = ~scannedKeys[1] & g_previousKeys[1];

                        // low and high keys
                        hal_KeyCallHandler(upKeys, HAL_KEY_UP);

                        // on-off key
                        if (g_previousOnOff & ~scannedOnOff)
                        {
                            g_keyIrqHandler(255, HAL_KEY_UP);
                        }
                    }

                    // Keep track of the pressed buttons.
                    g_previousKeys[0] = scannedKeys[0];
                    g_previousKeys[1] = scannedKeys[1];
                    g_previousOnOff   = scannedOnOff;
                }
            }
            else
            {
                // There are only already pressed keys 
                // still pressed, so no change in pressed keys
                // and no need for a new scan
                if ((status & KEYPAD_KP_ITV_IRQ_CAUSE) && g_eventOnPressed)
                {
                    hal_KeyCallHandler(g_previousKeys, HAL_KEY_PRESSED);
                    // on-off button
                    if (g_previousOnOff)
                    {
                        g_keyIrqHandler(255, HAL_KEY_PRESSED);
                    }
                }
            }
        }
    }
    else // Expand Key
    {
        if (status & KEYPAD_KP_EVT0_IRQ_CAUSE)
        {
            hwp_keypad->KP_CTRL = g_kpCtrlReg | KEYPAD_KP_ITV_TIME(0) | KEYPAD_KP_DBN_TIME(1);
            g_ItvTimeShort = TRUE;
            HAL_TRACE(HAL_IO_TRC, 0, "HAL_KEY: COL_DET");
            if (g_RowToDisable == 6)
            {
                hal_GpioClr(g_keyOut6);
            }
            else
            {
                hal_GpioClr(g_keyOut7);
            }
            g_ExpKeyPressed = TRUE;
        }
        if (status & KEYPAD_KP_ITV_IRQ_CAUSE)
        {
            if (g_ItvTimeShort)
            {
                hwp_keypad->KP_CTRL = g_kpCtrlReg | KEYPAD_KP_ITV_TIME(g_kpItvReg) | KEYPAD_KP_DBN_TIME(g_kpdbReg);
                g_ItvTimeShort=FALSE;
                if (g_RowToDisable == 6)
                {
                    // Row 6 is disabled, so exp key is on row 7
                    g_expKey[1] = 1;
                    HAL_TRACE(HAL_IO_TRC, 0, "HAL_KEY: Key Down 7");
                }
                else
                {
                    // Row 7 is disabled, so exp key is on row 6
                    g_expKey[1] = 0;
                    HAL_TRACE(HAL_IO_TRC, 0, "HAL_KEY: Key Down 6");
                }
                hal_ExpKeyCallHandler(g_expKey, HAL_KEY_DOWN);
            }
            else
            {
                if (g_RowToDisable == 6)
                {
                    // Row 6 is disabled, so exp key is on row 7
                    g_expKey[1] = 1;
                    HAL_TRACE(HAL_IO_TRC, 0, "HAL_KEY: Key Pressed 7");
                }
                else
                {
                    // Row 7 is disabled, so exp key is on row 6
                    g_expKey[1] = 0;
                    HAL_TRACE(HAL_IO_TRC, 0, "HAL_KEY: Key Pressed 6");
                }
                if (g_kpItvCnt)
                {
                    hal_ExpKeyCallHandler(g_expKey, HAL_KEY_PRESSED);
                }
                g_kpItvCnt++;
            }
        }
    }
}
Beispiel #13
0
// =============================================================================
// hal_TimeWdRecover
// -----------------------------------------------------------------------------
// Called early in the boot process when watchdog occured, so running in the memory
// context when the WDog occured. Displays the watchdog context.
// =============================================================================
PUBLIC VOID hal_TimeWdRecover(VOID)
{
    HAL_PROFILE_PULSE(XCPU_ERROR);
    hal_DbgFatalTrigger(HAL_DBG_EXL_FATAL);
    if (g_bootResetCause & SYS_CTRL_WATCHDOG_RESET_HAPPENED)
    {
        HAL_DBG_ERROR_CTX_T *errCtx = &(g_halWatchdogCtx.errorContext);

        // WatchDog detected
        // Do not clear watchdog bit or hal_TimWatchDogHappened wont work
        // anyway it is not required to clear it as other reset cause clears it:
        //  - full soft reset clears it
        //  - external hardware reset clears it
        // hwp_reg->sys_rst_clr = WD_HAPPENED;
        HAL_TRACE(_PAL|TSTDOUT, 0,"########################");
        HAL_TRACE(_PAL|TSTDOUT, 0,"WATCH DOG RESET DETECTED\n");
        HAL_TRACE(_PAL|TSTDOUT, 0,"Registers:");
        HAL_TRACE(_PAL|TSTDOUT, 0,"ze=0x00000000  at=0x%08X  v0=0x%08X  v1=0x%08X",
            errCtx->at, errCtx->v0, errCtx->v1);
        HAL_TRACE(_PAL|TSTDOUT, 0,"a0=0x%08X  a1=0x%08X  a2=0x%08X  a3=0x%08X",
            errCtx->a0, errCtx->a1,
            errCtx->a2, errCtx->a3);
        HAL_TRACE(_PAL|TSTDOUT, 0,"t0=0x%08X  t1=0x%08X  t2=0x%08X  t3=0x%08X",
            errCtx->t0, errCtx->t1,
            errCtx->t2, errCtx->t3);
        HAL_TRACE(_PAL|TSTDOUT, 0,"t4=0x%08X  t5=0x%08X  t6=0x%08X  t7=0x%08X",
            errCtx->t4, errCtx->t5,
            errCtx->t6, errCtx->t7);
        HAL_TRACE(_PAL|TSTDOUT, 0,"s0=0x%08X  s1=0x%08X  s2=0x%08X  s3=0x%08X",
            errCtx->s0, errCtx->s1,
            errCtx->s2, errCtx->s3);
        HAL_TRACE(_PAL|TSTDOUT, 0,"s4=0x%08X  s5=0x%08X  s6=0x%08X  s7=0x%08X",
            errCtx->s4, errCtx->s5,
            errCtx->s6, errCtx->s7);
        HAL_TRACE(_PAL|TSTDOUT, 0,"t8=0x%08X  t9=0x%08X  k0= < N/A >    k1=0x%08X",
            errCtx->t8, errCtx->t9, errCtx->k1);
        HAL_TRACE(_PAL|TSTDOUT, 0,"gp=0x%08X  sp=0x%08X  fp=0x%08X  ra=0x%08X",
            errCtx->gp, errCtx->sp,
            errCtx->fp, errCtx->ra);

        HAL_TRACE(_PAL|TSTDOUT, 0,"PC when WDog occured : 0x%08X" , errCtx->pc | 0x80000000);
        
        sxs_BackTrace(errCtx->pc | 0x80000000, (UINT32*)errCtx->sp);
        
        sxs_Boot -> WDog = TRUE;
//      sxs_Boot -> ExceptionExpected = TRUE;
//      sxs_Boot -> ExceptionCount++;
        sxs_SaveRmtBuffer ();
    }
}