mmcapp.c

来自「AVR典型实例.rar」· C语言 代码 · 共 60 行

C
60
字号
#define F_CPU 4000000UL
#include <avr\io.h>
#include <util\delay.h>
#include <stdio.h>
#include "mmc.h"
#include "lcd12864.h"

unsigned char sector[512];
int main(void)
{
    unsigned char tmp;
	unsigned char buf[10];
	unsigned int i;	
	DDRA=0xff;
	DDRC=0xff;
	DDRD=0xff;
	spi_init();
	init_lcd();
	clr_lcd();

	_delay_ms(100);
    MMCInit();


	while(1)
	{
    	// 测试1:将数据写入第255个扇区
		for(i=0; i<512; i++)
	   		sector[i]=0X88;

        SetRowCol(2,0);
		disp_str("输出"); 
		SetRowCol(2,33);
		if(MMCWrBlock1(0,sector))
		{
			disp_str("1");
		}else{
		    disp_str("0");
		}
		SetRowCol(3,0);
		disp_str("输入");
		SetRowCol(3,33);    
		// 测试2:将第1个扇区的数据读出
		if(MMCRdBolck1(0))
		{
		    disp_str("1");
		}else{
		    disp_str("0");
		}
		sprintf(buf,"%d %d",sector[0],sector[1]);
		SetRowCol(4,0);
		disp_str("数");
		SetRowCol(4,18);
		
		disp_str(buf);
	}
	return 0;

}

⌨️ 快捷键说明

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