df.h

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

Generated on Wed Sep 23 09:17:02 2009 for ATMEL by  doxygen 1.5.3