?? main.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 "HAL.H"
#include "USBD12.H"
#include "COMMON.h"
#include "USB110.H"
#include "USB.H"
#include "CHAP9.H"
#include "VDOR.H"
extern unsigned char GenBuf[GENBUF_LENGH];
///////////////////////////////////
// Data definition
COMMONFLAGS bCOMMONFlags;
extern CONTROL_XFER ControlData;
extern CODE_DATA CodeData;
void Init_AD(void)
{
T1SC = 0x06;
ADCLK = 0x30;
}
void Init_Port(void)
{
PTA = 0x00;
PTC = 0xff;
DDRA = 0xff;
DDRC = 0xff;
}
void Init(void)
{
asm{
SEI
BSET 0,INTSCR
BSET 1,INTSCR
LDA #$01
STA CONFIG1
LDA #$3D
STA CONFIG2
CLR PCTL
MOV #$01,PCTL
MOV #$01,PMSH
MOV #$2C,PMSL
MOV #$80,PMRS
BSET 5,PCTL
BSET 7,PBWC
BSET 4,PCTL
LDA #$02
STA SCBR
BSET 6,SCC1
BSET 3,SCC2
BSET 2,SCC2
LDA #$00
STA BRKSCR
LDA #$10
STA SBSR
LDA #$80
STA SBFCR
}
}
/*------------------------------------------------
The main C function. Program execution starts
here after stack initialization.
------------------------------------------------*/
void main (void)
{ int i;
Init();
Init_Port();
Init_AD();
for (i=0;i<256;i+=1)
{
GenBuf[i] = 0;
}
bCOMMONFlags.bits.bRun = RUN_STOP;
CodeData.bCodeCount = 1;
USB_Reconnect();
EnableInterrupts;
INTSCR &= 0xfd; //打開int中斷
////////////////////////
/* Main program loop */
////////////////////////
while(TRUE)
{
if (bCOMMONFlags.bits.bUSB_Busy)
{
ISRx_FN_USB();//對D12的USB處理
} // if USB_Busy
if (bCOMMONFlags.bits.bBus_Reset)
{
DisableInterrupts;
bCOMMONFlags.bits.bBus_Reset = 0;
EnableInterrupts;// Release D12's SUSPEND pin after bus reset
PTC |= 0x08; //置D12SUSPD為1
} // if bus reset
if (bCOMMONFlags.bits.bSuspend)
{
DisableInterrupts;
bCOMMONFlags.bits.bSuspend= 0;
EnableInterrupts;
} // if suspend change
if (bCOMMONFlags.bits.bSetup_Packet)
{
DisableInterrupts;
bCOMMONFlags.bits.bSetup_Packet = 0;
EnableInterrupts;
USB_Control_Handler();
PTC |= 0x08; //置D12SUSPD為1
} // if setup_packet
} // Main Loop
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -