]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h
Merge commit '22b6e15a179031afb7c3534cf7b109b0668b602c'
[max/tmk_keyboard.git] / tmk_core / protocol / lufa / LUFA-git / Projects / AVRISP-MKII / Lib / XPROG / TINYNVM.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 TINYNVM.c.
34  */
35
36 #ifndef _TINY_NVM_
37 #define _TINY_NVM_
38
39         /* Includes: */
40                 #include <avr/io.h>
41                 #include <avr/interrupt.h>
42                 #include <stdbool.h>
43
44                 #include <LUFA/Common/Common.h>
45
46                 #include "XPROGProtocol.h"
47                 #include "XPROGTarget.h"
48                 #include "Config/AppConfig.h"
49
50         /* Preprocessor Checks: */
51                 #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
52                         #undef ENABLE_ISP_PROTOCOL
53
54                         #if !defined(ENABLE_XPROG_PROTOCOL)
55                                 #define ENABLE_XPROG_PROTOCOL
56                         #endif
57                 #endif
58
59         /* Defines: */
60                 #define TINY_NVM_CMD_NOOP              0x00
61                 #define TINY_NVM_CMD_CHIPERASE         0x10
62                 #define TINY_NVM_CMD_SECTIONERASE      0x14
63                 #define TINY_NVM_CMD_WORDWRITE         0x1D
64
65         /* Function Prototypes: */
66                 bool TINYNVM_WaitWhileNVMBusBusy(void);
67                 bool TINYNVM_WaitWhileNVMControllerBusy(void);
68                 bool TINYNVM_EnableTPI(void);
69                 void TINYNVM_DisableTPI(void);
70                 bool TINYNVM_ReadMemory(const uint16_t ReadAddress,
71                                         uint8_t* ReadBuffer,
72                                         uint16_t ReadLength);
73                 bool TINYNVM_WriteMemory(const uint16_t WriteAddress,
74                                          uint8_t* WriteBuffer,
75                                          uint16_t WriteLength);
76                 bool TINYNVM_EraseMemory(const uint8_t EraseCommand,
77                                          const uint16_t Address);
78
79                 #if (defined(INCLUDE_FROM_TINYNVM_C) && defined(ENABLE_XPROG_PROTOCOL))
80                         static void TINYNVM_SendReadNVMRegister(const uint8_t Address);
81                         static void TINYNVM_SendWriteNVMRegister(const uint8_t Address);
82                         static void TINYNVM_SendPointerAddress(const uint16_t AbsoluteAddress);
83                 #endif
84
85 #endif
86