?? usbdisk.h
字號:
/*
**********************************************************************************************
* Project: TK7821
* File: UsbDisk.h
* Contents:
* The public definition header file
*
* $Date: 02/25/05 Jason v0.1
* 05/12/05 Mingo v0.2 www.fameg.com
*
* Copyright (c) 2005 Fameg, Inc. All rights reserved
***********************************************************************************************
*/
#ifndef UsbDiskH
#define UsbDiskH
#include "SotaType.h"
sfr STRETCH = 0x8f;
#if (defined(CTRL_SIMULATION) || defined(BULK_SIMULATION))
#define USB_SIMULATION
#endif
#ifndef USB_SIMULATION
#define PREFETCH
#ifdef READER
#define SD
#define PMOS
#endif
#endif
#if (defined(FLASH_DISK) || defined(SERIAL_FLASH))
#define INT_ROM
#endif
#ifdef PMOS
sbit SM_POWER_CTRL = P2^7;
sbit SD_POWER_CTRL = P2^6;
sbit MS_POWER_CTRL = P2^5;
#else
sbit CARD_POWER_CTRL = P2^7;
#endif
sbit POWER_LED_CTRL = P2^4;
#ifdef INT_ROM
#define ROM_UPGRADE
#endif
#ifdef SERIAL_FLASH
#define ROM_UPGRADE
#endif
#ifdef FLASH_DISK
#define FIRMWARE_ID 0x8210
#endif
#ifdef READER
#define FIRMWARE_ID 0x8228
#endif
#define FIRMWARE_VERSION 0x0253
//----------------------------------------------------------------------------
// Status code 0x00 ~ 0x3f for storage media
//----------------------------------------------------------------------------
#define STATUS_SUCCESS 0x00
#define STATUS_PARAM_ERROR 0x01
#define STATUS_FLASH_ERROR 0x02
#define STATUS_WRITE_PROTECT 0x03
#define STATUS_CIS_ERROR 0x04
#define STATUS_BLOCK_ERROR 0x05
#define STATUS_DATA_ERROR 0x06
#define STATUS_ECC_1ERROR 0x07
#define STATUS_ECC_2ERROR 0x08
#define STATUS_NO_BLOCK 0x09
#define STATUS_INVALID_BLOCK 0x0a
#define STATUS_NO_MEDIA 0x0b
#define STATUS_MEDIA_CHANGE 0x0c
#define STATUS_MEDIA_BUSY 0x0d
#define STATUS_AUTH_ERROR 0x0e
#define STATUS_CMD_ERROR 0x0f
//----------------------------------------------------------------------------
// Tool function declare
//----------------------------------------------------------------------------
UINT16 ConvertEndian16(UINT16 Src);
UINT32 ConvertEndian32(UINT32 Src);
bool EvenParity(UINT16 Data);
void Reset();
//----------------------------------------------------------------------------
// USB function declare
//----------------------------------------------------------------------------
void UsbInit();
void UsbCtrlIntHandler(BYTE IntEvent);
void UsbBulkIntHandler(BYTE IntEvent);
#define LoSpeed() STRETCH = 5
#define NormalSpeed() STRETCH = 3;
#define HiSpeed() STRETCH = 1
#define FifoClkUsb(Buffer)\
{\
if (Buffer == DMA_BUFFER0)\
CSRWrite(USB_BASE + FIFO_CLK_CTRL, CSRRead(USB_BASE + FIFO_CLK_CTRL) & ~FIFO0_CLK);\
else\
CSRWrite(USB_BASE + FIFO_CLK_CTRL, CSRRead(USB_BASE + FIFO_CLK_CTRL) & ~FIFO1_CLK);\
}
#define FifoClkCpu(Buffer)\
{\
if (Buffer == DMA_BUFFER0)\
CSRWrite(USB_BASE + FIFO_CLK_CTRL, CSRRead(USB_BASE + FIFO_CLK_CTRL) | FIFO0_CLK);\
else\
CSRWrite(USB_BASE + FIFO_CLK_CTRL, CSRRead(USB_BASE + FIFO_CLK_CTRL) | FIFO1_CLK);\
}
#define Fifo2ClkUsb() CSRWrite(USB_BASE + FIFO_CLK_CTRL, CSRRead(USB_BASE + FIFO_CLK_CTRL) & ~FIFO2_CLK)
#define Fifo2ClkCpu() CSRWrite(USB_BASE + FIFO_CLK_CTRL, CSRRead(USB_BASE + FIFO_CLK_CTRL) | FIFO2_CLK)
#define CSRRead(Addr) (*(volatile BYTE xdata *)(Addr))
#define CSRWrite(Addr, Data) (*(volatile BYTE xdata *)(Addr) = (Data))
#define cli() EA = 0
#define sti() EA = 1
#define ClearRegBit(Reg, BitMask) CSRWrite(Reg, (CSRRead(Reg) & BitMask))
#define Delay(Time)\
{\
DelayTimer = (Time)/10;\
while (DelayTimer);\
}
#define HwId() (((UINT16)CSRRead(USB_BASE + MAJOR_ID) << 8) | CSRRead(USB_BASE + MINOR_ID))
#define HwVersion() (((UINT16)CSRRead(USB_BASE + MAJOR_VERSION) << 8) | CSRRead(USB_BASE + MINOR_VERSION))
#define SOTA_MAGIC_NUM0 0x55
#define SOTA_MAGIC_NUM1 0xAA
extern bit ResetFlag;
extern xdata UINT16 DelayTimer;
extern xdata BYTE ClkIdx;
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -