df.h

Go to the documentation of this file.
00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
00013 
00014 /* Copyright (c) 2007, Atmel Corporation All rights reserved.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions are met:
00018  *
00019  * 1. Redistributions of source code must retain the above copyright notice,
00020  * this list of conditions and the following disclaimer.
00021  *
00022  * 2. Redistributions in binary form must reproduce the above copyright notice,
00023  * this list of conditions and the following disclaimer in the documentation
00024  * and/or other materials provided with the distribution.
00025  *
00026  * 3. The name of ATMEL may not be used to endorse or promote products derived
00027  * from this software without specific prior written permission.
00028  *
00029  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
00030  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00031  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
00032  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00033  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00034  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00035  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00036  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00038  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  */
00040 
00041 #ifndef _DF_H_
00042 #define _DF_H_
00043 
00044 //_____ I N C L U D E S ____________________________________________________
00045 
00046 #include "config.h"
00047 
00048 
00049 //_____ M A C R O S ________________________________________________________
00050 
00051 #define  MEM_BSY           0
00052 #define  MEM_OK            1
00053 #define  MEM_KO            2
00054 
00055 //----- DataFlash definition -----
00056 #define  DF_MSK_DENSITY    ((Byte)0x3C)      // status density mask 
00057 #define  DF_MSK_BIT_BUSY   ((Byte)0x80)
00058 #define  DF_MEM_BUSY       ((Byte)0x00)
00059         
00060 #define  DF_RD_STATUS      ((Byte)0xD7)      // read status cmd 
00061 #define  DF_PG_ERASE       ((Byte)0x81)      // page erase cmd  
00062 #define  DF_BK_ERASE       ((Byte)0x50)      // block erase cmd 
00063         
00064 #define  DF_WR_BUF_1       ((Byte)0x84)      // write buffer 1 cmd 
00065 #define  DF_WR_BUF_2       ((Byte)0x87)      // write buffer 2 cmd 
00066 #define  DF_B1_MAIN        ((Byte)0x83)      // buffer 1 to main program with erase cmd 
00067 #define  DF_B2_MAIN        ((Byte)0x86)      // buffer 2 to main program with erase cmd 
00068         
00069 #define  DF_RD_MAIN        ((Byte)0xD2)      // main memory page read cmd 
00070 #define  DF_TF_BUF_1       ((Byte)0x53)      // main memory page to buffer 1 transfer cmd 
00071 #define  DF_TF_BUF_2       ((Byte)0x55)      // main memory page to buffer 2 transfer cmd 
00072 #define  DF_RD_BUF_1       ((Byte)0xD4)      // buffer 1 read cmd 
00073 #define  DF_RD_BUF_2       ((Byte)0xD6)      // buffer 2 read cmd 
00074         
00075         
00076 #define  DF_4MB            ((Byte)0)
00077 #define  DF_8MB            ((Byte)1)
00078 #define  DF_16MB           ((Byte)2)
00079 #define  DF_32MB           ((Byte)3)
00080 #define  DF_64MB           ((Byte)4)
00081 
00082 
00083 // BUSY Management and Memory Selection 
00084 
00085 // The variable "df_mem_busy" can contain the state of 4 dataflash 
00086 #define  df_set_busy(i)       (df_mem_busy |= (1<<i))
00087 #define  df_release_busy(i)   (df_mem_busy &= ~(1<<i))
00088 #define  is_df_busy(i)        (((df_mem_busy&(1<<i)) != 0) ? TRUE : FALSE)
00089 
00090 
00091 //_____ D E F I N I T I O N ________________________________________________
00092 
00093 #ifdef DF_4_MB             // AT45DB321 memories 
00094   #define DF_SHFT_DFIDX    (22)              // RShift to apply to an absolute
00095                                              // * Byte address to get the DF idx 
00096   #define DF_DENSITY       ((Byte)0x34)
00097   #define DF_PG_BUF_1      ((Byte)0x82)      // main memory program through buf1 
00098   #define DF_PG_BUF_2      ((Byte)0x85)      // main memory program through buf2 
00099   #define DF_PAGE_SIZE     (512)             // page length 
00100   #define DF_PAGE_MASK     ((Byte)0x01)      // mask MSB page bits 
00101   #define DF_SHFT_B1       (1)
00102   #define DF_SHFT_B2       (7)
00103 #endif                    
00104                           
00105 #ifdef DF_8_MB             // AT45DB642 memories 
00106   #define DF_SHFT_DFIDX    (23)              // RShift to apply to an absolute
00107                                              // * Byte address to get the DF idx 
00108   #define DF_DENSITY       ((Byte)0x3C)
00109   #define DF_PG_BUF_1      ((Byte)0x82)      // fast main memory program through buf1 
00110   #define DF_PG_BUF_2      ((Byte)0x85)      // fast main memory program through buf2 
00111   #define DF_PAGE_SIZE     (1024)            // page length 
00112   #define DF_PAGE_MASK     ((Byte)0x03)      // mask MSB page bits 
00113   #define DF_SHFT_B1       (1)
00114   #define DF_SHFT_B2       (7)
00115 #endif
00116 
00117 
00118 //_____ D E C L A R A T I O N ______________________________________________
00119 
00120 void    df_init                  (void);
00121 Bool    df_mem_check             (void);
00122 Bool    df_read_open             (Uint32);
00123 void    df_read_close            (void);
00124 Bool    df_write_open            (Uint32);
00125 void    df_write_close           (void);
00126 
00128 Bool    df_write_sector          (Uint16);
00129 Bool    df_read_sector           (Uint16);
00131 bit     df_host_write_sector (Uint16);
00132 bit     df_host_read_sector (Uint16);
00133 
00135 Bool    df_read_sector_2_ram     (U8 *ram);
00136 Bool    df_write_sector_from_ram (U8 *ram);
00137 
00138 #endif  // _DF_H_ 
00139 
00140 

Generated on Fri Oct 31 14:31:23 2008 for ATMEL by  doxygen 1.5.3