From 7a1033025bbf0dcf4e4dc770fccb4edea86144a4 Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Wed, 8 Feb 2012 21:31:03 +0000
Subject: [PATCH] Minor documentation fixes.

Make an explicit constant name for the CMDEX bit of the target's NVM command register in the AVRISP-MKII Clone project.
---
 Projects/AVRISP-MKII/AVRISP-MKII.txt      | 38 ++++++++++++++---------
 Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c | 14 ++++-----
 Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h |  4 ++-
 Projects/XPLAINBridge/XPLAINBridge.txt    |  1 +
 4 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/Projects/AVRISP-MKII/AVRISP-MKII.txt b/Projects/AVRISP-MKII/AVRISP-MKII.txt
index d2977dde9..a6f00b4a3 100644
--- a/Projects/AVRISP-MKII/AVRISP-MKII.txt
+++ b/Projects/AVRISP-MKII/AVRISP-MKII.txt
@@ -215,63 +215,69 @@
  *    <td>AUX_LINE_PORT</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>PORT register for the programmer's AUX target line. The use of this line varies between the programming protocols,
- *        but is generally used for the target's /RESET line. <i>Ignored when compiled for the XPLAIN board.</i></td>
+ *        but is generally used for the target's /RESET line.
+ *        \n \n <i>Ignored when compiled for the XPLAIN board.</i></td>
  *   </tr>
  *   <tr>
  *    <td>AUX_LINE_PIN</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>PIN register for the programmer's AUX target line. The use of this line varies between the programming protocols,
- *        but is generally used for the target's /RESET line. <i>Ignored when compiled for the XPLAIN board.</i></td>
+ *        but is generally used for the target's /RESET line.
+ *        \n \n <i>Ignored when compiled for the XPLAIN board.</i></td>
  *   </tr>
  *   <tr>
  *    <td>AUX_LINE_DDR</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>DDR register for the programmer's AUX target line. The use of this line varies between the programming protocols,
- *        but is generally used for the target's /RESET line. <i>Ignored when compiled for the XPLAIN board.</i></td>
+ *        but is generally used for the target's /RESET line.
+ *        \n \n <i>Ignored when compiled for the XPLAIN board.</i></td>
  *   </tr>
  *   <tr>
  *    <td>AUX_LINE_MASK</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Mask for the programmer's AUX target line. The use of this line varies between the programming protocols,
- *        but is generally used for the target's /RESET line. <b>Must not be the AVR's /SS pin</b>. <i>Ignored when
- *        compiled for the XPLAIN board.</i></td>
+ *        but is generally used for the target's /RESET line. <b>Must not be the AVR's /SS pin</b>.
+ *        \n \n <i>Ignored when compiled for the XPLAIN board.</i></td>
  *   </tr>
  *   <tr>
  *    <td>VTARGET_ADC_CHANNEL</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>ADC channel number (on supported AVRs) to use for VTARGET level detection, if NO_VTARGET_DETECT is not defined.
- *        <i>Ignored when compiled for targets lacking an ADC.</i></td>
+ *        \n \n <i>Ignored when compiled for targets lacking an ADC.</i></td>
  *   </tr>
  *   <tr>
  *    <td>ENABLE_ISP_PROTOCOL</td>
  *    <td>Makefile LUFA_OPTS</td>
- *    <td>Define to enable SPI programming protocol support. <i>Ignored when compiled for the XPLAIN board.</i></td>
+ *    <td>Define to enable SPI programming protocol support.
+ *        \n \n <i>Ignored when compiled for the XPLAIN board.</i></td>
  *   </tr>
  *   <tr>
  *    <td>ENABLE_XPROG_PROTOCOL</td>
  *    <td>Makefile LUFA_OPTS</td>
- *    <td>Define to enable PDI and TPI programming protocol support. <i>Ignored when compiled for the XPLAIN board.</i></td>
+ *    <td>Define to enable PDI and TPI programming protocol support.
+ *        \n \n <i>Ignored when compiled for the XPLAIN board.</i></td>
  *   </tr>
  *   <tr>
  *    <td>NO_VTARGET_DETECT</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Define to disable VTARGET sampling and reporting on AVR models with an ADC converter. This will cause the programmer
- *        to report a fixed 3.3V target voltage to the host regardless of the real target voltage. <i>Ignored when compiled for
- *        targets lacking an ADC.</i></td>
+ *        to report a fixed 3.3V target voltage to the host regardless of the real target voltage. 
+ *        \n \n <i>Ignored when compiled for targets lacking an ADC.</i></td>
  *   </tr>
  *   <tr>
  *    <td>VTARGET_REF_VOLTS</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Indicates the programmer AVR's AVCC reference voltage when measuring the target's supply voltage. Note that the supply
  *        voltage should never exceed the reference voltage on the programmer AVR without some form of protection to prevent damage
- *        to the ADC. <i>Ignored when compiled for targets lacking an ADC, or when NO_VTARGET_DETECT is defined.</i></td>
+ *        to the ADC.
+ *        \n \n <i>Ignored when compiled for targets lacking an ADC, or when NO_VTARGET_DETECT is defined.</i></td>
  *   </tr>
  *   <tr>
  *    <td>VTARGET_USE_INTERNAL_REF</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Selects the internal 2.56V ADC reference voltage, instead of using the AVR's VREF pin. When enabled, this option will
- *        override the VTARGET_REF_VOLTS configuration option. <i>Ignored when compiled for targets lacking an ADC, or when
- *        NO_VTARGET_DETECT is defined.</i></td>
+ *        override the VTARGET_REF_VOLTS configuration option.
+ *        \n \n <i>Ignored when compiled for targets lacking an ADC, or when NO_VTARGET_DETECT is defined.</i></td>
  *   </tr>
  *   <tr>
  *    <td>VTARGET_SCALE_FACTOR</td>
@@ -279,7 +285,8 @@
  *    <td>Indicates the target's supply voltage scale factor when applied to the ADC. A simple resistive divider can be used on the
  *        ADC pin for measuring the target's supply voltage, so that voltages above the programmer AVR's AVCC reference voltage can be
  *        measured. This should be the reciprocal of the division performed - e.g. if the VTARGET voltage is halved, this should be set
- *        to 2. <i>Ignored when compiled for targets lacking an ADC, or when NO_VTARGET_DETECT is defined.</i></td>
+ *        to 2.
+ *        \n \n <i>Ignored when compiled for targets lacking an ADC, or when NO_VTARGET_DETECT is defined.</i></td>
  *   </tr>
  *   <tr>
  *    <td>LIBUSB_DRIVER_COMPAT</td>
@@ -291,7 +298,7 @@
  *    <td>XCK_RESCUE_CLOCK_ENABLE</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Define to move the ISP rescue clock to the AVR's XCK pin instead of the OCR1A output pin. This is useful for existing programming
- *        hardware that does not expose the OCR1A pin of the AVR, but *may* cause some issues with PDI programming mode.</td>
+ *        hardware that does not expose the OCR1A pin of the AVR, but <i>may</i> cause some issues with PDI programming mode.</td>
  *   </tr>
  *   <tr>
  *    <td>INVERTED_ISP_MISO</td>
@@ -301,6 +308,7 @@
  *   </tr>
  *   <tr>
  *    <td>FIRMWARE_VERSION_MINOR</td>
+ *    <td>Makefile LUFA_OPTS</td>
  *    <td>Define to set the minor firmware revision nunber reported to the host on request. By default this will use a firmware version compatible
  *        with the latest Atmel IDE version, however if desired the reported minor value can be adjusted here.</td>
  *   </tr>
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
index 820374fb9..567bd5777 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
@@ -186,7 +186,7 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest)
 	/* Set CMDEX bit in NVM CTRLA register to start the CRC generation */
 	XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
 	XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
-	XPROGTarget_SendByte(1 << 0);
+	XPROGTarget_SendByte(XMEGA_NVM_BIT_CTRLA_CMDEX);
 
 	/* Wait until the NVM bus is ready again */
 	if (!(XMEGANVM_WaitWhileNVMBusBusy()))
@@ -202,11 +202,11 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest)
 
 	/* Send the REPEAT command to grab the CRC bytes */
 	XPROGTarget_SendByte(PDI_CMD_REPEAT | PDI_DATSIZE_1BYTE);
-	XPROGTarget_SendByte(XMEGA_CRC_LENGTH - 1);
+	XPROGTarget_SendByte(XMEGA_CRC_LENGTH_BYTES - 1);
 
 	/* Read in the CRC bytes from the target */
 	XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
-	for (uint8_t i = 0; i < XMEGA_CRC_LENGTH; i++)
+	for (uint8_t i = 0; i < XMEGA_CRC_LENGTH_BYTES; i++)
 	  ((uint8_t*)CRCDest)[i] = XPROGTarget_ReceiveByte();
 
 	return (TimeoutExpired == false);
@@ -304,7 +304,7 @@ bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t Eras
 		/* Set CMDEX bit in NVM CTRLA register to start the buffer erase */
 		XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
 		XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
-		XPROGTarget_SendByte(1 << 0);
+		XPROGTarget_SendByte(XMEGA_NVM_BIT_CTRLA_CMDEX);
 	}
 
 	if (WriteSize)
@@ -376,7 +376,7 @@ bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address)
 		/* Set CMDEX bit in NVM CTRLA register to start the erase sequence */
 		XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
 		XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
-		XPROGTarget_SendByte(1 << 0);
+		XPROGTarget_SendByte(XMEGA_NVM_BIT_CTRLA_CMDEX);
 	}
 	else if (EraseCommand == XMEGA_NVM_CMD_ERASEEEPROM)
 	{
@@ -388,7 +388,7 @@ bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address)
 		/* Set CMDEX bit in NVM CTRLA register to start the buffer erase */
 		XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
 		XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
-		XPROGTarget_SendByte(1 << 0);
+		XPROGTarget_SendByte(XMEGA_NVM_BIT_CTRLA_CMDEX);
 
 		/* Wait until the NVM controller is no longer busy */
 		if (!(XMEGANVM_WaitWhileNVMControllerBusy()))
@@ -420,7 +420,7 @@ bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address)
 		/* Set CMDEX bit in NVM CTRLA register to start the EEPROM erase sequence */
 		XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
 		XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
-		XPROGTarget_SendByte(1 << 0);
+		XPROGTarget_SendByte(XMEGA_NVM_BIT_CTRLA_CMDEX);
 	}
 	else
 	{
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h
index 05ee5be9c..a8704df3c 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h
@@ -56,7 +56,7 @@
 		#endif
 
 	/* Defines: */
-		#define XMEGA_CRC_LENGTH                     3
+		#define XMEGA_CRC_LENGTH_BYTES               3
 
 		#define XMEGA_NVM_REG_ADDR0                  0x00
 		#define XMEGA_NVM_REG_ADDR1                  0x01
@@ -70,6 +70,8 @@
 		#define XMEGA_NVM_REG_INTCTRL                0x0D
 		#define XMEGA_NVM_REG_STATUS                 0x0F
 		#define XMEGA_NVM_REG_LOCKBITS               0x10
+		
+		#define XMEGA_NVM_BIT_CTRLA_CMDEX            (1 << 0)
 
 		#define XMEGA_NVM_CMD_NOOP                   0x00
 		#define XMEGA_NVM_CMD_CHIPERASE              0x40
diff --git a/Projects/XPLAINBridge/XPLAINBridge.txt b/Projects/XPLAINBridge/XPLAINBridge.txt
index 52cf99fac..9dead426e 100644
--- a/Projects/XPLAINBridge/XPLAINBridge.txt
+++ b/Projects/XPLAINBridge/XPLAINBridge.txt
@@ -91,6 +91,7 @@
  *   </tr>
  *   <tr>
  *    <td>FIRMWARE_VERSION_MINOR</td>
+ *    <td>Makefile LUFA_OPTS</td>
  *    <td>Define to set the minor firmware revision nunber reported to the host on request. By default this will use a firmware version compatible
  *        with the latest Atmel IDE version, however if desired the reported minor value can be adjusted here.</td>
  *   </tr>
-- 
GitLab