diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-12-24 03:02:26 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-12-24 03:02:26 +0000 |
commit | 35dac470f243d234d72f34cbaeb1d6c8a15bc435 (patch) | |
tree | e4e4f1f7cdb2c3253ad34437043f9a07f3811616 /Projects/AVRISP/Lib/XPROG/XPROGProtocol.c | |
parent | 65fcebf4784486f1cb8da08d7a400963461f61ad (diff) | |
download | lufa-35dac470f243d234d72f34cbaeb1d6c8a15bc435.tar.gz lufa-35dac470f243d234d72f34cbaeb1d6c8a15bc435.tar.bz2 lufa-35dac470f243d234d72f34cbaeb1d6c8a15bc435.zip |
Complete TPI protocol code to enter and exit TPI programming mode for the ATTINY 6-pin devices.
Diffstat (limited to 'Projects/AVRISP/Lib/XPROG/XPROGProtocol.c')
-rw-r--r-- | Projects/AVRISP/Lib/XPROG/XPROGProtocol.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Projects/AVRISP/Lib/XPROG/XPROGProtocol.c b/Projects/AVRISP/Lib/XPROG/XPROGProtocol.c index f83561c83..edcc874d7 100644 --- a/Projects/AVRISP/Lib/XPROG/XPROGProtocol.c +++ b/Projects/AVRISP/Lib/XPROG/XPROGProtocol.c @@ -132,7 +132,13 @@ static void XPROGProtocol_EnterXPROGMode(void) /* Enable TPI programming mode with the attached target */
XPROGTarget_EnableTargetTPI();
- // TODO - enable NVM bus via KEY
+ /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */
+ XPROGTarget_SendByte(TPI_CMD_SKEY);
+ for (uint8_t i = sizeof(TPI_NVMENABLE_KEY); i > 0; i--)
+ XPROGTarget_SendByte(TPI_NVMENABLE_KEY[i - 1]);
+
+ /* Wait until the NVM bus becomes active */
+ NVMBusEnabled = TINYNVM_WaitWhileNVMBusBusy();
}
Endpoint_Write_Byte(CMD_XPROG);
@@ -159,7 +165,9 @@ static void XPROGProtocol_LeaveXPROGMode(void) }
else
{
- // TODO - Disable TPI via register
+ /* Clear the NVMEN bit in the TPI CONTROL register to disable TPI mode */
+ XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG);
+ XPROGTarget_SendByte(0x00);
XPROGTarget_DisableTargetTPI();
}
|