📄 usbd.c.svn-base
字号:
/*
* usbd.c: implement USB device
*/
#include "config.h"
#include "frame.h"
#include "lib.h"
#include "usbd.h"
#ifdef _DEBUG
#include <stdio.h>
#endif /* _DEBUG */
static
void config_usbd()
{
PWR_REG = 0;
INDEX_REG = 0;
MAXP_REG = FIFO_SIZE_8;
EP0_CSR = EP0_SERVICED_OUT_PKT_RDY | EP0_SERVICED_SETUP_END;
USB_INT_REG = 0x07;
EP_INT_REG = 0x1f;
USB_INT_EN_REG = RESET_INT;
EP_INT_EN_REG = EP0_INT;
}
static void
usbd_isr(struct contextframe *cf, int irq)
{
unsigned char usb_int = USB_INT_REG;
unsigned char ep_int = EP_INT_REG;
#ifdef _DEBUG
printf("usbd_isr: ");
#endif /* _DEBUG */
if(usb_int & RESET_INT) {
#ifdef _DEBUG
printf("reset\n");
#endif /* _DEBUG */
config_usbd();
USB_INT_REG = RESET_INT;
}
if(ep_int & EP0_INT) {
#ifdef _DEBUG
printf("ep0\n");
#endif /* _DEBUG */
EP_INT_REG = EP0_INT;
}
}
void
init_usbd(void)
{
UPLLCON = (U_MDIV<<12)|(U_PDIV<<4)|U_SDIV;
config_usbd();
ivt[INT_USBD] = usbd_isr;
CLEAR_PENDING(INT_USBD);
INT_ENABLE(INT_USBD);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -