Exemple #1
0
void wifi_init()
{
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR;

    /*
     * Our half of the ARM7 Wifi handshaking:
     * Send it a pointer to the shared memory area for Wifi.
     */
    REG_IPC_FIFO_TX = IPC_MSG_WIFI_INIT;
    REG_IPC_FIFO_TX = Wifi_Init(WIFIINIT_OPTION_USELED);

    /* Disable TIMER3 before setting up its IRQ handler */
    TIMER3_CR = 0;

    irqInit(); 
    irqSet(IRQ_VBLANK, vblank_irq_handler);
    irqEnable(IRQ_VBLANK);
    irqSet(IRQ_TIMER3, wifi_timer_handler);
    irqEnable(IRQ_TIMER3);
    irqSet(IRQ_FIFO_NOT_EMPTY, fifo_irq_handler);
    irqEnable(IRQ_FIFO_NOT_EMPTY);

    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;
    Wifi_SetSyncHandler(wifi_sync_handler);

    /* Program TIMER3 for 50ms intervals */
    TIMER3_DATA = TIMER_FREQ_256(1000 / WIFI_TIMER_MS);
    TIMER3_CR = TIMER_DIV_256 | TIMER_IRQ_REQ;

    /* Poll for the ARM7 init to finish */
    while (!Wifi_CheckInit()) {
	swiWaitForVBlank();
    }
}
Exemple #2
0
static void setupTimer0(void)
{
	tpl_disable_interrupts();
	TIMER0_DATA = TIMER_FREQ_256(1000); /* 1ms */
	TIMER0_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_256;
	irqSet(IRQ_TIMER0, tpl_tick_timer0_overflow);
	irqEnable(IRQ_TIMER0);
}
Exemple #3
0
 void Scheduler::Start(int timer =2, const float resolutionSeconds=0.01)
{
	nowMillis = 0;
	resolutionMillis = resolutionSeconds *100;
	busy = false;
	timerStart(0, ClockDivider_256 , TIMER_FREQ_256(resolutionSeconds), timerCallback);
	taskQueue = new Task*[MAX_QUEUED_TASKS];
	capacity = MAX_QUEUED_TASKS;
	poolMax =0;

	for(int i =0; i< capacity; i++)
	{
		taskQueue[i] = nullptr;
	}
}
Exemple #4
0
bool videoStart(const char* file)
{
	vramSetBankB(VRAM_B_LCD);
	vramSetBankC(VRAM_C_LCD);
//	videoSetMode(MODE_FB1);

	if(videoPlaying) return false;
	
	videoFile = fopen(file, "rb");
	if (videoFile == NULL) return false;

	timerStart(3, ClockDivider_256, TIMER_FREQ_256(20), videoTick);
	videoFrames = 0;
	videoPlaying = true;
	vramBank = false;
	return true;
}
Exemple #5
0
//---------------------------------------------------------------------------------
int main(int argc, char ** argv) {
//---------------------------------------------------------------------------------
	readUserSettings();
	
	irqInit();
	initClockIRQ();
	fifoInit();
	
	SetYtrigger(80);
#ifdef USE_WIFI
	installWifiFIFO();
#endif
	//installSoundFIFO();
	installSystemFIFO();

 	//TIMER_CR(0) = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_1;

	vcount = 80;
	irqSet(IRQ_VBLANK, VblankHandler);
	irqSet(IRQ_VCOUNT, VcountHandler);
	irqSet(IRQ_HBLANK, hblank_handler);

	irqEnable(IRQ_VBLANK | IRQ_VCOUNT | IRQ_HBLANK);
	
	setPowerButtonCB(powerButtonCB);   
	
	fifoSetDatamsgHandler(FIFO_9to7, fifo_DataHandler, 0);

//	irqSet(IRQ_LID, lid);
//	irqEnable(IRQ_LID);
	
#ifdef IPC_IN_TIMER
	irqSet(IRQ_TIMER0, handle_ipc);
	TIMER_DATA(0) = TIMER_FREQ_256(20 * 60);
 	TIMER_CR(0) = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_256;
#endif
	
#ifdef USE_WIFI
#ifndef WIFI_ON_DEMAND
	wifi_go();
#endif
#endif

#ifdef USE_ADHOC
	IPC_Init() ;
	LWIFI_Init() ;
#endif
	
	// Keep the ARM7 idle
	while (!exitflag)
	{
		//ARM7_PRINT("arm7 ");
		if ( 0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R))) {
			exitflag = true;
		}
#ifdef USE_ADHOC
		LWIFI_IPC_UpdateNOIRQ() ;
