usbd.c.svn-base

来自「usb drivers based on s3c2410」· SVN-BASE 代码 · 共 72 行

SVN-BASE
72
字号
/*
 * 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 + =
减小字号Ctrl + -
显示快捷键?