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

📄 fw.c

📁 SdCard_V2.1TinyFatFs.rar是单片机实现SD卡功能的FAT文件系统
💻 C
字号:
/*
**********************************************************************************************
* Project:	FS7805 SD CARD READER
* File:		main.c
* Contents: 
*           The main function is SD and MMC card reader.
*
* $Date: 12/15/06    Derek    V1.0  
*  
* Coments: This is the SD/MMC card reader firmware.
*		   When read sector,the 512 pingpong FIFO mechanism
*		   is used to improve performance.But when write sector,
*		   only single FIFO is used.
*
* Copyright (c) 2006 Fameg, Inc. All rights reserved
*
* 
***********************************************************************************************
*/
#include "include\Include.h"
/*
*********************************************************************************************************
*                                       VARIABLE PROTOTYPES
*********************************************************************************************************
*/
extern  BOOL Rwuen, Selfpwr;
/*
*********************************************************************************************************
*                                       FUNCTION PROTOTYPES
*********************************************************************************************************
*/
	void  UsbInit (void);
  void  KsocInit (void);

/*
*********************************************************************************************************
*                                             TDINIT
*
* Description: Task Dispatcher hooks function
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  TdInit (void)
{	
   
     
  //  UsbInit();
    KsocInit();

    EA          = TRUE;                         // Enable All interrupt
}
/*$PAGE*/


/*
*********************************************************************************************************
*                                             SFIINIT
*
* Description: SlaveFIFO initialization function
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  KsocInit (void)
{
    SFI_EPCFG   = SFI_EPCFG & (~bmAUTO);               // Auto or Manual
}
/*$PAGE*/

/*
*********************************************************************************************************
*                                             McuInit
*
* Description: MCU initialization function
*			   
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void McuInit()
{
	SYS_CFG		= SYS_CFG|bmSYS_SW_RST;//软复位
	SYS_CFG		= 0x03|bmPM_AVBLE; ////00:15M,01:40M,02:30M,03:60M
	WDTRST		= 0x2D; 				//停止WDT
	MEMCON		= 0x00; 				//配置4k xdata区
	DMA_CTL2	= DMA_CTL2|bmCNFLICT_EN; //	
	CKCON 		= 0x01;   			// Cycle configuration--在60MHz的情况下,不宜过快。会造成不稳定。
								//保证CPU_CLOCK/CKCON < USB_CLOCK(30MHz)
	SYSIO_CFG	= SYSIO_CFG|bmSD_EN; //使能SDMI接口
	SDMI_CTL   |= bmSD_CLK_40;//
}
/*
*********************************************************************************************************
*                                          Timer0Init
*
* Description: timer0 initialization.
*			   10ms interrupt cycle.
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void Timer0Init()
{
//	TH0 = 0x9E; //0x9E58,CPU 30M定时10ms
//	TL0 = 0x58;
    TH0         = 0x3C;                                // 0x3CB0, CPU 60MHz, 10ms
    TL0         = 0xB0;

	TMOD = 0x21;
	TCON = 0x50;
	IP = 0x02;
	IE = 0x82;
}

⌨️ 快捷键说明

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