mirror of
https://github.com/ApacheThunder/nCard_USB_Examples.git
synced 2025-06-19 03:35:35 -04:00

* 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.
83 lines
1.1 KiB
C
83 lines
1.1 KiB
C
#include "usbhw.h"
|
|
#include "usbcore.h"
|
|
#include "usbuser.h"
|
|
#include "hiduser.h"
|
|
#include <stdio.h>
|
|
|
|
/* USB Endpoint Events Callback Pointers */
|
|
void (* const USB_P_EP[USB_EP_NUM/2]) (BYTE event) = {
|
|
USB_EndPoint0,
|
|
USB_EndPoint1,
|
|
USB_EndPoint2,
|
|
};
|
|
|
|
void USB_Configure_Event (void)
|
|
{
|
|
if (USB_Configuration)
|
|
{
|
|
GetInReport();
|
|
USB_WriteEP(0x81, InReport, 3);
|
|
}
|
|
}
|
|
|
|
void USB_EndPoint1 (BYTE event)
|
|
{
|
|
switch (event)
|
|
{
|
|
case USB_EVT_IN:
|
|
GetInReport();
|
|
USB_WriteEP(0x81, InReport, 3);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void USB_EndPoint2 (BYTE event)
|
|
{
|
|
}
|
|
|
|
|
|
u16 USB_IF=0;
|
|
void USB_ISR()
|
|
{
|
|
USB_IF|=D14_IF;
|
|
D14_IF=USB_IF;
|
|
|
|
if(USB_IF&D14_IF_BRST)
|
|
{
|
|
USB_Reset();
|
|
USB_IF&=~D14_IF_BRST;
|
|
}
|
|
|
|
if(USB_IF&D14_IF_SUSP)
|
|
{
|
|
USB_Suspend();
|
|
USB_IF&=~D14_IF_SUSP;
|
|
}
|
|
|
|
if(USB_IF&D14_IF_EP0SETUP)
|
|
{
|
|
USB_P_EP[0](USB_EVT_SETUP);
|
|
USB_IF&=~D14_IE_EP0SETUP;
|
|
}
|
|
|
|
if(USB_IF&D14_IF_EP0OUT)
|
|
{
|
|
USB_P_EP[0](USB_EVT_OUT);
|
|
USB_IF&=~D14_IF_EP0OUT;
|
|
}
|
|
|
|
if(USB_IF&D14_IF_EP0IN)
|
|
{
|
|
USB_P_EP[0](USB_EVT_IN);
|
|
USB_IF&=~D14_IF_EP0IN;
|
|
}
|
|
|
|
if(USB_IF&D14_IF_EP1IN)
|
|
{
|
|
USB_P_EP[1](USB_EVT_IN);
|
|
USB_IF&=~D14_IF_EP1IN;
|
|
}
|
|
}
|
|
|
|
//end of file
|