]> git.gir.st - tmk_keyboard.git/blob - protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/Lib/DataflashManager.h
Squashed 'tmk_core/' changes from d5c5ac6..8da1898
[tmk_keyboard.git] / protocol / lufa / LUFA-git / Demos / Device / ClassDriver / MassStorageKeyboard / Lib / DataflashManager.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2014.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2014 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 "../MassStorageKeyboard.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.
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. */
65 #define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
66
67 /** Blocks in each LUN, calculated from the total capacity divided by the total number of Logical Units in the device. */
68 #define LUN_MEDIA_BLOCKS (VIRTUAL_MEMORY_BLOCKS / TOTAL_LUNS)
69
70 /* Function Prototypes: */
71 void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
72 const uint32_t BlockAddress,
73 uint16_t TotalBlocks);
74 void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
75 const uint32_t BlockAddress,
76 uint16_t TotalBlocks);
77 void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
78 uint16_t TotalBlocks,
79 uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);
80 void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
81 uint16_t TotalBlocks,
82 uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);
83 void DataflashManager_ResetDataflashProtections(void);
84 bool DataflashManager_CheckDataflashOperation(void);
85
86 #endif
87
Imprint / Impressum