##// END OF EJS Templates
just backup
just backup

File last commit:

r12:cc0fb1c881c0 default
r12:cc0fb1c881c0 default
Show More
main.c
151 lines | 3.3 KiB | text/x-c | CLexer
/*------------------------------------------------------------------------------
-- This file is a part of the libuc, microcontroler library
-- Copyright (C) 2012, Alexis Jeandet
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------
-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@gmail.com
-------------------------------------------------------------------------------*/
#include "LPC17xx.h"
#include "bsp.h"
#include "core.h"
#include "uart.h"
#include "libucstrings.h"
#include <hexviewer.h>
#include <ucdirent.h>
#include <fsexplorer.h>
#define __delay(t) for(volatile int i=0;i<t;i++);
#define ledspos1 LED1_OFF;LED2_ON;LED3_OFF;LED4_ON;LED5_OFF;LED6_ON;LED7_OFF;LED8_ON
#define ledspos2 LED1_ON;LED2_OFF;LED3_ON;LED4_OFF;LED5_ON;LED6_OFF;LED7_ON;LED8_OFF
char sector[512];
int main (void)
{
int i,n;
char a[10];
char ocr[4];
bsp_init();
uartsetbaudrate(UART0,38400);
libucprintf("hello\n\r");
switch(SDCARD0.Stat)
{
case STA_NOINIT :
libucprintf("Card NOT initialized\n\r");
break;
case STA_NODISK :
libucprintf("NO Card\n\r");
break;
case STA_PROTECT :
libucprintf("Card protected\n\r");
break;
case 0:
libucprintf("Card initialized\n\r");
break;
default:
break;
}
switch(SDCARD0.CardType)
{
case CT_MMC:
libucprintf("Card is MMC\n\r");
break;
case CT_SD1:
libucprintf("Card is SD V1\n\r");
break;
case CT_SD2:
libucprintf("Card is SD V2\n\r");
break;
case CT_BLOCK|CT_SD2:
libucprintf("Card is SDHC\n\r");
break;
default:
break;
}
if(SDCARD0.Stat==0)
{
fsexplprintBootSector(&BLKDEVSDCARD0);
libucprintf("Part1 is 0x%x\n\r",0xff & PART0.TypeCode);
libucprintf("Read FAT32 Vol ID @ %x\n\r",PART0.LBABegin);
fsexplprintPartInfos(&PART0);
libucprintf("fs0.cluster_begin_lba = %x\n\r",fs0.cluster_begin_lba);
libucprintf("fs0.BPB_RsvdSecCnt = %x\n\r",fs0.BPB_RsvdSecCnt);
libucprintf("\tPrint few sectors of FAT:\n\r");
for(i=0;i<10;i++)
{
fsexplprintSector(&BLKDEVSDCARD0,fs0.fat_begin_lba+i);
}
libucprintf("\tPrint few sectors of first clusters:\n\r");
for(i=0;i<10;i++)
{
fsexplprintSector(&BLKDEVSDCARD0,fs0.cluster_begin_lba+i);
}
int res=direntgetroot(root);
while(res==DIRENT_noErr)
{
fsexplprintDirentInfos(&root);
res=direntgetnext(root);
}
libucprintf("Exit because of code %d\n\r",res);
}
libucprintf("SDCARD speed = %dkbps\n\r",SDCARD0.getspeed(SDCARD0.phy)/1000);
while(1)
{
ledspos1;
__delay(1024*1024);
ledspos2;
__delay(1024*1024);
}
return 0;
}