nCard_USB_Examples/dspad/arm9/source/usbhal.c
ApacheThunder e5a90c1121 Add source code.
* Initial commit of modified source code.
* Arm7 for both apps appears to be some form of template arm7 setup.
Perhaps from the ancient version of libnds this used to use. I just used
the default arm7 template code from current version of libnds...seems to
do the job.
2023-10-21 23:41:46 -05:00

62 lines
779 B
C

#include "usbhal.h"
#ifdef ARM9
__inline
void usbwrcmd(u8 val) //D12写命令
{
//*(vu8*)(0x0A000000+val) = 0xFF;
*(vu16*)(0x09FFFFFE) = val;
}
__inline
void usbwrdat(u8 val) //D12写数据
{
//*(vu8*)(0x0A000000+val) = 0xFE;
*(vu16*)(0x09FDFFFE) = val;
}
__inline
u8 usbrddat() //D12读
{
//*(vu8*)(0x0A00FFFF) = 0xFE;
return *(vu16*)(0x09FDFFFE);
}
u16 usbreadid()
{
u16 id=0;
usbwrcmd(0xFD);
id=usbrddat();
id|=(u16)usbrddat()<<8;
return id;
}
#else
void usbwrcmd(u8 val) //D12写命令
{
*(vu8*)(0x08020000) = val;
}
void usbwrdat(u8 val) //D12写数据
{
*(vu8*)(0x08000000) = val;
}
u8 usbrddat() //D12读
{
return *(vu8*)(0x08000000);
}
u16 usbreadid()
{
u16 id=0;
usbwrcmd(0xFD);
id=usbrddat();
id|=(u16)usbrddat()<<8;
return id;
}
#endif