Split out NVM access code in the AVRISP project into a seperate NVMTarget.c source...
[pub/USBasp.git] / Projects / AVRISP / Lib / NVMTarget.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 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 disclaim 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 NVMTarget.c.
34 */
35
36 #ifndef _NVM_TARGET_
37 #define _NVM_TARGET_
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 "PDIProtocol.h"
47 #include "PDITarget.h"
48
49 /* Preprocessor Checks: */
50 #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
51 #undef ENABLE_ISP_PROTOCOL
52
53 #if !defined(ENABLE_PDI_PROTOCOL)
54 #define ENABLE_PDI_PROTOCOL
55 #endif
56 #endif
57
58 /* Defines: */
59 #define FLASH_BASE 0x00800000
60 #define EPPROM_BASE 0x008C0000
61 #define FUSE_BASE 0x008F0020
62 #define DATAMEM_BASE 0x01000000
63 #define PROD_SIGNATURE_BASE 0x008E0200
64 #define USER_SIGNATURE_BASE 0x008E0400
65
66 #define NVM_REG_ADDR0 0x00
67 #define NVM_REG_ADDR1 0x01
68 #define NVM_REG_ADDR2 0x02
69 #define NVM_REG_DAT0 0x04
70 #define NVM_REG_DAT1 0x05
71 #define NVM_REG_DAT2 0x06
72 #define NVM_REG_CMD 0x0A
73 #define NVM_REG_CTRLA 0x0B
74 #define NVM_REG_CTRLB 0x0C
75 #define NVM_REG_INTCTRL 0x0D
76 #define NVM_REG_STATUS 0x0F
77 #define NVM_REG_LOCKBITS 0x10
78
79 #define NVM_CMD_APPCRC 0x38
80 #define NVM_CMD_BOOTCRC 0x39
81 #define NVM_CMD_FLASHCRC 0x78
82 #define NVM_CMD_READUSERSIG 0x03
83
84 /* Function Prototypes: */
85 void NVMTarget_SendNVMRegAddress(uint8_t Register);
86 bool NVMTarget_WaitWhileNVMBusBusy(void);
87 void NVMTarget_WaitWhileNVMControllerBusy(void);
88 uint32_t NVMTarget_GetMemoryCRC(uint8_t MemoryCommand);
89
90 #endif