(ReportItem->Attributes.Usage.Usage == USAGE_SCROLL_WHEEL) &&\r
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))\r
{\r
- int16_t WheelDelta = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));\r
+ int16_t WheelDelta = HID_ALIGN_DATA(ReportItem->Value, int16_t);\r
\r
if (WheelDelta)\r
LEDMask = (LEDS_LED1 | LEDS_LED2 | ((WheelDelta > 0) ? LEDS_LED3 : LEDS_LED4));\r
(ReportItem->Attributes.Usage.Usage == USAGE_Y)) &&\r
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))\r
{\r
- int16_t DeltaMovement = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));\r
+ int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem->Value, int16_t);\r
\r
if (ReportItem->Attributes.Usage.Usage == USAGE_X)\r
{\r
Pipe_SelectPipe(PNum);\r
\r
uint8_t PipeToken = Pipe_GetPipeToken();\r
+ bool PipeTokenCorrect = true;\r
\r
if (PipeToken != PIPE_TOKEN_SETUP)\r
- PipeToken = (PipeToken == ((EndpointAddress & PIPE_EPDIR_MASK) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT));\r
+ PipeTokenCorrect = (PipeToken == ((EndpointAddress & PIPE_EPDIR_MASK) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT));\r
\r
- if (Pipe_IsConfigured() && (Pipe_BoundEndpointNumber() == (EndpointAddress & PIPE_EPNUM_MASK)) && PipeToken)\r
- { \r
- return true;\r
- }\r
+ if (Pipe_IsConfigured() && PipeTokenCorrect && (Pipe_BoundEndpointNumber() == (EndpointAddress & PIPE_EPNUM_MASK)))\r
+ return true;\r
}\r
\r
Pipe_SelectPipe(PrevPipeNumber);\r
* - Fixed ADC routines not correctly returning the last result when multiple channels were read\r
* - Fixed ADC routines failing to read the extended channels (Channels 8 to 13, Internal Temperature Sensor) on the\r
* U4 series USB AVR parts\r
- * - Fixed PDI programming mode in the AVRISP programmer project not exiting programming mode correctly (clear target\r
- * Reset key twice, possible silicon bug?)\r
*\r
* \section Sec_ChangeLog100219 Version 100219\r
*\r
*/\r
static void TINYNVM_SendWriteNVMRegister(const uint8_t Address)\r
{\r
- /* The TPI command for writing to the I/O space uses weird addressing, where the I/O address's upper\r
+ /* The TPI command for reading from the I/O space uses strange addressing, where the I/O address's upper\r
* two bits of the 6-bit address are shifted left once */\r
XPROGTarget_SendByte(TPI_CMD_SOUT | ((Address & 0x30) << 1) | (Address & 0x0F));\r
}\r
/* Clear the RESET key in the RESET PDI register to allow the XMEGA to run */\r
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG); \r
XPROGTarget_SendByte(0x00);\r
- \r
- /* Clear /RESET key twice (for some reason this needs to be done twice to take effect) */\r
- XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG); \r
- XPROGTarget_SendByte(0x00);\r
\r
XPROGTarget_DisableTargetPDI();\r
}\r
\r
/* Set up the synchronous USART for XMEGA communications - \r
8 data bits, even parity, 2 stop bits */\r
- UBRR1 = (F_CPU / 500000UL);\r
+ UBRR1 = (F_CPU / XPROG_HARDWARE_SPEED);\r
UCSR1B = (1 << TXEN1);\r
UCSR1C = (1 << UMSEL10) | (1 << UPM11) | (1 << USBS1) | (1 << UCSZ11) | (1 << UCSZ10) | (1 << UCPOL1);\r
#else\r
\r
/* Set up the synchronous USART for TINY communications - \r
8 data bits, even parity, 2 stop bits */\r
- UBRR1 = (F_CPU / 500000UL);\r
+ UBRR1 = (F_CPU / XPROG_HARDWARE_SPEED);\r
UCSR1B = (1 << TXEN1);\r
UCSR1C = (1 << UMSEL10) | (1 << UPM11) | (1 << USBS1) | (1 << UCSZ11) | (1 << UCSZ10) | (1 << UCPOL1);\r
#else\r
\r
/* Tristate all pins */\r
DDRD &= ~((1 << 5) | (1 << 3));\r
- PORTD &= ~((1 << 3) | (1 << 2));\r
+ PORTD &= ~((1 << 5) | (1 << 3) | (1 << 2));\r
#else\r
/* Turn off software USART management timer */\r
TCCR1B = 0;\r
\r
- /* Tristate all pins */\r
+ /* Set DATA and CLOCK lines to inputs */\r
BITBANG_PDIDATA_DDR &= ~BITBANG_PDIDATA_MASK;\r
BITBANG_PDICLOCK_DDR &= ~BITBANG_PDICLOCK_MASK;\r
- BITBANG_PDICLOCK_PORT &= ~BITBANG_PDICLOCK_MASK; \r
+ \r
+ /* Tristate DATA and CLOCK lines */\r
BITBANG_PDIDATA_PORT &= ~BITBANG_PDIDATA_MASK;\r
+ BITBANG_PDICLOCK_PORT &= ~BITBANG_PDICLOCK_MASK; \r
#endif\r
}\r
\r
/* Defines: */\r
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))\r
#define XPROG_VIA_HARDWARE_USART\r
- #else\r
+ #else \r
#define BITBANG_PDIDATA_PORT PORTB\r
#define BITBANG_PDIDATA_DDR DDRB\r
#define BITBANG_PDIDATA_PIN PINB\r
#define BITBANG_TPICLOCK_MASK (1 << 1)\r
#endif\r
\r
+ /** Serial carrier TPI/PDI speed when hardware TPI/PDI mode is used */\r
+ #define XPROG_HARDWARE_SPEED 500000\r
+\r
/** Number of cycles between each clock when software USART mode is used */\r
- #define BITS_BETWEEN_USART_CLOCKS 80\r
+ #define BITS_BETWEEN_USART_CLOCKS 100\r
\r
/** Total number of bits in a single USART frame */\r
#define BITS_IN_USART_FRAME 12\r
# Target board (see library "Board Types" documentation, NONE for projects not requiring\r
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called \r
# "Board" inside the application directory.\r
-BOARD = XPLAIN\r
+BOARD = USBKEY\r
\r
\r
# Processor frequency.\r