aboutsummaryrefslogtreecommitdiffstats
path: root/Projects
diff options
context:
space:
mode:
Diffstat (limited to 'Projects')
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c14
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h2
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c14
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h1
4 files changed, 22 insertions, 9 deletions
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
index 4d879bd67..41e6852ce 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
@@ -119,14 +119,13 @@ bool TINYNVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_
/** Writes byte addressed memory to the target's memory spaces.
*
- * \param[in] WriteCommand Command to send to the device to write each memory byte
* \param[in] WriteAddress Start address to write to within the target's address space
* \param[in] WriteBuffer Buffer to source data from
- *
+ * \param[in] WriteLength Total number of bytes to write to the device
*
* \return Boolean true if the command sequence complete successfully
*/
-bool TINYNVM_WriteMemory(const uint32_t WriteAddress, const uint8_t Byte)
+bool TINYNVM_WriteMemory(const uint32_t WriteAddress, const uint8_t* WriteBuffer, uint16_t WriteLength)
{
/* Wait until the NVM controller is no longer busy */
if (!(TINYNVM_WaitWhileNVMControllerBusy()))
@@ -139,9 +138,12 @@ bool TINYNVM_WriteMemory(const uint32_t WriteAddress, const uint8_t Byte)
/* Send the address of the location to write to */
TINYNVM_SendPointerAddress(WriteAddress);
- /* Write the byte of data to the target */
- XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT);
- XPROGTarget_SendByte(Byte);
+ while (WriteLength--)
+ {
+ /* Write the byte of data to the target */
+ XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT_PI);
+ XPROGTarget_SendByte(*(WriteBuffer++));
+ }
return true;
}
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h
index 2d98c0d48..e7d8dad2d 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h
+++ b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h
@@ -65,7 +65,7 @@
void TINYNVM_SendPointerAddress(const uint16_t AbsoluteAddress);
bool TINYNVM_WaitWhileNVMBusBusy(void);
bool TINYNVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t ReadLength);
- bool TINYNVM_WriteMemory(const uint32_t WriteAddress, const uint8_t Byte);
+ bool TINYNVM_WriteMemory(const uint32_t WriteAddress, const uint8_t* WriteBuffer, uint16_t WriteLength);
bool TINYNVM_EraseMemory(void);
#endif
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
index 39f82a0df..5275cca8d 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
@@ -134,6 +134,7 @@ static void XPROGProtocol_EnterXPROGMode(void)
}
else
{
+ #if 0
/* Enable TPI programming mode with the attached target */
XPROGTarget_EnableTargetTPI();
@@ -144,6 +145,8 @@ static void XPROGProtocol_EnterXPROGMode(void)
/* Wait until the NVM bus becomes active */
NVMBusEnabled = TINYNVM_WaitWhileNVMBusBusy();
+ #endif
+ NVMBusEnabled = true;
}
Endpoint_Write_Byte(CMD_XPROG);
@@ -313,9 +316,14 @@ static void XPROGProtocol_WriteMemory(void)
}
else
{
+ Serial_TxByte((uint8_t)WriteMemory_XPROG_Params.Length);
+
/* Send write command to the TPI device, indicate timeout if occurred */
- if (!(TINYNVM_WriteMemory(WriteMemory_XPROG_Params.Address, WriteMemory_XPROG_Params.ProgData[0])))
- ReturnStatus = XPRG_ERR_TIMEOUT;
+ if (!(TINYNVM_WriteMemory(WriteMemory_XPROG_Params.Address, WriteMemory_XPROG_Params.ProgData,
+ WriteMemory_XPROG_Params.Length)))
+ {
+ ReturnStatus = XPRG_ERR_TIMEOUT;
+ }
}
Endpoint_Write_Byte(CMD_XPROG);
@@ -355,6 +363,8 @@ static void XPROGProtocol_ReadMemory(void)
}
else
{
+ Serial_TxByte((uint8_t)ReadMemory_XPROG_Params.Length);
+
/* Read the TPI target's memory, indicate timeout if occurred */
if (!(TINYNVM_ReadMemory(ReadMemory_XPROG_Params.Address, ReadBuffer, ReadMemory_XPROG_Params.Length)))
ReturnStatus = XPRG_ERR_TIMEOUT;
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h
index a95e5b851..4bb600910 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h
@@ -42,6 +42,7 @@
#include <stdio.h>
#include <LUFA/Drivers/USB/USB.h>
+ #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include "../V2Protocol.h"
#include "XPROGTarget.h"