Пример #1
0
//---------------------------------------------------------------------------------
void VblankHandler(void) {
//---------------------------------------------------------------------------------

    u32 i;
    uint8 ct[sizeof(IPC->time.curtime)];

    //sound code  :)
    TransferSound *snd = IPC->soundData;
    IPC->soundData = 0;

    rtcGetTime((uint8 *)ct);
    BCDToInteger((uint8 *)&(ct[1]), 7);

    for(i=0; i<sizeof(ct); i++) {
        IPC->time.curtime[i] = ct[i];
    }

    if (0 != snd) {

        for (i=0; i<snd->count; i++) {
            s32 chan = getFreeSoundChannel();

            if (chan >= 0) {
                startSound(snd->data[i].rate, snd->data[i].data, snd->data[i].len, chan, snd->data[i].vol, snd->data[i].pan, snd->data[i].format);
            }
        }
    }
    Wifi_Update(); // update wireless in vblank
}
Пример #2
0
int main()
{
	readUserSettings();
	ledBlink(0);

	irqInit();
	initClockIRQ();
	fifoInit();

	SetYtrigger(80);

	installWifiFIFO();
	//installSoundFIFO();
	installSystemFIFO();
	installFeOSFIFO();

	coopIrqSet(IRQ_VCOUNT, VCountHandler);

	irqEnable(IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);

	setPowerButtonCB(powerButtonCB);

	while (!exitflag)
	{
		coopWaitForVBlank();
		FeOS_VBlankFunc();
		if (!(REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R)))
			break;
		Wifi_Update();
	}
	return 0;
}
Пример #3
0
//---------------------------------------------------------------------------------
void VblankHandler(void) {
//---------------------------------------------------------------------------------	
#ifdef USE_WIFI
	Wifi_Update(); // update wireless in vblank
#endif
#ifdef IPC_IN_VBLANK
	handle_ipc();
#endif

	if (arm7_initialised)
		refresh_channel_status();
}
Пример #4
0
void PA_VBL(void){
//  static int heartbeat = 0;
   s32 batt=0;// aux=0;
    int t1=0, t2=0;
    uint32 temp=0;
    uint8 ct[sizeof(IPC->time.curtime)];

    // Update the heartbeat
 //   heartbeat++;
 
    // Read the X/Y buttons and the /PENIRQ line
 /*   but = REG_KEYXY;
    if (!(but & 0x40)) {   //
		PA_UpdateStylus();  // If IPC set correctly
    }*/

    batt = touchRead(TSC_MEASURE_BATTERY);
    
    // Read the time
    rtcGetTimeAndDate((uint8 *)ct);
    //BCDToInteger((uint8 *)&(ct[1]), 7);
    memmove(ct+1, ct, 7);
 
    // Read the temperature
    temp = touchReadTemperature(&t1, &t2);
//    IPC->heartbeat = heartbeat;
  //  IPC->buttons   = but;
    IPC->battery   = batt;
    
    u32 i;
    for(i=0; i<sizeof(ct); i++) {
      IPC->time.curtime[i] = ct[i];
    }

    IPC->temperature = temp;
    IPC->tdiode1 = t1;
    IPC->tdiode2 = t2;
	
	if (PA_NewSPI != (IPC->aux)){
		PA_NewSPI = IPC->aux;
		PA_ScreenLight(); // Update the screen lights...
		//IPC->aux = touchRead(TSC_MEASURE_AUX); // update IPC with new values
	}
			
	SndVblIrq();	// DekuTree64's version
	
	
	PA_IPCManage(); // PAlib IPC functions (sound busy, panning, etc...)
	
	Wifi_Update();
}
Пример #5
0
//---------------------------------------------------------------------------------
void VblankHandler(void) 
{
    static int lastbut = -1;
    
    uint16 but=0, x=0, y=0, xpx=0, ypx=0, z1=0, z2=0;
    uint16 batt=0, aux=0;

    but = REG_KEYXY;

    if (!( (but ^ lastbut) & (1<<6))) {
 
        tempPos = touchReadXY();

        if ( tempPos.x == 0 || tempPos.y == 0 ) {
            but |= (1 <<6);
            lastbut = but;
        } else {
            x = tempPos.x;
            y = tempPos.y;
            xpx = tempPos.px;
            ypx = tempPos.py;
            z1 = tempPos.z1;
            z2 = tempPos.z2;
        }
        
    } else {
        lastbut = but;
        but |= (1 <<6);
    }

    batt = touchRead(TSC_MEASURE_BATTERY);
    aux  = touchRead(TSC_MEASURE_AUX);

    IPC->touchX         = x;
    IPC->touchY         = y;
    IPC->touchXpx       = xpx;
    IPC->touchYpx       = ypx;
    IPC->touchZ1        = z1;
    IPC->touchZ2        = z2;
    IPC->buttons        = but;
    IPC->battery        = batt;
    IPC->aux            = aux;

#ifdef WIFI
	Wifi_Update(); // update wireless in vblank
#endif
}
Пример #6
0
void PA_VBL() {
   s32 batt=0;
    int t1=0, t2=0;
    uint32 temp=0;
    uint8 ct[sizeof(IPC->time.curtime)];

    batt = touchRead(TSC_MEASURE_BATTERY);
    
    // Read the time
    PA_rtcGetTime((uint8 *)ct);
    BCDToInteger((uint8 *)&(ct[1]), 7);
 
    // Read the temperature
    temp = touchReadTemperature(&t1, &t2);
    IPC->battery   = batt;
    
    u32 i;
    for(i=0; i<sizeof(ct); i++) {
      IPC->time.curtime[i] = ct[i];
    }

    IPC->temperature = temp;
    IPC->tdiode1 = t1;
    IPC->tdiode2 = t2;
	
	if (PA_NewSPI != (IPC->aux)){
		PA_NewSPI = IPC->aux;
		PA_ScreenLight(); // Update the screen lights...
	}
	
	AS_SoundVBL();	// Update AS_Lib
	
	PA_IPCManage(); // PAlib IPC functions (sound busy, panning, etc...)
	
	Wifi_Update();
}
Пример #7
0
void VblankHandler(void)
{
	u32 i;

	//sound code  :)
	TransferSound *snd = IPC->soundData;
	IPC->soundData = 0;

	if(0 != snd)
	{
		for(i=0; i<snd->count; i++)
		{
			s32 chan = getFreeSoundChannel();

			if(chan >= 0)
			{
				startSound(snd->data[i].rate, snd->data[i].data, snd->data[i].len, chan, snd->data[i].vol, snd->data[i].pan, snd->data[i].format);
			}
		}
	}

	CommandProcessCommands();
	Wifi_Update();
}
Пример #8
0
void wardriving_loop()
{
	int num_aps, i, index, flags, pressed;
	touchPosition touchXY;
	Wifi_AccessPoint cur_ap;
	u32 lasttick;
	char state, display_state;
	/* Vars for AP_DISPLAY */
	int entry_n;
	struct AP_HT_Entry *entry = NULL;

	print_to_debug("Setting scan mode...");

	Wifi_ScanMode();
	state = STATE_SCANNING;
	display_state = STATE_CONNECTING;

	for (i = 0; i < 3; i++) {
		sizes[i] = DEFAULT_ALLOC_SIZE;
		num[i] = num_null[i] = 0;
		first_null[i] = -1;
		ap[i] = (struct AP_HT_Entry **)
		    malloc(sizes[i] * sizeof(struct AP_HT_Entry *));
		if (ap[i] == NULL)
			abort_msg("alloc failed");
	}

	flags = DISP_WPA | DISP_OPN | DISP_WEP;
	memset(modes, 0, sizeof(modes));
	strcpy(modes, "OPN+WEP+WPA");

	index = 0;

	TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1024;
	TIMER1_CR = TIMER_ENABLE | TIMER_CASCADE;
	lasttick = tick();

	while (1) {
		switch (state) {
		case STATE_SCANNING:
			curtick = tick();

			/* Wait for VBL just before key handling and redraw */
			swiWaitForVBlank();
			scanKeys();
			pressed = keysDown();

			/* Handle stylus press to display more detailed infos 
			 * handle this before AP insertion, to avoid race
			 * conditions */
			if (pressed & KEY_TOUCH) {
				touchRead(&touchXY);
				/* Entry number : 8 pixels for text, 3 lines */
				entry_n = touchXY.py / 8 / 3;
				entry = cur_entries[entry_n];
#ifdef DEBUG
				printf_to_debug("Entry : Y : %d\n", entry_n);
				printf_to_debug("SSID : %s\n", entry->ap->ssid);
#endif
				if (entry) {
					state = STATE_AP_DISPLAY;
					//display_state = STATE_PACKET_INIT;
					display_state = STATE_CONNECTING;
					print_to_debug("Packet scan mode");
					print_to_debug(" A : try to connect");
					print_to_debug(" B : back to scan");
					break;
				}
			}

			num_aps = Wifi_GetNumAP();
			for (i = 0; i < num_aps; i++) {
				if (Wifi_GetAPData(i, &cur_ap) !=
				    WIFI_RETURN_OK)
					continue;
				insert_ap(&cur_ap);
			}

			/* Check timeouts every second */
			if (timeout && (curtick - lasttick > 1000)) {
				lasttick = tick();
				clean_timeouts(lasttick);
			}

			if (pressed & KEY_RIGHT)
				timeout += 5000;
			if (pressed & KEY_LEFT && timeout > 0)
				timeout -= 5000;

			if (pressed & KEY_DOWN)
				index++;
			if (pressed & KEY_UP && index > 0)
				index--;
			if (pressed & KEY_R
			    && (index + (DISPLAY_LINES - 1)) <= numap)
				index += DISPLAY_LINES - 1;
			if (pressed & KEY_L && index >= DISPLAY_LINES - 1)
				index -= DISPLAY_LINES - 1;

			if (pressed & KEY_B)
				flags ^= DISP_OPN;
			if (pressed & KEY_A)
				flags ^= DISP_WEP;
			if (pressed & KEY_X)
				flags ^= DISP_WPA;

			/* Update modes string */
			if (pressed & KEY_B || pressed & KEY_A
			    || pressed & KEY_X) {
				modes[0] = 0;
				if (flags & DISP_OPN)
					strcat(modes, "OPN+");
				if (flags & DISP_WEP)
					strcat(modes, "WEP+");
				if (flags & DISP_WPA)
					strcat(modes, "WPA+");
				modes[strlen(modes) - 1] = 0;	/* remove the + */
			}

			display_list(index, flags);
			break;

		case STATE_AP_DISPLAY:
			switch (display_state) {
			case STATE_CONNECTING:
				/* TODO:
				 * 1) default to packet display
				 * 2) try DHCP [DONE]
				 * 3) try default IPs
				 * 4) handle WEP ?
				 */
				/* Try to connect */
				if (!(entry->ap->flags & WFLAG_APDATA_WPA) &&
				    !(entry->ap->flags & WFLAG_APDATA_WEP)) {
					print_to_debug
					    ("Trying to connect to :");
					print_to_debug(entry->ap->ssid);
					if (entry->ap->rssi <= 40)
						print_to_debug
						    ("Warning : weak signal");
					print_to_debug("Press B to cancel");
					switch (connect_ap(entry->ap)) {
					case ASSOCSTATUS_ASSOCIATED:
						display_state =
						    STATE_CONNECTED_FIRST;
						break;

					default:
						print_to_debug("Cnx failed");
						state = STATE_SCANNING;
						Wifi_ScanMode();
					}
				} else {
					print_to_debug
					    ("WEP/WPA AP not supported");
					state = STATE_SCANNING;
					break;
				}
				break;

			case STATE_CONNECTED_FIRST:
				display_ap(entry->ap, 1);
				display_state = STATE_CONNECTED;
				break;

			case STATE_CONNECTED:
				display_ap(entry->ap, 0);
				break;

			case STATE_PACKET_INIT:
				memcpy(mac_filter, entry->ap->macaddr, 6);
				Wifi_SetChannel(entry->ap->channel);
				Wifi_RawSetPacketHandler(cap_handler);
				Wifi_SetPromiscuousMode(1);
				display_state = STATE_PACKET;
				break;

			case STATE_PACKET:
				Wifi_Update();
				if (valid_packet)
					print_to_debug("Un paquet !\n");
				else
					print_to_debug("No paquet !\n");
				break;
			}

			scanKeys();
			if (keysDown() & KEY_A && state == STATE_PACKET) {
				state = STATE_CONNECTING;
			}
			if (keysDown() & KEY_B) {
				print_to_debug("Back to scan mode");
				state = STATE_SCANNING;
				Wifi_RawSetPacketHandler(NULL);
				Wifi_SetPromiscuousMode(0);
				Wifi_ScanMode();
			}
			swiWaitForVBlank();
			break;
		}
	}
}
Пример #9
0
//---------------------------------------------------------------------------------
void VblankHandler(void) {
//---------------------------------------------------------------------------------
	Wifi_Update();
}
Пример #10
0
void vblank_irq_handler()
{
    Wifi_Update();
}
Пример #11
0
void IRQ_VBlank(void)
{
    Wifi_Update();
}