MP3播放器详细设计方案
源代码在线查看: mmc.h
/*H**************************************************************************
* $RCSfile: mmc.h,v $
*----------------------------------------------------------------------------
* Copyright (c) 2002 Atmel.
*----------------------------------------------------------------------------
* RELEASE: $Name: DEMO_FAT_1_9_9 $
* REVISION: $Revision: 1.7 $
* FILE_CVSID: $Id: mmc.h,v 1.7 2002/08/14 07:35:32 ffosse Exp $
*----------------------------------------------------------------------------
* PURPOSE:
* This file contains the high level MMC definitions
*****************************************************************************/
#ifndef _MMC_H_
#define _MMC_H_
/*_____ I N C L U D E S ____________________________________________________*/
#include "..\..\lib\mmc\mmc_drv.h" /* MMC driver definition */
/*_____ M A C R O S ________________________________________________________*/
/* Clock */
#define MMC_CLK_INIT ((FOSC / 400) - 1) /* 400 KHz */
#define MMC_CLK_TRANS ((FOSC / 8000) - 1) /* 8 MHz */
/* Card RCA */
#define MMC_NO_CARD ((Uint32)0x0000FFFF)
#define MMC_RCA_1 ((Uint32)0x0002FFFF)
#define MMC_RCA_2 ((Uint32)0x0003FFFF)
#define MMC_PAGE_MASK ((Byte)0x01)
/* Card Size based on 512 bytes block size */
#define MMC_SIZE_4MB ((Uint32)7872 - 1)
#define MMC_SIZE_8MB ((Uint32)15680 - 1)
#define MMC_SIZE_16MB ((Uint32)31360 - 1)
#define MMC_SIZE_28MB ((Uint32)54784 - 1)
#define MMC_SIZE_32MB ((Uint32)62720 - 1)
#define MMC_SIZE_64MB ((Uint32)125440 - 1)
#define MMC_SIZE_128MB ((Uint32)250880 - 1)
#define MMC_SIZE_256MB ((Uint32)501760 - 1)
#define MMC_4MB ((Byte)0)
#define MMC_8MB ((Byte)1)
#define MMC_16MB ((Byte)2)
#define MMC_28MB ((Byte)3)
#define MMC_32MB ((Byte)4)
#define MMC_64MB ((Byte)5)
#define MMC_128MB ((Byte)6)
#define MMC_256MB ((Byte)7)
/* Functions parameters & returns */
#define MMC_ERROR ((Byte)0)
#define MMC_OK ((Byte)1)
#define MMC_END ((Byte)0xFF)
#define MMC_CARD1 ((bit)0)
#define MMC_CARD2 ((bit)1)
/* Functions states */
#define MMC_FUNCT_START ((Byte)0) /* start state of all functions */
#define MMC_SINGLE_OP_COND MMC_FUNCT_START /* mmc_single_ack */
#define MMC_SINGLE_CID ((Byte)1)
#define MMC_SINGLE_SRA ((Byte)2)
#define MMC_SINGLE_CSD ((Byte)3)
#define MMC_SINGLE_END ((Byte)4)
#define MMC_STACK_OP_COND MMC_FUNCT_START /* mmc_update_acq */
#define MMC_STACK_CID ((Byte)1)
#define MMC_STACK_SRA ((Byte)2)
#define MMC_STACK_CSD ((Byte)3)
#define MMC_STACK_END ((Byte)4)
#define MMC_SETUP_SELECT MMC_FUNCT_START /* mmc_select_card */
#define MMC_SETUP_STATUS ((Byte)1)
#define MMC_STATUS_SEND MMC_FUNCT_START /* mmc_get_status */
#define MMC_STATUS_CHECK ((Byte)1)
#define MMC_MASS_BLOCK_SIZE ((Uint16)2048) /* mass storage block size */
#define MMC_RESPONSE_TIME ((Byte)15) /* 64 + 48 bits time_out */
#define MMC_RESP_TIME ((Byte)0xFE) /* 2 ticks time_out */
#define MMC_DATA_TIME ((Byte)0xFC) /* 4 ticks time_out */
#define MMC_TIME_OUT ((Byte)0x00)
/*_____ D E F I N I T I O N ________________________________________________*/
extern idata Uint32 mmc_mem_size;
/*_____ D E C L A R A T I O N ______________________________________________*/
/* System */
void mmc_init (void);
bit mmc_init_csd (void);
bit mmc_read_open (Uint32);
void mmc_read_close (void);
Byte mmc_read_byte (void);
bit mmc_read_sector (Uint16);
bit mmc_write_open (Uint32);
void mmc_write_close (void);
bit mmc_write_byte (Byte);
bit mmc_write_sector (Uint16);
s_format code * mmc_format (void);
#define Mmc_disk_size() ((Uint32)(mmc_mem_size))
#define Mmc_disk_size_0() (((Byte *)&mmc_mem_size)[0])
#define Mmc_disk_size_1() (((Byte *)&mmc_mem_size)[1])
#define Mmc_disk_size_2() (((Byte *)&mmc_mem_size)[2])
#define Mmc_disk_size_3() (((Byte *)&mmc_mem_size)[3])
#define Mmc_block_size() ((Uint32)512)
#define Mmc_block_size_0() ((Byte)(Mmc_block_size() >> 24))
#define Mmc_block_size_1() ((Byte)(Mmc_block_size() >> 16))
#define Mmc_block_size_2() ((Byte)(Mmc_block_size() >> 8))
#define Mmc_block_size_3() ((Byte)Mmc_block_size())
/* Control */
void mmc_init_stack (void);
void mmc_init_next (void);
Byte mmc_single_acq (void);
Byte mmc_update_acq (void);
Byte mmc_setup_card (bit);
bit mmc_check_presence (bit);
bit mmc_check_stack (void);
/* Data */
void mmc_init_data_mode (void);
#endif /* _MMC_H_ */