3ddd2eda016084b2bd24cd6e34b19d5aa98e40f9
3 Copyright (C) Dean Camera, 2009.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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
33 * Target-related functions for the TINY target's NVM module.
36 #define INCLUDE_FROM_TINYNVM_C
39 #if defined(ENABLE_XPROG_PROTOCOL) || defined(__DOXYGEN__)
40 #warning TPI Protocol support is currently incomplete and is not suitable for general use.
42 /** Busy-waits while the NVM controller is busy performing a NVM operation, such as a FLASH page read.
44 * \return Boolean true if the NVM controller became ready within the timeout period, false otherwise
46 bool TINYNVM_WaitWhileNVMBusBusy(void)
48 /* Poll the STATUS register to check to see if NVM access has been enabled */
49 while (TimeoutMSRemaining
)
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
)
60 /** Reads memory from the target's memory spaces.
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
66 * \return Boolean true if the command sequence complete successfully
68 bool TINYNVM_ReadMemory(const uint32_t ReadAddress
, uint8_t* ReadBuffer
, const uint16_t ReadSize
)
75 /** Writes byte addressed memory to the target's memory spaces.
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
81 * \return Boolean true if the command sequence complete successfully
83 bool TINYNVM_WriteMemory(const uint8_t WriteCommand
, const uint32_t WriteAddress
, const uint8_t* WriteBuffer
)
90 /** Erases a specific memory space of the target.
92 * \param[in] EraseCommand NVM erase command to send to the device
93 * \param[in] Address Address inside the memory space to erase
95 * \return Boolean true if the command sequence complete successfully
97 bool TINYNVM_EraseMemory(const uint8_t EraseCommand
, const uint32_t Address
)