avr_flash.h

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00002 /*! \file avr_flash.h *********************************************************
00003  *
00004  * \brief
00005  *      This file writes/reads to/from flash memory internal to the AVR.
00006  *
00007  * \addtogroup usbstick
00008  *
00009  * \author
00010  *      Colin O'Flynn <coflynn@newae.com>
00011  ******************************************************************************/
00012 /* 
00013    Copyright (c) 2008  Colin O'Flynn
00014    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    * Redistributions of source code must retain the above copyright
00020      notice, this list of conditions and the following disclaimer.
00021    * Redistributions in binary form must reproduce the above copyright
00022      notice, this list of conditions and the following disclaimer in
00023      the documentation and/or other materials provided with the
00024      distribution.
00025    * Neither the name of the copyright holders nor the names of
00026      contributors may be used to endorse or promote products derived
00027      from this software without specific prior written permission.
00028 
00029   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00030   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00031   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00032   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00033   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00034   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00035   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00036   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00037   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00038   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00039   POSSIBILITY OF SUCH DAMAGE.
00040 */
00041 
00042 /**
00043  \addtogroup usbstorage
00044  @{
00045 */
00046 
00047 #ifndef _DFMEM_H_
00048 #define _DFMEM_H_
00049 
00050 #include "conf_access.h"
00051 #include "ctrl_status.h"
00052 
00053 
00054 
00055 
00056 //_____ D E F I N I T I O N S ______________________________________________
00057 
00058 //! FAT specification
00059 #define  ENTRY_SIZE           32    // size of entrie in byte
00060 
00061 
00062 
00063 // First sector of the disk virtual (this disk isn't partitioned, only one partion)
00064 #define  PBR_SECTOR           (0)
00065 #define  FAT_SECTOR           (PBR_SECTOR  + VMEM_RESERVED_SIZE)
00066 #define  ROOT_SECTOR          (FAT_SECTOR  + (VMEM_SIZE_FAT*VMEM_NB_FATS))
00067 #define  FILE_SECTOR          (ROOT_SECTOR + ((ENTRY_SIZE*VMEM_NB_ROOT_ENTRY) / VMEM_SECTOR_SIZE))                   // 1(sector) = size root dir
00068 
00069 
00070 /* FAT Format Structure */
00071 typedef struct
00072 {
00073   Uint16 nb_cylinder;
00074   Byte   nb_head;
00075   Byte   nb_sector;
00076   Byte   nb_hidden_sector;
00077   Byte   nb_sector_per_cluster;
00078 } s_format;
00079 
00080 #define MEM_BSY       0
00081 #define MEM_OK        1
00082 #define MEM_KO        2
00083 
00084 
00085 
00086 
00087 //---- CONTROL FONCTIONS ----
00088 
00089 // those fonctions are declared in df_mem.h
00090 void           avrf_mem_init(void);
00091 Ctrl_status    avrf_test_unit_ready(void);
00092 Ctrl_status    avrf_read_capacity( U32 _MEM_TYPE_SLOW_ *u32_nb_sector );
00093 Bool           avrf_wr_protect(void);
00094 Bool           avrf_removal(void);
00095 
00096 //---- AVR FLASH LOW-LEVEL----
00097 
00098 
00099 bit     avrf_init (void);
00100 bit     avrf_mem_check(void);
00101 bit     avrf_read_open (Uint32);
00102 void    avrf_read_close (void);
00103 bit     avrf_write_open (Uint32);
00104 void    avrf_write_close (void);
00105 
00106 //! Funtions to link USB DEVICE flow with data flash
00107 bit     avrf_write_sector (Uint16);
00108 bit     avrf_read_sector (Uint16);
00109 
00110 
00111 s_format  * avrf_format (void);
00112 
00113 
00114 
00115 //---- ACCESS DATA FONCTIONS ----
00116 
00117 // Standard functions for open in read/write mode the device
00118 Ctrl_status    avrf_read_10( U32 addr , U16 nb_sector );
00119 Ctrl_status    avrf_write_10( U32 addr , U16 nb_sector );
00120 
00121 
00122 //** If your device transfer have a specific transfer for USB (Particularity of Chejudo product, or bootloader)
00123 #ifdef DF_VALIDATION
00124 #include "virtual_usb.h"
00125 #else
00126 #include "usb_drv.h"    // In this case the driver must be known for the USB access
00127 #endif
00128 //Ctrl_status avr_usb_read( void );
00129 //Ctrl_status avr_usb_write( void );
00130 Ctrl_status avrf_usb_read( void );
00131 Ctrl_status avrf_usb_write( void );
00132 
00133 
00134 
00135 #endif   // _DFMEM_H_
00136 
00137 /** @} */

Generated on Mon Apr 11 14:23:36 2011 for Contiki 2.5 by  doxygen 1.6.1