Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Erik Strand
lufa
Commits
37c9ba7f
Commit
37c9ba7f
authored
Dec 20, 2009
by
Dean Camera
Browse files
Fixed AVRISP project timeouts not checking for the correct timeout period (thanks to Carl Ott).
parent
8b756595
Changes
6
Hide whitespace changes
Inline
Side-by-side
LUFA/ManPages/ChangeLog.txt
View file @
37c9ba7f
...
...
@@ -68,6 +68,7 @@
* - Fixed USB_CurrentMode not being reset to USB_MODE_NONE when the USB interface is shut down and both Host and Device modes can be
* used (thanks to Daniel Levy)
* - Fixed TeensyHID bootloader not enumerating to the host correctly
* - Fixed AVRISP project timeouts not checking for the correct timeout period (thanks to Carl Ott)
*
* \section Sec_ChangeLog091122 Version 091122
*
...
...
Projects/AVRISP/Lib/ISPTarget.c
View file @
37c9ba7f
...
...
@@ -123,16 +123,25 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1
case
PROG_MODE_WORD_VALUE_MASK
:
case
PROG_MODE_PAGED_VALUE_MASK
:
TCNT0
=
0
;
TIFR0
=
(
1
<<
OCF1A
);
uint8_t
TimeoutMS
=
TARGET_BUSY_TIMEOUT_MS
;
do
{
SPI_SendByte
(
ReadMemCommand
);
SPI_SendByte
(
PollAddress
>>
8
);
SPI_SendByte
(
PollAddress
&
0xFF
);
SPI_SendByte
(
PollAddress
&
0xFF
);
if
(
TIFR0
&
(
1
<<
OCF1A
))
{
TIFR0
=
(
1
<<
OCF1A
);
TimeoutMS
--
;
}
}
while
((
SPI_TransferByte
(
0x00
)
!=
PollValue
)
&&
(
TCNT0
<
TARGET_BUSY_TIMEOUT_
MS
)
)
;
while
((
SPI_TransferByte
(
0x00
)
!=
PollValue
)
&&
Timeout
MS
);
if
(
TCNT0
>=
TARGET_BUSY_TIMEOUT_
MS
)
if
(
!
(
Timeout
MS
)
)
ProgrammingStatus
=
STATUS_CMD_TOUT
;
break
;
...
...
@@ -153,6 +162,9 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1
uint8_t
ISPTarget_WaitWhileTargetBusy
(
void
)
{
TCNT0
=
0
;
TIFR0
=
(
1
<<
OCF1A
);
uint8_t
TimeoutMS
=
TARGET_BUSY_TIMEOUT_MS
;
do
{
...
...
@@ -160,10 +172,16 @@ uint8_t ISPTarget_WaitWhileTargetBusy(void)
SPI_SendByte
(
0x00
);
SPI_SendByte
(
0x00
);
if
(
TIFR0
&
(
1
<<
OCF1A
))
{
TIFR0
=
(
1
<<
OCF1A
);
TimeoutMS
--
;
}
}
while
((
SPI_ReceiveByte
()
&
0x01
)
&&
(
TCNT0
<
TARGET_BUSY_TIMEOUT_
MS
)
)
;
while
((
SPI_ReceiveByte
()
&
0x01
)
&&
Timeout
MS
);
if
(
TCNT0
>=
TARGET_BUSY_TIMEOUT_
MS
)
if
(
!
(
Timeout
MS
)
)
return
STATUS_RDY_BSY_TOUT
;
else
return
STATUS_CMD_OK
;
...
...
Projects/AVRISP/Lib/NVMTarget.c
View file @
37c9ba7f
...
...
@@ -72,9 +72,12 @@ void NVMTarget_SendAddress(const uint32_t AbsoluteAddress)
bool
NVMTarget_WaitWhileNVMControllerBusy
(
void
)
{
TCNT0
=
0
;
TIFR0
=
(
1
<<
OCF1A
);
uint8_t
TimeoutMS
=
PDI_NVM_TIMEOUT_MS
;
/* Poll the NVM STATUS register while the NVM controller is busy */
while
(
T
CNT0
<
NVM_BUSY_TIMEOUT_
MS
)
while
(
T
imeout
MS
)
{
/* Send a LDS command to read the NVM STATUS register to check the BUSY flag */
PDITarget_SendByte
(
PDI_CMD_LDS
|
(
PDI_DATSIZE_4BYTES
<<
2
));
...
...
@@ -83,6 +86,12 @@ bool NVMTarget_WaitWhileNVMControllerBusy(void)
/* Check to see if the BUSY flag is still set */
if
(
!
(
PDITarget_ReceiveByte
()
&
(
1
<<
7
)))
return
true
;
if
(
TIFR0
&
(
1
<<
OCF1A
))
{
TIFR0
=
(
1
<<
OCF1A
);
TimeoutMS
--
;
}
}
return
false
;
...
...
Projects/AVRISP/Lib/PDITarget.c
View file @
37c9ba7f
...
...
@@ -311,14 +311,23 @@ void PDITarget_SendBreak(void)
bool
PDITarget_WaitWhileNVMBusBusy
(
void
)
{
TCNT0
=
0
;
TIFR0
=
(
1
<<
OCF1A
);
uint8_t
TimeoutMS
=
PDI_NVM_TIMEOUT_MS
;
/* Poll the STATUS register to check to see if NVM access has been enabled */
while
(
T
CNT0
<
PDI_NVM_TIMEOUT_
MS
)
while
(
T
imeout
MS
)
{
/* Send the LDCS command to read the PDI STATUS register to see the NVM bus is active */
PDITarget_SendByte
(
PDI_CMD_LDCS
|
PDI_STATUS_REG
);
if
(
PDITarget_ReceiveByte
()
&
PDI_STATUS_NVM
)
return
true
;
if
(
TIFR0
&
(
1
<<
OCF1A
))
{
TIFR0
=
(
1
<<
OCF1A
);
TimeoutMS
--
;
}
}
return
false
;
...
...
Projects/AVRISP/Lib/V2Protocol.h
View file @
37c9ba7f
...
...
@@ -70,7 +70,16 @@
static
inline
void
V2Protocol_DelayMS
(
uint8_t
DelayMS
)
{
TCNT0
=
0
;
while
(
TCNT0
<
DelayMS
);
TIFR0
=
(
1
<<
OCF1A
);
while
(
DelayMS
)
{
if
(
TIFR0
&
(
1
<<
OCF1A
))
{
TIFR0
=
(
1
<<
OCF1A
);
DelayMS
--
;
}
}
}
/* External Variables: */
...
...
Projects/AVRISP/makefile
View file @
37c9ba7f
...
...
@@ -66,7 +66,7 @@ MCU = at90usb1287
# Target board (see library "Board Types" documentation, USER or blank for projects not requiring
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
# "Board" inside the application directory.
BOARD
=
XPLAIN
BOARD
=
USBKEY
# Processor frequency.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment