Skip to content

Commit

Permalink
pdi reads successfull
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars committed Dec 5, 2021
1 parent b2590d1 commit 2666376
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask)
{
// UECFG0X = ((UECFG0X & ~(1 << EPDIR)) | (DirectionMask ? (1 << EPDIR) : 0));
USB_Endpoint_SelectedEndpoint = (USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN) | DirectionMask;
//USB_Endpoint_SelectedEndpoint = (USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN) | DirectionMask;
}

/** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.
Expand Down
4 changes: 2 additions & 2 deletions Projects/AVRISP-MKII/AVRISP-MKII.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void SetupHardware(void)
#if defined(RESET_TOGGLES_LIBUSB_COMPAT)
UpdateCurrentCompatibilityMode();
#endif

/* USB Stack Initialization */
USB_Init();
}
Expand All @@ -122,7 +122,7 @@ void EVENT_USB_Device_ConfigurationChanged(void)
ConfigSuccess &= Endpoint_ConfigureEndpoint(AVRISP_DATA_OUT_EPADDR, EP_TYPE_BULK, AVRISP_DATA_EPSIZE, 1);

/* Setup AVRISP Data IN endpoint if it is using a physically different endpoint */
if ((AVRISP_DATA_IN_EPADDR & ENDPOINT_EPNUM_MASK) != (AVRISP_DATA_OUT_EPADDR & ENDPOINT_EPNUM_MASK))
//if ((AVRISP_DATA_IN_EPADDR & ENDPOINT_EPNUM_MASK) != (AVRISP_DATA_OUT_EPADDR & ENDPOINT_EPNUM_MASK))
ConfigSuccess &= Endpoint_ConfigureEndpoint(AVRISP_DATA_IN_EPADDR, EP_TYPE_BULK, AVRISP_DATA_EPSIZE, 1);

/* Indicate endpoint configuration success or failure */
Expand Down
2 changes: 1 addition & 1 deletion Projects/AVRISP-MKII/Config/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
#define PDI_USART USARTC0
#define PDI_PORT PORTC
#define PDI_RX_MASK (1 << 2)
#define PDI_RX_CTRL PIN1CTRL
#define PDI_RX_CTRL PIN2CTRL

#define PDI_TX_MASK (1 << 3)
#define PDI_TX_CTRL PIN3CTRL
Expand Down
4 changes: 2 additions & 2 deletions Projects/AVRISP-MKII/Config/LUFAConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
#define FIXED_NUM_CONFIGURATIONS 1
// #define CONTROL_ONLY_DEVICE
#define MAX_ENDPOINT_INDEX 4
// #define NO_DEVICE_REMOTE_WAKEUP
// #define NO_DEVICE_SELF_POWER
#define NO_DEVICE_REMOTE_WAKEUP
#define NO_DEVICE_SELF_POWER

#else

Expand Down
2 changes: 1 addition & 1 deletion Projects/AVRISP-MKII/Lib/V2Protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void V2Protocol_ProcessCommand(void)
#if ARCH == ARCH_AVR8
TCCR0B = ((1 << CS02) | (1 << CS00));
#elif ARCH == ARCH_XMEGA
TCD0.CTRLA = TC_CLKSEL_DIV1024_gc;
DELAY_TIMER.CTRLA = TC_CLKSEL_DIV1024_gc;
#endif
switch (V2Command)
{
Expand Down
3 changes: 3 additions & 0 deletions Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,11 @@ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress,
{
/* Send a LDS command with the read address to read out the requested byte */
XPROGTarget_SendByte(PDI_CMD_LDS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));

XMEGANVM_SendAddress(ReadAddress);

*(ReadBuffer++) = XPROGTarget_ReceiveByte();

}

return (TimeoutTicksRemaining > 0);
Expand Down
3 changes: 2 additions & 1 deletion Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ void XPROGTarget_SendByte(const uint8_t Byte)
#elif (ARCH == ARCH_XMEGA)
while(!(PDI_USART.STATUS & USART_DREIF_bm))
;
PDI_USART.STATUS |= USART_TXCIF_bm;
PDI_USART.DATA = Byte;
#endif
}
Expand All @@ -236,7 +237,7 @@ uint8_t XPROGTarget_ReceiveByte(void)
;
return UDR1;
#elif (ARCH == ARCH_XMEGA)
while(!(PDI_USART.STATUS & USART_RXCIF_bm))
while(!(PDI_USART.STATUS & USART_RXCIF_bm) && TimeoutTicksRemaining)
;
return PDI_USART.DATA;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Projects/AVRISP-MKII/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Run "make help" for target help.

MCU = atxmega128a4u
MCU = atxmega256a3u
ARCH = XMEGA
BOARD = NONE
F_CPU = 32000000
Expand Down

0 comments on commit 2666376

Please sign in to comment.