⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smartmed.h

📁 用ST92163开发的鼠标
💻 H
字号:
/*-*-*-*-*-*-*-*-*-*-* (C) 2000 STMicroelectronics *-*-*-*-*-*-*-*-*-*-*-*-*-*

PROJECT  : ST92163 USB Mass Storage Class - Bulk-Only
COMPILER : ST9 C

MODULE  :  smartmed.h
VERSION :  V 4.0

CREATION DATE :  19/09/2000

AUTHOR : Microcontroller Division - ePI BU Application Lab
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

DESCRIPTION : SmartMedia Card interface routines
			  Refer to a smartmedia card datasheet for signal
			  description.

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

MODIFICATIONS :

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

#ifndef	_SMARTMEDIA_H_
#define	_SMARTMEDIA_H_

#define SMALL_READ		// To speed up the playback
#define ECC
#define LOOKUP
#define USE_LED

/* Exported Macros -------------------------------------------- */


/* CONTROL SIGNALS DEFINITION & ROUTINES */

#define SMedia_RB  0x10		/* Ready/Busy P5.4*/
#define SMedia_WP  0x04		/* Write Protect P4.2 */

/* Commands definition */

#define	DATA_INPUT		   	0x80
#define READ_MODE_1			0x00
#define READ_MODE_2			0x01
#define READ_MODE_3			0x50
#define RESET				0xFF
#define AUTO_PROG			0x10
#define AUTO_BLOCK_ERASE	0x60
#define	ERASE_CONFIRM		0xD0
#define STATUS_READ			0x70
#define	ID_READ				0x90


//#define LVX_READ	{ spp(0); WCR = 0x7F; P1DR |= 0x80;}
//#define LVX_WRITE	{ spp(0); WCR = 0x7F; P1DR &= 0x7F;}

//#define LVX_READ	{ spp(0); WCR = 0x7A; P1DR |= 0x80;}
//#define LVX_WRITE	{ spp(0); WCR = 0x7A; P1DR &= 0x7F;}

//#define LVX_READ	{ spp(0); WCR = 0x78; P1DR |= 0x80;}
//#define LVX_WRITE	{ spp(0); WCR = 0x78; P1DR &= 0x7F;}

#define LVX_READ	{ ;}
#define LVX_WRITE	{ ;}

#define wDATA_PORT	((volatile BYTE*)0xBE00)
#define wCMD_PORT	((volatile BYTE*)0xBE01)
#define wADDR_PORT	((volatile BYTE*)0xBE02)
#define rDATA_PORT	((volatile BYTE*)0xBF00)
#define wByte(Byte)	{ LVX_WRITE ; *wDATA_PORT = Byte; }
#define rByte()			(*(BYTE *) 0x8000 = *rDATA_PORT)
#define wAddr(Byte)	{ LVX_WRITE ; *wADDR_PORT = Byte; }
#define wCmd(Byte)	{ LVX_WRITE ; *wCMD_PORT = Byte; }

#define SMC_ON		{ BYTE dummy; asm("di"); LVX_READ ; dummy = rByte(); }
//#define SMC_OFF		{ BYTE dummy; LVX_READ; dummy = *((volatile BYTE*)0xA000); asm("ei"); P1DR &= 0x7F; }
#define SMC_OFF		{ LVX_READ ; asm("ei");}

#define	SM_WaitFree()	while((P5DR & SMedia_RB)==0)
#define SM_Reset()	{ wCmd(RESET);	SM_WaitFree(); }

#define SMCCHK			1	// Bit number
#define SMC_WRITE_PROTECT	(!(P4DR & SMedia_WP))

//			Support up to 64MB
// Since we are using pl_Flag to mark the translation, this number can not large than 16
#define CHAIN_NUMBER	16

/* Exported Variables -------------------------------------------- */
#define	Format_Flags	PageOffset

/* Exported Functions -------------------------------------------- */
void SM_Card_Format();
void Format_Procedure();

void SM_Init();
BYTE SM_ReadID();
BYTE SM_Read_Capacity(BYTE* pCapacity);
void SM_Read(BYTE Length);
void SM_Write();
void SM_Erase( );

WORD FindFree();

WORD LogicalToPhysical();

WORD SM_Write_Data10(void);
BYTE SM_Write_Block(BYTE* Buffer);
void Write_PreCopy();
void Write_PostCopy();
WORD SM_Read_Data10(void);
BYTE SM_Read_Block(BYTE* Buffer);

extern void SM_Media_Release_SenseData(BYTE* Sense_Buffer);

#ifdef PLAYBACK
void Cluster_Chain(DWORD* Chain);
void Translate_Chain_Once(BYTE BlocksPerCluster);
void Translate_Chain_Step();
void PlayBack_Read_Data10(BYTE* Buffer);
void Read_ONE_Block(BYTE* Buffer);
BYTE Read_Block_Now(BYTE *Buffer);
#ifdef	SMALL_READ
void SM_Read_Word(WORD Column, BYTE *Buffer);
#endif
#endif


// Flags for the Media_Flags
#define BLOCK_FREE		0x01		// writing a brand new block
#define BLOCK_DIRTY		0x02		// writing some pages to a existing block
#define BLOCK_OVERWRT	0x03		// over-writing a existing block

#endif /* #ifndef _SMARTMEDIA_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -