]> git.gir.st - tmk_keyboard.git/blob - protocol/lufa/LUFA-git/Projects/Webserver/Lib/DataflashManager.h
Squashed 'tmk_core/' changes from caca2c0..dc0e46e
[tmk_keyboard.git] / protocol / lufa / LUFA-git / Projects / Webserver / 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 "../Descriptors.h"
43
44 #include <LUFA/Common/Common.h>
45 #include <LUFA/Drivers/USB/USB.h>
46 #include <LUFA/Drivers/Board/Dataflash.h>
47
48 /* Preprocessor Checks: */
49 #if (DATAFLASH_PAGE_SIZE % 16)
50 #error Dataflash page size must be a multiple of 16 bytes.
51 #endif
52
53 /* Defines: */
54 /** Total number of bytes of the storage medium, comprised of one or more Dataflash ICs. */
55 #define VIRTUAL_MEMORY_BYTES ((uint32_t)DATAFLASH_PAGES * DATAFLASH_PAGE_SIZE * DATAFLASH_TOTALCHIPS)
56
57 /** Block size of the device. This is kept at 512 to remain compatible with the OS despite the underlying
58 * storage media (Dataflash) using a different native block size. Do not change this value.
59 */
60 #define VIRTUAL_MEMORY_BLOCK_SIZE 512
61
62 /** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not
63 * change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size.
64 */
65 #define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
66
67 /** Indicates if the disk is write protected or not. */
68 #define DISK_READ_ONLY false
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 const 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