#endif
		if (do_mp3 != 0)
		{
#ifdef USE_MP3
			ds_enable_interrupts(0);
			if (helix_initialised == 0)
			{
				ARM7_PRINT("beginning helix init\n");
				helix_init();
				ARM7_PRINT("helix init done\n");
				
				helix_initialised = 1;
			}
			
			char helix_argv1[100];
			char helix_argv2[100];
			memset(helix_argv1, 0, 100);
			memset(helix_argv2, 0, 100);
			strcpy(helix_argv1, "/jones.mp3");
//			sprintf(helix_argv1, "/quake soundtrack/0%d-AudioTrack 0%d.mp3", mp3_track_no, mp3_track_no);
//			strcpy(helix_argv2, "/jones.pcm");
			
			char *proper_helix_argv[3];
			proper_helix_argv[0] = NULL;
			proper_helix_argv[1] = helix_argv1;
//			proper_helix_argv[1] = (char *)track_name;
			proper_helix_argv[2] = helix_argv2;
			
			ARM7_PRINT("Starting Helix...\n");
			decoder_stopped = 0;
			
			ds_enable_interrupts(1);		
			helix_main(3, proper_helix_argv);
			ds_enable_interrupts(0);
			
			decoder_stopped = 1;
			ARM7_PRINT("out of helix\n");
//			ARM7_HALT();
			send_mp3_stop_message();
			
			ds_enable_interrupts(1);
#endif
		}

//		if (REG_KEYXY & (1 << 7))
//		{
//			while (quake_ipc_7to9->message == 0xffffffff);
//			
//			quake_ipc_7to9->message_type = kLidHasClosed;
//			quake_ipc_7to9->message = 0xffffffff;
//			
//			while (quake_ipc_7to9->message == 0xffffffff);
//			
//			ARM7_PRINT("ARM7: waiting...\n");
//			while (REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY);
//			ARM7_PRINT("ARM7: disabling interrupts\n");
//			
//			irqDisable(IRQ_HBLANK);
//			irqDisable(IRQ_VBLANK);
//			irqDisable(IRQ_VCOUNT);
//			
////			irqEnable(IRQ_LID);
//			
//			powerOFF(POWER_SOUND);
//			
//			swiWaitForVBlank();			//wake up when the lid re-enables the interrupt
//		}
		
		if (arm7_initialised && ((hblanks & 0x3f) == 0))
		{
			arm7_initialised = 1;
			//ARM7_PRINT("ping");
			//while (quake_ipc_7to9->message == 0xffffffff);
			
			//quake_ipc_7to9->message_type = kPing;
			//quake_ipc_7to9->message = 0xffffffff;
			//while (quake_ipc_7to9->message == 0xffffffff);
		}
			
//		int total = 0;
//		for (int count = 0 ; count < 16; count++)
//			if (!is_channel_enabled(count))
//				total++;
//		if (free_time == kFreeTime)
//			ARM7_PRINTF("%d channels free\n", total);
		
//		if (free_time == kFreeTime)
//			if (needs_defrag())
//			{
//				ARM7_PRINT("NEEDS DEFRAG\n");
//				defrag(&free_time);
//			}
		
//		swiWaitForVBlank();

#ifdef IPC_IN_MAIN_THREAD
		//handle_ipc();
#endif
//		if (arm7_initialised == true)
//		{
////			temp_test();
//			
//			arm7_initialised = false;
//			ARM7_PRINT("installing exception handler\n");
//			install();
//			register unsigned int sp asm ("13");
//			ARM7_PRINT("done\nlet\'s try and crash it\n");
//			/*ARM7_PRINT_NUMBER(sp);*/
//			
////			asm("LDR r12,=MyReg2\n"
////				"STMIA r12,{r0-r15}\n"
////					:
////					:
////					: "r12");
//			
////			ARM7_PRINT_NUMBER(MyReg2[12]);
//			
////			for (int count = 0; count < 16; count++)
////				ARM7_PRINT_NUMBER(MyReg2[count]);
////			ARM7_PRINT("\n");
////			while(1);
////			asm (".word 0xffffffff");
////			asm (".word 0x0");
//			
//			
////			Exception();
//	
////			asm (".word 0xe6000010");
//			
////			asm("LDR r12,=MyReg2\n"
////				"STMIA r12,{r0-r15}\n"
////					:
////					:
////					: "r12");
////			
////			for (int count = 0; count < 8; count++)
////			{
////				ARM7_PRINT_NUMBER(MyReg[count + 8]);
////				ARM7_PRINT_NUMBER(MyReg2[count + 8]);
////			}
//			
//			
////			asm ("mcr 15,0,r0,c0,c0,0");
////			asm ("bkpt");
////			*(int *)0 = 0;
////			asm ("b debugger_hit");
////			debugger_hit();
////			debugger_handle_breakpoint(0,0,0);
//			
////			asm (".word 0xe6000010");
////			asm (".short 0xe801");
//			ARM7_PRINT("shouldn\'t make it here\n");
//			ARM7_PRINT_NUMBER(ProperCPSR);
//			while(1);
//		}
		swiIntrWait(1, 1);
	}
}