diff options
Diffstat (limited to 'lib/lufa/Projects/TempDataLogger/Lib/DataflashManager.h')
| -rw-r--r-- | lib/lufa/Projects/TempDataLogger/Lib/DataflashManager.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/lib/lufa/Projects/TempDataLogger/Lib/DataflashManager.h b/lib/lufa/Projects/TempDataLogger/Lib/DataflashManager.h new file mode 100644 index 000000000..f0feeb67b --- /dev/null +++ b/lib/lufa/Projects/TempDataLogger/Lib/DataflashManager.h | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 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. | ||
| 20 | |||
| 21 | The author disclaims 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 | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * | ||
| 33 | * Header file for DataflashManager.c. | ||
| 34 | */ | ||
| 35 | |||
| 36 | #ifndef _DATAFLASH_MANAGER_H_ | ||
| 37 | #define _DATAFLASH_MANAGER_H_ | ||
| 38 | |||
| 39 | /* Includes: */ | ||
| 40 | #include <avr/io.h> | ||
| 41 | |||
| 42 | #include "../TempDataLogger.h" | ||
| 43 | #include "../Descriptors.h" | ||
| 44 | #include "Config/AppConfig.h" | ||
| 45 | |||
| 46 | #include <LUFA/Common/Common.h> | ||
| 47 | #include <LUFA/Drivers/USB/USB.h> | ||
| 48 | #include <LUFA/Drivers/Board/Dataflash.h> | ||
| 49 | |||
| 50 | /* Preprocessor Checks: */ | ||
| 51 | #if (DATAFLASH_PAGE_SIZE % 16) | ||
| 52 | #error Dataflash page size must be a multiple of 16 bytes. | ||
| 53 | #endif | ||
| 54 | |||
| 55 | /* Defines: */ | ||
| 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) | ||
| 58 | |||
| 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. | ||
| 61 | */ | ||
| 62 | #define VIRTUAL_MEMORY_BLOCK_SIZE 512 | ||
| 63 | |||
| 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. | ||
| 66 | */ | ||
| 67 | #define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE) | ||
| 68 | |||
| 69 | /* Function Prototypes: */ | ||
| 70 | void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo, | ||
| 71 | const uint32_t BlockAddress, | ||
| 72 | uint16_t TotalBlocks); | ||
| 73 | void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo, | ||
| 74 | const uint32_t BlockAddress, | ||
| 75 | uint16_t TotalBlocks); | ||
| 76 | void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress, | ||
| 77 | uint16_t TotalBlocks, | ||
| 78 | const uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3); | ||
| 79 | void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress, | ||
| 80 | uint16_t TotalBlocks, | ||
| 81 | uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3); | ||
| 82 | void DataflashManager_ResetDataflashProtections(void); | ||
| 83 | bool DataflashManager_CheckDataflashOperation(void); | ||
| 84 | |||
| 85 | #endif | ||
| 86 | |||
