#122713 - Phantaseur - Wed Mar 21, 2007 1:30 pm
I'm trying to catch a button pressing but for some reason irq processing function cannot be called.
I think the label ,,Key pressed'' have to appear after I press any button but it never appears. What's wrong in this code?
Code: |
#include <nds.h>
#include <stdio.h> void on_irq(); int main(void){ videoSetMode(0); videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankC(VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31,31,31); consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); printf("Waiting for keys\n"); REG_IME = 0; IRQ_HANDLER = on_irq; REG_IE = IRQ_KEYS; REG_IF = ~0; REG_IME = 1; while(1); return(0); } void on_irq(){ if(REG_IF&IRQ_KEYS){ printf("Key pressed\n"); VBLANK_INTR_WAIT_FLAGS |= IRQ_VBLANK; REG_IF |= IRQ_VBLANK; } } |
I think the label ,,Key pressed'' have to appear after I press any button but it never appears. What's wrong in this code?