?? main.c
字號:
//*----------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name : main.c
//* Object : main application written in C to SDRAM
//* 1.0 18/May/06 JPP : Creation
//*----------------------------------------------------------------------------
// Include Standard files
#include "project.h"
#include "AT91SAM7SE-EK.h"
#include "SDRAM.h"
//*----------------------------------------------------------------------------
//* \fn AT91F_TestSdram
//* \brief SDRAM test
//*----------------------------------------------------------------------------
int AT91F_TestSdram(void)
{
unsigned int i;
// Write
for(i = 0; i < AT91C_SDRAM_SIZE; i++)
{
*(AT91C_SDRAM_BASE + i) = i;
}
// Read and check
for(i = 0; i < AT91C_SDRAM_SIZE; i++)
{
if (*(AT91C_SDRAM_BASE + i) != i)
return -1;
}
return 0;
}
//*--------------------------------------------------------------------------------------
//* Function Name : Main
//* Object : Software entry point
//* Input Parameters : none.
//* Output Parameters : none.
//*--------------------------------------------------------------------------------------
int main()
{
int Test;
// First, enable the clock of the PIO LEDs
AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1 << AT91C_ID_PIOA ) ;
// then, we configure the PIO Lines corresponding to LED1 to LED2 to be
// outputs. No need to set these pins to be driven by the PIO because it is
// GPIO pins only.
AT91F_PIO_CfgOutput( AT91D_BASE_PIO_LED, AT91B_LED_MASK );
// Clear the LED's. On the board we must apply a "1" to turn off LEDs
AT91F_PIO_SetOutput( AT91D_BASE_PIO_LED, AT91B_LED_MASK );
//* Initi SDRAM access
AT91F_InitSdram ();
//* Test SDRAM
Test = AT91F_TestSdram();
if ( Test != -1) { //* SDRAM OK
AT91F_PIO_ClearOutput( AT91D_BASE_PIO_LED, AT91B_LED2) ;
} else { //* SDRAM FAIL !!
AT91F_PIO_ClearOutput( AT91D_BASE_PIO_LED, AT91B_POWERLED|AT91B_LED1) ;
}
//* while (1);
for(;;){};
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -