aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-12-28 07:17:21 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-12-28 07:17:21 +0000
commit7c8f4a716f01f6598234fd60cd53345da4903fde (patch)
tree352ac03ad26c195e273b723bda4e1777592b8f6b /Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
parent3222f21b849ca283cc6c1f07c347285b8cbce075 (diff)
downloadlufa-7c8f4a716f01f6598234fd60cd53345da4903fde.tar.gz
lufa-7c8f4a716f01f6598234fd60cd53345da4903fde.tar.bz2
lufa-7c8f4a716f01f6598234fd60cd53345da4903fde.zip
Add first draft of the TPI NVM commands for reading, writing and erasing a target. Needs testing when physical access to a part is available.
Diffstat (limited to 'Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c')
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
index f3f888e1c..39f82a0df 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
@@ -37,11 +37,17 @@
#include "XPROGProtocol.h"
#if defined(ENABLE_XPROG_PROTOCOL) || defined(__DOXYGEN__)
-/** Base absolute address for the target's NVM controller */
+/** Base absolute address for the target's NVM controller for PDI programming */
uint32_t XPROG_Param_NVMBase = 0x010001C0;
/** Size in bytes of the target's EEPROM page */
-uint32_t XPROG_Param_EEPageSize;
+uint16_t XPROG_Param_EEPageSize;
+
+/** Address of the TPI device's NVMCMD register for TPI programming */
+uint8_t XPROG_Param_NVMCMDRegAddr;
+
+/** Address of the TPI device's NVMCSR register for TPI programming */
+uint8_t XPROG_Param_NVMCSRRegAddr;
/** Currently selected XPROG programming protocol */
uint8_t XPROG_SelectedProtocol = XPRG_PROTOCOL_PDI;
@@ -222,7 +228,9 @@ static void XPROGProtocol_Erase(void)
}
else
{
- // TODO
+ /* Erase the target memory, indicate timeout if ocurred */
+ if (!(TINYNVM_EraseMemory()))
+ ReturnStatus = XPRG_ERR_TIMEOUT;
}
Endpoint_Write_Byte(CMD_XPROG);
@@ -294,18 +302,20 @@ static void XPROGProtocol_WriteMemory(void)
}
/* Send the appropriate memory write commands to the device, indicate timeout if occurred */
- if ((PagedMemory && !XMEGANVM_WritePageMemory(WriteBuffCommand, EraseBuffCommand, WriteCommand,
+ if ((PagedMemory && !(XMEGANVM_WritePageMemory(WriteBuffCommand, EraseBuffCommand, WriteCommand,
WriteMemory_XPROG_Params.PageMode, WriteMemory_XPROG_Params.Address,
- WriteMemory_XPROG_Params.ProgData, WriteMemory_XPROG_Params.Length)) ||
- (!PagedMemory && !XMEGANVM_WriteByteMemory(WriteCommand, WriteMemory_XPROG_Params.Address,
- WriteMemory_XPROG_Params.ProgData)))
+ WriteMemory_XPROG_Params.ProgData, WriteMemory_XPROG_Params.Length))) ||
+ (!PagedMemory && !(XMEGANVM_WriteByteMemory(WriteCommand, WriteMemory_XPROG_Params.Address,
+ WriteMemory_XPROG_Params.ProgData[0]))))
{
ReturnStatus = XPRG_ERR_TIMEOUT;
}
}
else
{
- // TODO
+ /* 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;
}
Endpoint_Write_Byte(CMD_XPROG);
@@ -339,13 +349,15 @@ static void XPROGProtocol_ReadMemory(void)
if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
{
- /* Read the target's memory, indicate timeout if occurred */
+ /* Read the PDI target's memory, indicate timeout if occurred */
if (!(XMEGANVM_ReadMemory(ReadMemory_XPROG_Params.Address, ReadBuffer, ReadMemory_XPROG_Params.Length)))
ReturnStatus = XPRG_ERR_TIMEOUT;
}
else
{
- // TODO
+ /* 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;
}
Endpoint_Write_Byte(CMD_XPROG);
@@ -428,9 +440,12 @@ static void XPROGProtocol_SetParam(void)
case XPRG_PARAM_EEPPAGESIZE:
XPROG_Param_EEPageSize = Endpoint_Read_Word_BE();
break;
- case XPRG_PARAM_UNDOC_1:
- case XPRG_PARAM_UNDOC_2:
- break; // Undocumented TPI parameter, just accept and discard
+ case XPRG_PARAM_NVMCMD:
+ XPROG_Param_NVMCMDRegAddr = Endpoint_Read_Byte();
+ break;
+ case XPRG_PARAM_NVMCSR:
+ XPROG_Param_NVMCSRRegAddr = Endpoint_Read_Byte();
+ break;
default:
ReturnStatus = XPRG_ERR_FAILED;
break;