aboutsummaryrefslogtreecommitdiffstats
path: root/Projects
diff options
context:
space:
mode:
authorjacobseptember <jacobseptember@users.noreply.github.com>2019-01-04 11:09:21 -0500
committerGitHub <noreply@github.com>2019-01-04 11:09:21 -0500
commitc1822a1f65facc85349c0ef34f9cc54ff036f600 (patch)
tree4ee5498bd864811c34480005a4bf611fd77a3941 /Projects
parentf5af6d23c0906de725f49753fb70c0d9a3ebd624 (diff)
downloadlufa-c1822a1f65facc85349c0ef34f9cc54ff036f600.tar.gz
lufa-c1822a1f65facc85349c0ef34f9cc54ff036f600.tar.bz2
lufa-c1822a1f65facc85349c0ef34f9cc54ff036f600.zip
Changes to interrupt blocking, etc for PR change
Diffstat (limited to 'Projects')
-rw-r--r--Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
index 4dc37a4c1..ffe2c56db 100644
--- a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
+++ b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
@@ -36,6 +36,7 @@
*/
#include "ISPProtocol.h"
+#include <util/atomic.h>
#if defined(ENABLE_ISP_PROTOCOL) || defined(__DOXYGEN__)
@@ -395,14 +396,14 @@ volatile uint16_t HalfCyclesRemaining;
volatile uint8_t ResponseTogglesRemaining;
/** ISR to toggle MOSI pin when TIMER1 overflows */
-ISR(TIMER1_OVF_vect)
+ISR(TIMER1_OVF_vect, ISR_BLOCK)
{
PINB |= (1 << PB2); // toggle PB2 (MOSI) by writing 1 to its bit in PINB
HalfCyclesRemaining--;
}
/** ISR to listen for toggles on MISO pin */
-ISR(PCINT0_vect)
+ISR(PCINT0_vect, ISR_BLOCK)
{
ResponseTogglesRemaining--;
}
@@ -444,22 +445,23 @@ void ISPProtocol_Calibrate(void)
ResponseTogglesRemaining = SUCCESS_TOGGLE_NUM;
/* Turn on interrupts */
- uint8_t OldSREG = SREG; // save current global interrupt state
PCICR |= (1 << PCIE0); // enable interrupts for PCINT7:0 (don't touch setting for PCINT12:8)
TIMSK1 = (1 << TOIE1); // enable T1 OVF interrupt (and no other T1 interrupts)
- sei(); // enable global interrupts
-
- /* Let device do its calibration, wait for reponse on MISO */
- while ( HalfCyclesRemaining && ResponseTogglesRemaining )
+
+ /* Turn on global interrupts for the following block, restoring current state at end */
+ NONATOMIC_BLOCK(NONATOMIC_RESTORESTATE)
{
- // do nothing...
+ /* Let device do its calibration, wait for reponse on MISO */
+ while ( HalfCyclesRemaining && ResponseTogglesRemaining )
+ {
+ // do nothing...
+ }
+
+ /* Disable interrupts */
+ PCICR &= ~(1 << PCIE0);
+ TIMSK1 = 0;
}
- /* Disable interrupts, restore SREG */
- PCICR &= ~(1 << PCIE0);
- TIMSK1 = 0;
- SREG = OldSREG;
-
/* Check if device responded with a success message or if we timed out */
if (ResponseTogglesRemaining)
{