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

📄 test_data_flash_eb55.c

📁 ARM入门的好帮手.包含了从简单到相对较复杂的程序.
💻 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           : test_data_flash.c
//* Object              : Data Flash Test Program.
//* Translator          : ARM Software Development Toolkit V2.5
//*
//* 1.0 20/09/99 JCZ    : Creation
//*--------------------------------------------------------------------------------------

#include    "parts/m55800/m55800.h"
#include    "at45db321.h"
#include    <stdio.h>

/* Global variables */
/* 32Kbytes buffer to read and write */
u_char  buffer_data_flash1[1024] ;
u_char  buffer_data_flash2[1024] ;

//*--------------------------------------------------------------------------------------
//* Function Name       : display_buffer
//* Object              : Displaying the buffer
//* Input Parameters    : <*buffer> : Buffer to display
//*                     : <size>    : Number of data to display    
//* Output Parameters   : 
//* Functions called    : 
//*--------------------------------------------------------------------------------------
void display_buffer ( u_char *buffer, int size )
{
    u_int address = 0 ;
    
    while ( size > 0 )
    {
        if (( address & 0x7 ) == 0 )
            printf ( "0x%04X :", address ) ;
        
        printf ( " %02X", *buffer ) ;
        address ++ ;
        size -- ;
        buffer ++ ;
        if (( address & 0x7 ) == 0 )
            printf ("\n") ;
    }
    printf ("\n\n") ;
}

//*--------------------------------------------------------------------------------------
//* Function Name       : Main
//* Object              : Test communication beetwen Serial Data flash and SPI AT91 port
//* Input Parameters    : 
//* Output Parameters   : 
//* Functions called    : db321_open, db321_close, db321_write_buffer, db321_read_buffer 
//*--------------------------------------------------------------------------------------
int main ( void )
//* Begin
{
    u_int type_flash ;
    u_int i ;

    type_flash = db321_open () ;
    printf ("Type de Data Flash = 0x%08X\n", type_flash ) ;

    for ( i=0; i<528; i++ )
    {
        buffer_data_flash1[i] = (u_char)(i&0xFF) ;
    }
    for ( i=0; i<528; i++ )
    {
        buffer_data_flash2[i] = 0xFF ;
    }
    
    printf ("Displaying Buffer 1 before writing to Data Flash\n" ) ;
    display_buffer ( buffer_data_flash1, 528 ) ;
    
    printf ("Displaying Buffer 2 before writing to Data Flash\n" ) ;
    display_buffer ( buffer_data_flash2, 528 ) ;

    db321_write_buffer ( buffer_data_flash1, 0x0, 528) ;

    db321_read_buffer ( 0x0, buffer_data_flash2, 528) ;
    
    printf ("Displaying Buffer 2 after reading Data Flash\n" ) ;
    display_buffer ( buffer_data_flash2, 528 ) ;

    for ( i=0; i<528; i++ ) 
    {
        buffer_data_flash1[i] = (u_char)(i&0xFF) ;
        if ( buffer_data_flash2[i] != buffer_data_flash1[i] )
        {
            printf ("Test Serial DataFlash AT45DB321 Failed !\n" ) ;
            return ( FALSE ) ;
        }
    }   

    printf ("Test Serial DataFlash AT45DB321 OK !\n" ) ;    

    db321_close () ;
}
//* End

⌨️ 快捷键说明

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