3      Copyright (C) Dean Camera, 2010. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this  
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in  
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting  
  17   documentation, and that the name of the author not be used in  
  18   advertising or publicity pertaining to distribution of the  
  19   software without specific, written prior permission. 
  21   The author disclaim all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  33  *  Header file for DataflashManager.c. 
  36 #ifndef _DATAFLASH_MANAGER_H 
  37 #define _DATAFLASH_MANAGER_H 
  42                 #include "MassStorage.h" 
  43                 #include "Descriptors.h" 
  45                 #include <LUFA/Common/Common.h> 
  46                 #include <LUFA/Drivers/USB/USB.h> 
  47                 #include <LUFA/Drivers/USB/Class/MassStorage.h> 
  48                 #include <LUFA/Drivers/Board/Dataflash.h> 
  50         /* Preprocessor Checks: */ 
  51                 #if (DATAFLASH_PAGE_SIZE % 16) 
  52                         #error Dataflash page size must be a multiple of 16 bytes. 
  56                 /** Total number of bytes of the storage medium, comprised of one or more dataflash ICs. */ 
  57                 #define VIRTUAL_MEMORY_BYTES                ((uint32_t)DATAFLASH_PAGES * DATAFLASH_PAGE_SIZE * DATAFLASH_TOTALCHIPS) 
  59                 /** Block size of the device. This is kept at 512 to remain compatible with the OS despite the underlying 
  60                  *  storage media (Dataflash) using a different native block size. Do not change this value. 
  62                 #define VIRTUAL_MEMORY_BLOCK_SIZE           512 
  64                 /** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not 
  65                  *  change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size. 
  67                 #define VIRTUAL_MEMORY_BLOCKS               (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE) 
  69         /* Function Prototypes: */ 
  70                 void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t
* MSInterfaceInfo
, const uint32_t BlockAddress
, 
  71                                                   uint16_t TotalBlocks
); 
  72                 void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t
* MSInterfaceInfo
, const uint32_t BlockAddress
, 
  73                                                  uint16_t TotalBlocks
); 
  74                 void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress
, uint16_t TotalBlocks
, 
  75                                                       uint8_t* BufferPtr
) ATTR_NON_NULL_PTR_ARG(3); 
  76                 void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress
, uint16_t TotalBlocks
, 
  77                                                      uint8_t* BufferPtr
) ATTR_NON_NULL_PTR_ARG(3); 
  78                 void DataflashManager_ResetDataflashProtections(void); 
  79                 bool DataflashManager_CheckDataflashOperation(void);