#106751 - HyperHacker - Mon Oct 23, 2006 5:15 am
I've been trying to use the hardware FIFO, but I ran into an odd problem. I can send however much I want to ARM7, but only the first thing sent to ARM9 is ever received.
Relevant code:
ARM7:
ARM9:
_________________
I'm a PSP hacker now, but I still <3 DS.
Relevant code:
ARM7:
Code: |
//Graphics Test ARM7 Code
#include "main.h" /* Entry Point CPU: ARM7 Inputs: -argc: Number of arguments -argv: Pointer to arguments Returns: Program return code */ int main(int argc, char** argv) { //Blank out IPC memzero((u8*)IPC,sizeof(IPC)); //Init interrupts REG_IME = 0; //Disable interrupts while changing them IRQ_HANDLER = Interrupt; //Set handler callback REG_IE = IRQ_VBLANK | IRQ_TIMER3 | IRQ_IPC_SYNC | IRQ_FIFO_NOT_EMPTY; REG_IF = ~0; DISP_SR = DISP_VBLANK_IRQ; REG_IME = 1; //Enable interrupts //Init IPC REG_IPC_SYNC = IPC_SYNC_IRQ_ENABLE; //Enable IRQs from ARM9 REG_IPC_FIFO_CR = IPC_FIFO_SEND_IRQ | IPC_FIFO_RECV_IRQ | IPC_FIFO_ENABLE; //Enable FIFO and interrupt on send FIFO empty/receive FIFO not empty REG_IPC_FIFO_TX = 420; //Init reload ability //LOADNDS->PATH = 0; //Init timers TIMER3_DATA = 65535 - 34318; //should be one interrupt every ~1ms TIMER3_CR = TIMER_ENABLE | TIMER_IRQ_REQ; swiWaitForVBlank(); swiWaitForVBlank(); swiWaitForVBlank(); REG_IPC_FIFO_TX = 1234; while(true) { IPC->keys = REG_KEYXY; //if((~REG_KEYXY) & 1) REG_IPC_FIFO_TX = 69; swiWaitForVBlank(); } return 0; } /* Interrupt handler CPU: ARM7 */ void Interrupt() { if(REG_IF & IRQ_VBLANK) { //if (LOADNDS->PATH != 0) LOADNDS->ARM7FUNC(LOADNDS->PATH); //Reload when singalled VBLANK_INTR_WAIT_FLAGS |= IRQ_VBLANK; //Signal that vblank interrupt has been processed REG_IF |= IRQ_VBLANK; } else if(REG_IF & IRQ_TIMER3) { IPC->tickcount++; VBLANK_INTR_WAIT_FLAGS |= IRQ_TIMER3; REG_IF |= IRQ_TIMER3; } else if(REG_IF & IRQ_FIFO_NOT_EMPTY) { IPC->temperature = REG_IPC_FIFO_RX; //testing IPC->a7_fifo_count++; VBLANK_INTR_WAIT_FLAGS |= IRQ_FIFO_NOT_EMPTY; REG_IF |= IRQ_FIFO_NOT_EMPTY; } else REG_IF = REG_IF; //Trigger a write } |
ARM9:
Code: |
//Graphics Test ARM9 Code
#include "main.h" /* Entry Point CPU: ARM9 Inputs: -argc: Number of arguments -argv: Pointer to arguments Returns: Program return code */ int main(int argc, char** argv) { powerON(POWER_ALL_2D); //Turn stuff on (required for some flash cards) //Init video videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE); vramSetMainBanks(VRAM_A_MAIN_BG_0x6000000, VRAM_B_MAIN_BG_0x6000000, VRAM_C_SUB_BG_0x6200000, VRAM_D_LCD); BG3_CR = BG_BMP16_256x256; BG3_XDX = 1 << 8; BG3_XDY = 0; BG3_YDX = 0; BG3_YDY = 1 << 8; BG3_CX = 0; BG3_CY = 0; SUB_BG3_CR = BG_BMP16_256x256; SUB_BG3_XDX = 1 << 8; SUB_BG3_XDY = 0; SUB_BG3_YDX = 0; SUB_BG3_YDY = 1 << 8; SUB_BG3_CX = 0; SUB_BG3_CY = 0; //Init interrupts REG_IME = 0; //Disable interrupts while changing them IRQ_HANDLER = Interrupt; //Set handler callback REG_IE = IRQ_VBLANK | IRQ_HBLANK | IRQ_IPC_SYNC | IRQ_FIFO_NOT_EMPTY; REG_IF = ~0; DISP_SR = DISP_VBLANK_IRQ | DISP_HBLANK_IRQ; REG_IME = 1; //Enable interrupts //Init IPC REG_IPC_SYNC = IPC_SYNC_IRQ_ENABLE; //Enable IRQs from ARM7 REG_IPC_FIFO_CR = IPC_FIFO_SEND_IRQ | IPC_FIFO_RECV_IRQ | IPC_FIFO_ENABLE; //Enable FIFO and interrupt on send FIFO empty/receive FIFO not empty REG_IPC_FIFO_TX = 1337; //Let things get set up swiWaitForVBlank(); swiWaitForVBlank(); swiWaitForVBlank(); sysSetBusOwners(true, true, true); //All to ARM9 REG_IPC_FIFO_TX = 5555; MainScreenBuf = CreateGraphicBuffer(SCREEN_WIDTH, SCREEN_HEIGHT); SubScreenBuf = CreateGraphicBuffer(SCREEN_WIDTH, SCREEN_HEIGHT); ClearGraphicBuffer(MainScreenBuf, RGB15(0, 0, 15) | 0x8000); ClearGraphicBuffer(SubScreenBuf, RGB15(0, 0, 0) | 0x8000); //FillRect(MainScreenBuf, 5, 100, 25, 25, RGB15(31, 31, 0)); while(true) { swiWaitForVBlank(); FillRect(MainScreenBuf, 5, 5, 100, 30, RGB15(0, 0, 15)); Print(MainScreenBuf, 0, 5, 5, "Msec=%d\nA7 FIFO=%d, %d\nA9 FIFO=%d, %d\nKey=%08X", IPC->tickcount, IPC->a7_fifo_count, IPC->temperature, IPC->a9_fifo_count, IPC->buttons_held, IPC->keys); } return 0; } /* Interrupt handler CPU: ARM9 */ void Interrupt() { /*if(REG_IF & IRQ_HBLANK) //HBlank interrupt { VBLANK_INTR_WAIT_FLAGS |= IRQ_HBLANK; REG_IF |= IRQ_HBLANK; } else */if(REG_IF & IRQ_VBLANK) //VBlank interrupt { FastCopy32(MainScreenBuf->Pixels, BG_GFX, (SCREEN_WIDTH * SCREEN_HEIGHT) * 2); FastCopy32(SubScreenBuf->Pixels, BG_GFX_SUB, (SCREEN_WIDTH * SCREEN_HEIGHT) * 2); //dmaCopy(MainScreenBuf->Pixels, BG_GFX, (SCREEN_WIDTH * SCREEN_HEIGHT) * 2); VBLANK_INTR_WAIT_FLAGS |= IRQ_VBLANK; //Signal that vblank interrupt has been processed REG_IF |= IRQ_VBLANK; //Signal that vblank interrupt processing is done. We need to trigger a write even though this shouldn't change the value. } else if(REG_IF & IRQ_FIFO_NOT_EMPTY) { IPC->buttons_held = REG_IPC_FIFO_RX; //testing IPC->a9_fifo_count++; VBLANK_INTR_WAIT_FLAGS |= IRQ_FIFO_NOT_EMPTY; REG_IF |= IRQ_FIFO_NOT_EMPTY; } else REG_IF = REG_IF; //Trigger a write } |
_________________
I'm a PSP hacker now, but I still <3 DS.