📄 main.c
字号:
/*
**********************************************************************************************
* Project: TK7821
* File: main.c
* Contents:
* The main and interrupt handler
*
* $Date: 02/25/05 Jason v0.1
* 04/21/05 Mingo v0.2 www.fameg.com
* 06/24/05 Mingo v0.3
*
* Copyright (c) 2005 Fameg, Inc. All rights reserved
***********************************************************************************************
*/
#include <reg51.h>
#include <stdlib.h>
#include "Device.h"
#include "UsbDisk.h"
xdata UINT16 DelayTimer = 0;
//----------------------------------------------------------------------------
// Timeout every 10 ms
//----------------------------------------------------------------------------
void Timer0() interrupt 1 using 3
{
// Restore the counter to 10 ms
TH0 = 0xCE;
TL0 = 0xE8;
// Inc the system tick
if (DelayTimer)
DelayTimer --;
}
//----------------------------------------------------------------------------
void main()
{
TH1 = 0xF8; // For 15MHz CPU Clock
TH0 = 0xCE;
TL0 = 0xE8;
TMOD = 0x21;
TCON = 0x50;
IP = 0x02;
IE = 0x82;
CSRWrite(USB_BASE + GCTL, CSRRead(USB_BASE + GCTL) | DISCONNECT);
Delay(300);
CSRWrite(USB_BASE + GCTL, CSRRead(USB_BASE + GCTL) | RESET); //0xF000,General control register
POWER_LED_CTRL = 0;
UsbInit();
while (true)
{
BYTE Event;
Event = CSRRead(USB_BASE + EPIE); //0xF001,EP interrupt event 1 register
if (Event)
{
if (Event & (IRQ_RX0 | IRQ_TX0 | IRQ_IN0))
UsbCtrlIntHandler(Event);
if (Event & IRQ_RX2)
{
UsbBulkIntHandler(Event);
}
}
if(POWER_LED_CTRL)
POWER_LED_CTRL = FALSE; //亮
else
POWER_LED_CTRL = TRUE;
Delay(50);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -