\r
/** Writes byte addressed memory to the target's memory spaces.\r
*\r
- * \param[in] WriteCommand Command to send to the device to write each memory byte\r
* \param[in] WriteAddress Start address to write to within the target's address space\r
* \param[in] WriteBuffer Buffer to source data from\r
- *\r
+ * \param[in] WriteLength Total number of bytes to write to the device\r
*\r
* \return Boolean true if the command sequence complete successfully\r
*/\r
-bool TINYNVM_WriteMemory(const uint32_t WriteAddress, const uint8_t Byte)\r
+bool TINYNVM_WriteMemory(const uint32_t WriteAddress, const uint8_t* WriteBuffer, uint16_t WriteLength)\r
{\r
/* Wait until the NVM controller is no longer busy */\r
if (!(TINYNVM_WaitWhileNVMControllerBusy()))\r
/* Send the address of the location to write to */\r
TINYNVM_SendPointerAddress(WriteAddress);\r
\r
- /* Write the byte of data to the target */\r
- XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT);\r
- XPROGTarget_SendByte(Byte);\r
+ while (WriteLength--)\r
+ {\r
+ /* Write the byte of data to the target */\r
+ XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT_PI);\r
+ XPROGTarget_SendByte(*(WriteBuffer++));\r
+ }\r
\r
return true;\r
}\r
void TINYNVM_SendPointerAddress(const uint16_t AbsoluteAddress);\r
bool TINYNVM_WaitWhileNVMBusBusy(void);\r
bool TINYNVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t ReadLength);\r
- bool TINYNVM_WriteMemory(const uint32_t WriteAddress, const uint8_t Byte);\r
+ bool TINYNVM_WriteMemory(const uint32_t WriteAddress, const uint8_t* WriteBuffer, uint16_t WriteLength);\r
bool TINYNVM_EraseMemory(void);\r
\r
#endif\r
}\r
else\r
{\r
+ #if 0\r
/* Enable TPI programming mode with the attached target */\r
XPROGTarget_EnableTargetTPI();\r
\r
\r
/* Wait until the NVM bus becomes active */\r
NVMBusEnabled = TINYNVM_WaitWhileNVMBusBusy();\r
+ #endif\r
+ NVMBusEnabled = true;\r
}\r
\r
Endpoint_Write_Byte(CMD_XPROG);\r
}\r
else\r
{\r
+ Serial_TxByte((uint8_t)WriteMemory_XPROG_Params.Length);\r
+ \r
/* Send write command to the TPI device, indicate timeout if occurred */\r
- if (!(TINYNVM_WriteMemory(WriteMemory_XPROG_Params.Address, WriteMemory_XPROG_Params.ProgData[0])))\r
- ReturnStatus = XPRG_ERR_TIMEOUT;\r
+ if (!(TINYNVM_WriteMemory(WriteMemory_XPROG_Params.Address, WriteMemory_XPROG_Params.ProgData,\r
+ WriteMemory_XPROG_Params.Length)))\r
+ {\r
+ ReturnStatus = XPRG_ERR_TIMEOUT;\r
+ }\r
}\r
\r
Endpoint_Write_Byte(CMD_XPROG);\r
}\r
else\r
{\r
+ Serial_TxByte((uint8_t)ReadMemory_XPROG_Params.Length);\r
+\r
/* Read the TPI target's memory, indicate timeout if occurred */\r
if (!(TINYNVM_ReadMemory(ReadMemory_XPROG_Params.Address, ReadBuffer, ReadMemory_XPROG_Params.Length)))\r
ReturnStatus = XPRG_ERR_TIMEOUT;\r
#include <stdio.h>\r
\r
#include <LUFA/Drivers/USB/USB.h>\r
+ #include <LUFA/Drivers/Peripheral/SerialStream.h>\r
\r
#include "../V2Protocol.h"\r
#include "XPROGTarget.h"\r