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

📄 main.c

📁 Read MMC No SPI AT91SAM7S256
💻 C
字号:
/******************************************************************************/
/* HELLO.C: Hello World Example                                               */
/******************************************************************************/
/* This file is part of the uVision/ARM development tools.                    */
/* Copyright (c) 2005-2006 Keil Software. All rights reserved.                */
/* This software may only be used under the terms of a valid, current,        */
/* end user licence from KEIL for a compatible version of KEIL software       */
/* development tools. Nothing else gives you the right to use this software.  */
/******************************************************************************/

#include <stdio.h>                          /* I/O Functions */
#include <AT91SAM7S256.H>                    /* AT91SAM7S256 definitions */
#include "mmc.h"
#include "system.h"
#include "Board.h"	
#include "string.h"

char wr_buffer[512]={0};
char rd_buffer[512]={0};
	  

AT91S_PIO * pPIO = AT91C_BASE_PIOA;         /* Global Pointer to PIO */	 

extern void init_serial (void);             /* Initialize Serial Interface */


int main (void)
{

  int i;
  *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA) |  /* Enable Clock for PIO    */
                    (1 << AT91C_ID_US0);    /* Enable Clock for USART0 */

  pPIO->PIO_PER  = LED_MASK;                /* Enable PIO for LED1,2  */
  pPIO->PIO_OER  = LED_MASK;                /* LED1,2 are Outputs     */
  pPIO->PIO_SODR = LED_MASK;                /* Turn off LED's ("1")    */
  pPIO->PIO_OWER = LED2;                    /* LED2 ODSR Write Enable  */

  init_serial(); 	                        /* Initialize Serial Interface */
  //chek for CP and WP
  //CP - card present
  //while(((pPIO->PIO_PDSR) & BIT15)) { /*put your card present event here*/  }
  //WP - write protect
  //while(((pPIO->PIO_PDSR) & BIT16)) { /*put your write protect event here*/ }

  if (initMMC() == MMC_SUCCESS)	// card found
  {
  	printf("card init success!\n");
	memset(&wr_buffer,0,512);//clear wr_buffer[]
	memset(&rd_buffer,0,512);//clear rd_buffer[]
    mmcReadRegister (10, 16);
    wr_buffer[7]=0;
	rd_buffer[7]=0;

	    // Fill first Block (0) with 'A'
    for(i=0;i<10;i++)				  
	memset(&wr_buffer[i],i+66,1);    //set breakpoint and trace mmc_buffer contents
    mmcWriteBlock(wr_buffer,0);
    memset(&rd_buffer,0x00,512);
    mmcReadBlock(rd_buffer,0,512);


	for(i=0;i<10;i++)
	printf("buffer[%d]:=%c\n",i,rd_buffer[i]);

    // Read first Block back to buffer
    //memset(&mmc_buffer,0x00,512);
    //mmcReadBlock(512,512);
  }
  else
  {
  	printf("card not found!\n");
  }

  while (1) 
  {                               /* Loop forever */
      
  }
}

⌨️ 快捷键说明

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