?? _old_main.c
字號:
#include "include/include.h"
extern char mmc_buffer[512];
AT91PS_PIO m_pPio = AT91C_BASE_PIOA;
void Delay (unsigned long var){
while(--var != 0) ;
}
/*-----------------------------------------------------------------------------
*-----------------------------------------------------------------------------*/
static void ConfigureIO (void){
// for LCD Backlight
AT91C_BASE_PIOB->PIO_OER = (AT91B_LCD_BL); // set to output
AT91C_BASE_PIOB->PIO_PER = (AT91B_LCD_BL); // set to PIO mode
AT91C_BASE_PIOB->PIO_PPUDR = (AT91B_LCD_BL); // disable pull up
AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_PIOA); // enable periph clock for PIO controller
AT91C_BASE_PIOA->PIO_ODR = (AT91A_JS_ALL); // set PIO line to input
AT91C_BASE_PIOB->PIO_ODR = SW1 | SW2; //Configure as Input
AT91C_BASE_PIOB->PIO_PER = SW1 | SW2; //Enable pin
}
int main()
{
const double wait = 1650000;
ConfigureIO();
AT91C_BASE_PMC->PMC_PCER = ( 1 << AT91C_ID_PIOA ) | ( 1 << AT91C_ID_PIOB ) | ( 1 << AT91C_ID_US0 );
uart0_init();
uart0_puts("\n\nINIT...OK\n");
Init_CP_WP();
uart0_puts("CP, WP...OK\n");
//CP - card present
/*uart0_puts("WP present? ");
while(((AT91C_BASE_PIOB->PIO_PDSR) & SW1)) { uart0_puts("NO WP\n"); }
uart0_puts("YES\n");
//WP - write protect
uart0_puts("Write protected? ");
while(((m_pPio->PIO_PDSR) & BIT16)) { //put your write protect event here }
//uart0_puts("NO WP\n");
*/
if ((AT91C_BASE_PIOB->PIO_PDSR) & SW1) uart0_puts("SW1 ");
if ((AT91C_BASE_PIOB->PIO_PDSR) & SW2) uart0_puts("SW2 ");
if ((AT91C_BASE_PIOB->PIO_PDSR) & CP) uart0_puts("CP ");
if ((AT91C_BASE_PIOB->PIO_PDSR) & WP) uart0_puts("WP ");
AT91C_BASE_PIOB->PIO_SODR = NPCS1;
/**** MMC CARD ****/
if (initMMC() == MMC_SUCCESS) // card found
{
AT91C_BASE_PIOB->PIO_SODR = NPCS1;
//card_state |= 1;
memset(&mmc_buffer,0,512);
mmcReadRegister (10, 16);
mmc_buffer[7]=0;
// Fill first Block (0) with 'A'
memset(&mmc_buffer,'0',512); //set breakpoint and trace mmc_buffer contents
mmcWriteBlock(0);
// Fill second Block (1)-AbsAddr 512 with 'B'
memset(&mmc_buffer,'1',512);
mmcWriteBlock(512);
// Read first Block back to buffer
memset(&mmc_buffer,0x00,512);
mmcReadBlock(0,512);
// Read first Block back to buffer
memset(&mmc_buffer,0x00,512);
mmcReadBlock(512,512);
uart0_puts(mmc_buffer[0]);
uart0_puts(mmc_buffer[1]);
uart0_puts(mmc_buffer[2]);
}
// loop forever
while (1) {
AT91C_BASE_PIOB->PIO_SODR = AT91B_LCD_BL;
Delay(wait);
AT91C_BASE_PIOB->PIO_CODR = AT91B_LCD_BL;
Delay(wait);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -