/* Enable TPI programming mode with the attached target */\r
XPROGTarget_EnableTargetTPI();\r
\r
- // TODO - enable NVM bus via KEY \r
+ /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
+ XPROGTarget_SendByte(TPI_CMD_SKEY); \r
+ for (uint8_t i = sizeof(TPI_NVMENABLE_KEY); i > 0; i--)\r
+ XPROGTarget_SendByte(TPI_NVMENABLE_KEY[i - 1]);\r
+\r
+ /* Wait until the NVM bus becomes active */\r
+ NVMBusEnabled = TINYNVM_WaitWhileNVMBusBusy();\r
}\r
\r
Endpoint_Write_Byte(CMD_XPROG);\r
}\r
else\r
{\r
- // TODO - Disable TPI via register\r
+ /* Clear the NVMEN bit in the TPI CONTROL register to disable TPI mode */\r
+ XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG); \r
+ XPROGTarget_SendByte(0x00);\r
\r
XPROGTarget_DisableTargetTPI();\r
}\r