sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\personality\example\isr.cpp sl@0: // Test code for example RTOS personality. sl@0: // sl@0: // sl@0: sl@0: #include "plat_priv.h" sl@0: #include sl@0: sl@0: #if defined(__MAWD__) sl@0: #include sl@0: #elif defined(__MISA__) sl@0: #define __ISR_SUPPORTED__ sl@0: #include sl@0: #elif defined(__MCOT__) sl@0: #define __ISR_SUPPORTED__ sl@0: #include sl@0: #elif defined(__MI920__) || defined(__NI1136__) sl@0: #include sl@0: #elif defined(__EPOC32__) && defined(__CPU_X86) sl@0: #include sl@0: #endif sl@0: sl@0: #ifdef __ISR_SUPPORTED__ sl@0: #include "../../misc/prbs.h" sl@0: #endif sl@0: sl@0: extern "C" void stop_random_isr(void); sl@0: sl@0: typedef void (*isr_entry)(unsigned); sl@0: sl@0: volatile TUint RandomSeed[2] = {0xb504f333u, 0xf9de6484u}; sl@0: volatile isr_entry IsrVector = 0; sl@0: volatile TUint IsrCount = 0; sl@0: sl@0: void timer_isr(void*) sl@0: { sl@0: #if defined(__MISA__) sl@0: TUint interval = Random((TUint*)RandomSeed); sl@0: interval &= 0x3ff; sl@0: interval += 256; // 256-1279 ticks = approx 69 to 347 microseconds sl@0: TUint oscr=TSa1100::OstData(); sl@0: TSa1100::SetOstMatch(KHwOstMatchGeneral, oscr + interval); sl@0: TSa1100::SetOstMatchEOI(KHwOstMatchGeneral); sl@0: #elif defined(__MCOT__) sl@0: TUint interval = Random((TUint*)RandomSeed); sl@0: interval &= 0x3ff; sl@0: interval += 256; // 256-1279 ticks = approx 69 to 347 microseconds sl@0: TUint oscr=TCotulla::OstData(); sl@0: TCotulla::SetOstMatch(KHwOstMatchGeneral, oscr + interval); sl@0: TCotulla::SetOstMatchEOI(KHwOstMatchGeneral); sl@0: #endif sl@0: (*IsrVector)(IsrCount++); sl@0: } sl@0: sl@0: #ifdef __ISR_SUPPORTED__ sl@0: void start_timer(void) sl@0: { sl@0: #if defined(__MISA__) sl@0: // for SA11x0 use OST match 0 sl@0: TInt r=Interrupt::Bind(KIntIdOstMatchGeneral, &timer_isr, 0); sl@0: assert(r==KErrNone); sl@0: TSa1100::ModifyIntLevels(0,KHtIntsOstMatchGeneral); // route new timer interrupt to FIQ sl@0: TSa1100::SetOstMatchEOI(KHwOstMatchGeneral); sl@0: TUint oscr=TSa1100::OstData(); sl@0: TSa1100::SetOstMatch(KHwOstMatchGeneral, oscr + 5000); sl@0: TSa1100::EnableOstInterrupt(KHwOstMatchGeneral); sl@0: Interrupt::Enable(KIntIdOstMatchGeneral); sl@0: #elif defined(__MCOT__) sl@0: // for SA11x0 use OST match 0 sl@0: TInt r=Interrupt::Bind(KIntIdOstMatchGeneral, &timer_isr, 0); sl@0: assert(r==KErrNone); sl@0: TCotulla::ModifyIntLevels(0,KHtIntsOstMatchGeneral); // route new timer interrupt to FIQ sl@0: TCotulla::SetOstMatchEOI(KHwOstMatchGeneral); sl@0: TUint oscr=TCotulla::OstData(); sl@0: TCotulla::SetOstMatch(KHwOstMatchGeneral, oscr + 5000); sl@0: TCotulla::EnableOstInterrupt(KHwOstMatchGeneral); sl@0: Interrupt::Enable(KIntIdOstMatchGeneral); sl@0: #endif sl@0: } sl@0: #endif sl@0: sl@0: extern "C" int start_random_isr(isr_entry vector) sl@0: { sl@0: stop_random_isr(); sl@0: IsrVector = vector; sl@0: #ifdef __ISR_SUPPORTED__ sl@0: start_timer(); sl@0: return OK; sl@0: #else sl@0: return KErrNotSupported; sl@0: #endif sl@0: } sl@0: sl@0: extern "C" void stop_random_isr(void) sl@0: { sl@0: #if defined(__MISA__) sl@0: Interrupt::Disable(KIntIdOstMatchGeneral); sl@0: Interrupt::Unbind(KIntIdOstMatchGeneral); sl@0: #elif defined(__MCOT__) sl@0: Interrupt::Disable(KIntIdOstMatchGeneral); sl@0: Interrupt::Unbind(KIntIdOstMatchGeneral); sl@0: #endif sl@0: IsrVector = 0; sl@0: } sl@0: