#171972 - hounjini - Tue Jan 05, 2010 3:46 pm
Hi
I'm trying to make slot2 digital input / ouput.
I read this page(http://nocash.emubase.de/gbatek.htm#gbacartioportgpio)
,and trying to make it working.
Here is my code.
simple hello world code with output(void) function for setting register.
hardware : attached data lines to all slot2 pins and test with led.
thank you for reading my post.
Happy new year!
I'm trying to make slot2 digital input / ouput.
I read this page(http://nocash.emubase.de/gbatek.htm#gbacartioportgpio)
,and trying to make it working.
Here is my code.
Code: |
#include <nds.h> #include <stdio.h> #define REG_DIRECTION (*(vuint16*)0x080000C6) #define REG_DATA (*(vuint16*)0x080000C4) #define REG_CONTROL (*(uint16*)0x80000C8) volatile int frame = 0; void Vblank() { frame++; } bool output(void) { sysSetCartOwner(true); REG_CONTROL = REG_CONTROL & 0x0000; REG_CONTROL = REG_CONTROL | 0x0001; REG_DIRECTION = REG_DIRECTION & 0x0000; REG_DIRECTION = REG_DIRECTION | 0x000F; REG_DATA = REG_DATA & 0x0000; REG_DATA = REG_DATA | 0x000C; } int main(void) { touchPosition touchXY; irqSet(IRQ_VBLANK, Vblank); consoleDemoInit(); iprintf(" Hello DS dev'rs\n"); iprintf(" \x1b[32mwww.devkitpro.org\n"); iprintf(" \x1b[32;1mwww.drunkencoders.com\x1b[39m"); output(); while(1) { swiWaitForVBlank(); touchRead(&touchXY); iprintf("\x1b[10;0HFrame = %d",frame); iprintf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.rawx, touchXY.px); iprintf("Touch y = %04X, %04X\n", touchXY.rawy, touchXY.py); } return 0; } |
simple hello world code with output(void) function for setting register.
hardware : attached data lines to all slot2 pins and test with led.
thank you for reading my post.
Happy new year!