3ddd2eda016084b2bd24cd6e34b19d5aa98e40f9
[pub/USBasp.git] / Projects / AVRISP-MKII / Lib / XPROG / TINYNVM.c
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 * Target-related functions for the TINY target's NVM module.
34 */
35
36 #define INCLUDE_FROM_TINYNVM_C
37 #include "TINYNVM.h"
38
39 #if defined(ENABLE_XPROG_PROTOCOL) || defined(__DOXYGEN__)
40 #warning TPI Protocol support is currently incomplete and is not suitable for general use.
41
42 /** Busy-waits while the NVM controller is busy performing a NVM operation, such as a FLASH page read.
43 *
44 * \return Boolean true if the NVM controller became ready within the timeout period, false otherwise
45 */
46 bool TINYNVM_WaitWhileNVMBusBusy(void)
47 {
48 /* Poll the STATUS register to check to see if NVM access has been enabled */
49 while (TimeoutMSRemaining)
50 {
51 /* Send the SLDCS command to read the TPI STATUS register to see the NVM bus is active */
52 XPROGTarget_SendByte(TPI_CMD_SLDCS | TPI_STATUS_REG);
53 if (XPROGTarget_ReceiveByte() & TPI_STATUS_NVM)
54 return true;
55 }
56
57 return false;
58 }
59
60 /** Reads memory from the target's memory spaces.
61 *
62 * \param[in] ReadAddress Start address to read from within the target's address space
63 * \param[out] ReadBuffer Buffer to store read data into
64 * \param[in] ReadSize Number of bytes to read
65 *
66 * \return Boolean true if the command sequence complete successfully
67 */
68 bool TINYNVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, const uint16_t ReadSize)
69 {
70 // TODO
71
72 return true;
73 }
74
75 /** Writes byte addressed memory to the target's memory spaces.
76 *
77 * \param[in] WriteCommand Command to send to the device to write each memory byte
78 * \param[in] WriteAddress Start address to write to within the target's address space
79 * \param[in] WriteBuffer Buffer to source data from
80 *
81 * \return Boolean true if the command sequence complete successfully
82 */
83 bool TINYNVM_WriteMemory(const uint8_t WriteCommand, const uint32_t WriteAddress, const uint8_t* WriteBuffer)
84 {
85 // TODO
86
87 return true;
88 }
89
90 /** Erases a specific memory space of the target.
91 *
92 * \param[in] EraseCommand NVM erase command to send to the device
93 * \param[in] Address Address inside the memory space to erase
94 *
95 * \return Boolean true if the command sequence complete successfully
96 */
97 bool TINYNVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address)
98 {
99 // TODO
100
101 return true;
102 }
103
104 #endif