Radio Datalogger Project  Version 2.0
Macros | Functions
DataflashManager.h File Reference
#include <avr/io.h>
#include "TempDataLogger.h"
#include "Descriptors.h"
#include <LUFA/Common/Common.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Board/Dataflash.h>

Macros

#define VIRTUAL_MEMORY_BYTES   ((uint32_t)DATAFLASH_PAGES * DATAFLASH_PAGE_SIZE * DATAFLASH_TOTALCHIPS)
 
#define VIRTUAL_MEMORY_BLOCK_SIZE   512
 
#define VIRTUAL_MEMORY_BLOCKS   (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
 

Functions

void DataflashManager_WriteBlocks (USB_ClassInfo_MS_Device_t *const MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
 
void DataflashManager_ReadBlocks (USB_ClassInfo_MS_Device_t *const MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
 
void DataflashManager_WriteBlocks_RAM (const uint32_t BlockAddress, uint16_t TotalBlocks, const uint8_t *BufferPtr) ATTR_NON_NULL_PTR_ARG(3)
 
void DataflashManager_ReadBlocks_RAM (const uint32_t BlockAddress, uint16_t TotalBlocks, uint8_t *BufferPtr) ATTR_NON_NULL_PTR_ARG(3)
 
void DataflashManager_ResetDataflashProtections (void)
 
bool DataflashManager_CheckDataflashOperation (void)
 

Detailed Description

Header file for DataflashManager.c.

Macro Definition Documentation

#define VIRTUAL_MEMORY_BLOCK_SIZE   512

Block size of the device. This is kept at 512 to remain compatible with the OS despite the underlying storage media (Dataflash) using a different native block size. Do not change this value.

#define VIRTUAL_MEMORY_BLOCKS   (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)

Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size.

#define VIRTUAL_MEMORY_BYTES   ((uint32_t)DATAFLASH_PAGES * DATAFLASH_PAGE_SIZE * DATAFLASH_TOTALCHIPS)

Total number of bytes of the storage medium, comprised of one or more dataflash ICs.

Function Documentation

bool DataflashManager_CheckDataflashOperation ( void  )

Performs a simple test on the attached Dataflash IC(s) to ensure that they are working.

Returns
Boolean true if all media chips are working, false otherwise
void DataflashManager_ReadBlocks ( USB_ClassInfo_MS_Device_t *const  MSInterfaceInfo,
const uint32_t  BlockAddress,
uint16_t  TotalBlocks 
)

Reads blocks (OS blocks, not Dataflash pages) from the storage medium, the board Dataflash IC(s), into the pre-selected data IN endpoint. This routine reads in Dataflash page sized blocks from the Dataflash and writes them in OS sized blocks to the endpoint.

Parameters
[in]MSInterfaceInfoPointer to a structure containing a Mass Storage Class configuration and state
[in]BlockAddressData block starting address for the read sequence
[in]TotalBlocksNumber of blocks of data to read
void DataflashManager_ReadBlocks_RAM ( const uint32_t  BlockAddress,
uint16_t  TotalBlocks,
uint8_t *  BufferPtr 
)

Reads blocks (OS blocks, not Dataflash pages) from the storage medium, the board Dataflash IC(s), into the preallocated RAM buffer. This routine reads in Dataflash page sized blocks from the Dataflash and writes them in OS sized blocks to the given buffer. This can be linked to FAT libraries to read the files stored on the Dataflash.

Parameters
[in]BlockAddressData block starting address for the read sequence
[in]TotalBlocksNumber of blocks of data to read
[out]BufferPtrPointer to the data destination RAM buffer
void DataflashManager_ResetDataflashProtections ( void  )

Disables the Dataflash memory write protection bits on the board Dataflash ICs, if enabled.

void DataflashManager_WriteBlocks ( USB_ClassInfo_MS_Device_t *const  MSInterfaceInfo,
const uint32_t  BlockAddress,
uint16_t  TotalBlocks 
)

Writes blocks (OS blocks, not Dataflash pages) to the storage medium, the board Dataflash IC(s), from the pre-selected data OUT endpoint. This routine reads in OS sized blocks from the endpoint and writes them to the Dataflash in Dataflash page sized blocks.

Parameters
[in]MSInterfaceInfoPointer to a structure containing a Mass Storage Class configuration and state
[in]BlockAddressData block starting address for the write sequence
[in]TotalBlocksNumber of blocks of data to write
void DataflashManager_WriteBlocks_RAM ( const uint32_t  BlockAddress,
uint16_t  TotalBlocks,
const uint8_t *  BufferPtr 
)

Writes blocks (OS blocks, not Dataflash pages) to the storage medium, the board Dataflash IC(s), from the given RAM buffer. This routine reads in OS sized blocks from the buffer and writes them to the Dataflash in Dataflash page sized blocks. This can be linked to FAT libraries to write files to the Dataflash.

Parameters
[in]BlockAddressData block starting address for the write sequence
[in]TotalBlocksNumber of blocks of data to write
[in]BufferPtrPointer to the data source RAM buffer