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_TPI_PROTOCOL) || defined(__DOXYGEN__)
41 /** Sends the given NVM register address to the target.
43 * \param[in] Register NVM register whose absolute address is to be sent
45 void TINYNVM_SendNVMRegAddress(const uint8_t Register
)
50 /** Sends the given 32-bit absolute address to the target.
52 * \param[in] AbsoluteAddress Absolute address to send to the target
54 void TINYNVM_SendAddress(const uint32_t AbsoluteAddress
)
59 /** Waits while the target's NVM controller is busy performing an operation, exiting if the
60 * timeout period expires.
62 * \return Boolean true if the NVM controller became ready within the timeout period, false otherwise
64 bool TINYNVM_WaitWhileNVMControllerBusy(void)
70 /** Retrieves the CRC value of the given memory space.
72 * \param[in] CRCCommand NVM CRC command to issue to the target
73 * \param[out] CRCDest CRC Destination when read from the target
75 * \return Boolean true if the command sequence complete successfully
77 bool TINYNVM_GetMemoryCRC(const uint8_t CRCCommand
, uint32_t* const CRCDest
)
83 /** Reads memory from the target's memory spaces.
85 * \param[in] ReadAddress Start address to read from within the target's address space
86 * \param[out] ReadBuffer Buffer to store read data into
87 * \param[in] ReadSize Number of bytes to read
89 * \return Boolean true if the command sequence complete successfully
91 bool TINYNVM_ReadMemory(const uint32_t ReadAddress
, uint8_t* ReadBuffer
, const uint16_t ReadSize
)
97 /** Writes byte addressed memory to the target's memory spaces.
99 * \param[in] WriteCommand Command to send to the device to write each memory byte
100 * \param[in] WriteAddress Start address to write to within the target's address space
101 * \param[in] WriteBuffer Buffer to source data from
103 * \return Boolean true if the command sequence complete successfully
105 bool TINYNVM_WriteByteMemory(const uint8_t WriteCommand
, const uint32_t WriteAddress
, const uint8_t* WriteBuffer
)
111 /** Writes page addressed memory to the target's memory spaces.
113 * \param[in] WriteBuffCommand Command to send to the device to write a byte to the memory page buffer
114 * \param[in] EraseBuffCommand Command to send to the device to erase the memory page buffer
115 * \param[in] WritePageCommand Command to send to the device to write the page buffer to the destination memory
116 * \param[in] PageMode Bitfield indicating what operations need to be executed on the specified page
117 * \param[in] WriteAddress Start address to write the page data to within the target's address space
118 * \param[in] WriteBuffer Buffer to source data from
119 * \param[in] WriteSize Number of bytes to write
121 * \return Boolean true if the command sequence complete successfully
123 bool TINYNVM_WritePageMemory(const uint8_t WriteBuffCommand
, const uint8_t EraseBuffCommand
,
124 const uint8_t WritePageCommand
, const uint8_t PageMode
, const uint32_t WriteAddress
,
125 const uint8_t* WriteBuffer
, const uint16_t WriteSize
)
131 /** Erases a specific memory space of the target.
133 * \param[in] EraseCommand NVM erase command to send to the device
134 * \param[in] Address Address inside the memory space to erase
136 * \return Boolean true if the command sequence complete successfully
138 bool TINYNVM_EraseMemory(const uint8_t EraseCommand
, const uint32_t Address
)