コード例 #1
0
ファイル: arm7_main.cpp プロジェクト: EQ4/LittleGPTracker
int main(int argc, char **argv)
{
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR ;
    
    u32 old_reg = readPowerManagement(PM_CONTROL_REG);
    writePowerManagement(PM_CONTROL_REG, old_reg |PM_LED_ON); // enable fast
    
	// Reset the clock if needed
	rtcReset();

	// Turn on Sound
	powerON(POWER_SOUND);

	// Set up sound defaults.
	SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
	IPC->soundData = 0;

	// Set up the interrupt handler
	irqInit();
	irqSet(IRQ_VBLANK, VblankHandler);
	irqEnable(IRQ_VBLANK);

     // Setup FIFO
     
 	irqSet(IRQ_FIFO_NOT_EMPTY,FifoInterruptHandler);
	irqEnable(IRQ_FIFO_NOT_EMPTY);     
    REG_IPC_FIFO_CR =  IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ ;
    
	// Keep the ARM7 out of main RAM
	while (1)
		swiWaitForVBlank();
	
	return 0;
}
コード例 #2
0
ファイル: arm7_main.c プロジェクト: erdincay/svsip
void InterruptHandler_IPC_SYNC(void) 
{
    u8 sync;

    sync = IPC_GetSync();

    {
        int oldval, newval;
        
        newval = oldval = readPowerManagement(PM_CONTROL_REG);

        if(sync == IPC2_REQUEST_SET_BACKLIGHTS_OFF)
            newval = oldval & ~PM_BACKLIGHT_TOP & ~PM_BACKLIGHT_BOTTOM;

        else if(sync == IPC2_REQUEST_SET_BACKLIGHTS_ON)
            newval = oldval | PM_BACKLIGHT_TOP | PM_BACKLIGHT_BOTTOM;

        else if(sync == IPC2_REQUEST_LEDBLINK_OFF)
            newval = oldval & ~PM_LED_BLINK;

        else if(sync == IPC2_REQUEST_LEDBLINK_ON)
            newval = oldval | PM_LED_BLINK;

        writePowerManagement(PM_CONTROL_REG, newval);
    }
}
コード例 #3
0
ファイル: NeoSystem7.c プロジェクト: Leerz/NeoDS
static void neoBacklightOn()
{
	u32 enabled = REG_IME;
	REG_IME = 0;
	u32 value = readPowerManagement(PM_CONTROL_REG);
	writePowerManagement(PM_CONTROL_REG, value | PM_BACKLIGHT_BOTTOM);
	REG_IME = enabled;
}
コード例 #4
0
ファイル: NeoSystem7.c プロジェクト: Leerz/NeoDS
static void neoLidClose()
{
	u32 enabled = REG_IME;
	REG_IME = 0;
	const u32 powerValue = readPowerManagement(PM_CONTROL_REG);
	u32 value = powerValue;
	value &= ~(PM_BACKLIGHT_BOTTOM | PM_BACKLIGHT_TOP);
	value |= PM_LED_SLEEP;
	writePowerManagement(PM_CONTROL_REG, value);
	REG_IME = enabled;
	swiChangeSoundBias(0, 0x400); //speaker off
	neoAudioShutdown();

	//ack LIDCLOSE command
	neoIPCAckCommand();

	//wait for lid to open
	while(1) {
		swiWaitForVBlank();
		u32 command = neoIPCRecvCommand();
		if(command) {
			if(NEOIPC_GET_COMMAND(command) == NEOARM7_LIDOPEN) {
				break;
			} else {
				//ignore all commands (should not get any)
				neoIPCAckCommand();
			}
		}
	}

	enabled = REG_IME;
	REG_IME = 0;
	writePowerManagement(PM_CONTROL_REG, powerValue);
	REG_IME = enabled;
	swiChangeSoundBias(1, 0x400); //speaker on
	neoAudioReset();

	//ACK lid open command
	neoIPCAckCommand();
}
コード例 #5
0
void SoundEngine::soundOn()
{
    int pmReg;

    powerOn((PM_Bits) POWER_SOUND);

    pmReg = readPowerManagement(PM_CONTROL_REG);
    pmReg &= ~PM_SOUND_MUTE;
    pmReg |= PM_SOUND_AMP;
    writePowerManagement(PM_CONTROL_REG, pmReg);

    REG_SOUNDCNT = SOUND_ENABLE;
    REG_MASTER_VOLUME = 127;
}
コード例 #6
0
ファイル: main.cpp プロジェクト: halfbyte/nds-oscpad
//---------------------------------------------------------------------------------
int main(int argc, char ** argv) {
//---------------------------------------------------------------------------------
    // read User Settings from firmware
    readUserSettings();
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & prepare fifo asap
    rtcReset();

    //enable sound
    powerON(POWER_SOUND);
    writePowerManagement(PM_CONTROL_REG, ( readPowerManagement(PM_CONTROL_REG) & ~PM_SOUND_MUTE ) | PM_SOUND_AMP );
    SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);

    irqInit();

    // Start the RTC tracking IRQ
    initClockIRQ();

    SetYtrigger(80);
    irqSet(IRQ_VCOUNT, VcountHandler);
    irqSet(IRQ_VBLANK, VblankHandler);
    irqSet(IRQ_WIFI, Wifi_Interrupt); // set up wifi interrupt

    irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_WIFI);

    {   // sync with arm9 and init wifi
        u32 fifo_temp;

        while(1) { // wait for magic number
            while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
            fifo_temp=REG_IPC_FIFO_RX;
            if(fifo_temp==0x12345678) break;
        }
        while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
        fifo_temp=REG_IPC_FIFO_RX; // give next value to wifi_init
        Wifi_Init(fifo_temp);

        irqSet(IRQ_FIFO_NOT_EMPTY,arm7_fifo); // set up fifo irq
        irqEnable(IRQ_FIFO_NOT_EMPTY);
        REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

        Wifi_SetSyncHandler(arm7_synctoarm9); // allow wifi lib to notify arm9
    } // arm7 wifi init complete


    // Keep the ARM7 mostly idle
    while (1) swiWaitForVBlank();
}
コード例 #7
0
ファイル: interrupts.c プロジェクト: Nasty35/gbaemu4DS
//---------------------------------------------------------------------------------
void i2cIRQHandler() {
//---------------------------------------------------------------------------------
    int cause = (i2cReadRegister(I2C_PM, I2CREGPM_PWRIF) & 0x3) | (i2cReadRegister(I2C_GPIO, 0x02)<<2);

    switch (cause & 3) {
    case 1:
        if (__powerbuttonCB) {
            __powerbuttonCB();
        } else {
            i2cWriteRegister(I2C_PM, I2CREGPM_RESETFLAG, 1);
            i2cWriteRegister(I2C_PM, I2CREGPM_PWRCNT, 1);
        }
        break;
    case 2:
        writePowerManagement(PM_CONTROL_REG,PM_SYSTEM_PWR);
        break;
    }
}
コード例 #8
0
ファイル: main.c プロジェクト: ahezard/default-arm7
//---------------------------------------------------------------------------------
int main() {
//---------------------------------------------------------------------------------
	// clear sound registers
	dmaFillWords(0, (void*)0x04000400, 0x100);

	REG_SOUNDCNT |= SOUND_ENABLE;
	writePowerManagement(PM_CONTROL_REG, ( readPowerManagement(PM_CONTROL_REG) & ~PM_SOUND_MUTE ) | PM_SOUND_AMP );
	powerOn(POWER_SOUND);

	readUserSettings();
	ledBlink(0);

	irqInit();
	// Start the RTC tracking IRQ
	initClockIRQ();
	fifoInit();

	mmInstall(FIFO_MAXMOD);

	SetYtrigger(80);

	installWifiFIFO();
	installSoundFIFO();

	installSystemFIFO();

	irqSet(IRQ_VCOUNT, VcountHandler);
	irqSet(IRQ_VBLANK, VblankHandler);

	irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);

	setPowerButtonCB(powerButtonCB);

	// Keep the ARM7 mostly idle
	while (!exitflag) {
		if ( 0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R))) {
			exitflag = true;
		}
		swiWaitForVBlank();
	}
	return 0;
}
コード例 #9
0
ファイル: PA.c プロジェクト: troy56/palibds
void PA_SetDSLiteBrightness(u8 level){
	if (level > 3) level = 3;
    writePowerManagement(PM_DSLITE_REG, level);
}