📄 usb_a.c
字号:
//===================================================================//
// Project Name : MOTOROLA-PDIUSBD12 USB-MCS CARD
// Module Name : Master Firmware Program
// Product Type : License
// OS/Dev Tool : CodeWarrior Development Studio for HC(S)08 Microcontrollers
// Original Author : Ming Zeng
// Organization : Tsinghua University , DEP
// Original Date : Feb, 20, 2003
// Addr : Tsinghua University, Beijing City
// TEL :
// EMail : ming@zming.net
// Website : http://www.zming.net
// Copyright : Copyright ZMing.net, 2003
// Comments :
//
//
//===================================================================//
#include "COMMON.H"
#include "USB.H"
#include "USBD12.H"
#include "CHAP9.H"
#include "VDOR.H"
#include "HAL.H"
extern COMMONFLAGS bCOMMONFlags;
//*************************************************************************
// Public static data
//*************************************************************************
////////////////
// Functions
/////////////////
void USB_Suspend_Change(void)
{
}
void USB_Stall_EP0(void)
{
USBD12_SetEndpointStatus(0, 1);
USBD12_SetEndpointStatus(1, 1);
}
void USB_Disconnect(void)
{
INTSCR |= 0x02; //关闭int中断
// Initialize D12 configuration
USBD12_SetMode(USBD12_NOLAZYCLOCK | USBD12_CLOCKRUNNING,
USBD12_SETTOONE | USBD12_CLOCK_12M);
}
void USB_Connect(void)
{
// reset event flags
bCOMMONFlags.nValue = 0;
USBD12_SetEndpointStatus(4, 0);
USBD12_SetEndpointStatus(5, 0);
USBD12_SetDMA(USBD12_ENDP4INTENABLE | USBD12_ENDP5INTENABLE);
// Initialize D12 configuration
USBD12_SetMode(USBD12_NOLAZYCLOCK | USBD12_CLOCKRUNNING | USBD12_SOFTCONNECT, USBD12_SETTOONE | USBD12_CLOCK_12M);
INTSCR &= 0xfd; //打开int中断 // EX0 = 1;
}
void USB_Reconnect(void)
{
int i;
bCOMMONFlags.bits.bIN_ISR = 1;
USB_ClearAllInts();
USB_Disconnect();
Delay(0xff);
for (i=0;i<6;i++)
{
DelayMs(250);
}
USB_Connect();
bCOMMONFlags.bits.bIN_ISR = 0;
}
void USB_Init_Unconfig(void)
{
USBD12_SetEndpointEnable(0); /* Disable all endpoints but EPP0. */
}
void USB_Init_Config(void)
{
USBD12_SetEndpointEnable(1); /* Enable generic/iso endpoints. */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -