void InitTimer0(void(*handler)()) { //Disable Timer0 T0TCR &= ~BIT_0; //Configure Interrupt Register T0IR = BIT_0; //Configure Count Control Register T0CTCR = 0; //Configure Prescale Counter Register T0PC = 0; //Configure Prescale Counter Register //15000000 - 1Hz //1500000 - 10Hz //150000 - 100Hz //15000 - 1kHz //5Hz T0MR0 = 3000000; //Configure Match Control Register T0MCR = (BIT_0 | BIT_1); timer0_handler = handler; InstallIRQ( TIMER0_INT, (void *)TimerHandler0, 0x03 ); }
static void mouse_init( void ) { //CursorDeviceCustomButtonUPP func = NewCursorDeviceCustomButtonUPP( custom_butclick ); UInt32 mouse_dpi; CLEAR( m ); DNeedTime_Init(); m.cursDev = &m.cursorDeviceInfo; CursorDeviceNewDevice( &m.cursDev ); CursorDeviceSetAcceleration( m.cursDev, (Fixed)(1<<16) ); CursorDeviceSetButtons( m.cursDev, 3); CursorDeviceButtonOp( m.cursDev, 0, kButtonSingleClick, 0L ); CursorDeviceButtonOp( m.cursDev, 1, kButtonDoubleClick, 0L ); CursorDeviceButtonOp( m.cursDev, 2, kButtonDoubleClick, 0L ); //CursorDeviceButtonOp( m.cursDev, 2, kButtonCustom, (long)func ); mouse_dpi = OSI_MouseCntrl( kMouseGetDPI ); CursorDeviceUnitsPerInch( m.cursDev, (Fixed)((Fixed)(mouse_dpi<<16)) ); if( InstallIRQ( &GLOBAL.deviceEntry, hard_irq, &m.irq_info ) ) { lprintf("Mouse: Can't install irq!\n"); return; } OSI_MouseCntrl1( kMouseRouteIRQ, m.irq_info.aapl_int ); lprintf( "Mouse Driver v1.0\n" ); }
OSStatus InstallIRQ_NT( char *name, char *type, InterruptHandler handler, IRQInfo *info ) { RegEntryID re; OSStatus status; RegistryEntryIDInit( &re ); if( !NRFindNode( name, type, &re ) ) { RegistryEntryIDDispose( &re ); lprintf("Failed to find node %s!\n", name); return 1; } status = InstallIRQ( &re, handler, info ); RegistryEntryIDDispose( &re ); if( status ) { lprintf("InstallIRQ_NT returned %d\n", status ); } return status; }